Member Offer
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[PHP] Can some one tell me why this is failing please

Discussion in 'Website Design Forum:' started by Jazajay, Nov 8, 2010.

  1. Jazajay

    Jazajay Active Member

    Right peeps,
    This keeps failing and I'm not sure why. :mad:

    $query="SELECT id FROM jos_users WHERE username='".$username."'";
    $database->setQuery($query);
    $rows=$database->loadObjectList();
    $row2=$rows[0];
    $id=$row2->id;

    $query2="SELECT city, country, vm_newsletter FROM jos_vm_user_info WHERE user_id='".$id."'";
    $database->setQuery($query2);
    $rows=$database->loadObjectList();
    $row2=$rows[0]; // failing here
    $city=$row2->city;
    $country=$row2->country;
    $news=$row2->vm_newsletter;

    if($news==1){
    $sendNews="Yes";
    }else{
    $sendNews="No";
    }
    $news=$vm_newsletter;

    The output I get is in green below:

    Username - james
    City -
    Country -
    Newsletter -
    ID - 174
    Rows - Array
    Rows 0 -
    Row2 -

    Really confused as to why that fails?????? :confused:

    Any help????
     
  2. Jazajay

    Jazajay Active Member

    This thread can be closed I was trying to select the data from a table that hadn't had the data inserted into yet.Hence nothing to select. Errr......anyhoo. :cry:
     

Share This Page