SirChick Posted November 9, 2007 Share Posted November 9, 2007 I have a query which gets to two fields.. one is from one row and the other field is coming from a different row when they should be the same row! It makes no sense i've not had this problem before... and i dont see any problem with my query either this is what i have: <? $GetUserCars = mysql_query("SELECT * FROM cars WHERE UserID='{$_SESSION['Current_User']}' AND Equipped='1'") or die(mysql_error()); // Fetch the row from the database if (!($carsrow = mysql_fetch_assoc($GetUserCars))) { Header ("location: myhouseinfo.php"); }else{ $CarCondition = $carsrow['Longetivity']; $PetrolLeft = $carsrow['FuelLeft']; } Echo $CarCondition; Echo $PetrolLeft; ?> Also only one of the rows has Equipped set to 1 the other is set to 0 so there is something wrong at that part of the query.. not sure why I have attatched pictures to show you: As you see the second row is echo'd for fuel left and row 1 is echo'd for CarCondition so i dont get how :S [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
phpknight Posted November 9, 2007 Share Posted November 9, 2007 Run them through phpmyadmin and at least see if what is returned is what you want. Quote Link to comment Share on other sites More sharing options...
SirChick Posted November 10, 2007 Author Share Posted November 10, 2007 how do you do that? Also just to add if i delete the row which has Equipped=0 meaning there is only 1 row it then works fine ... duno but the second i add a row it screws up . Quote Link to comment Share on other sites More sharing options...
phpknight Posted November 10, 2007 Share Posted November 10, 2007 Just login to phpmyadmin. You should have it. Click on "SQL" and run the query to make sure you are getting the results you are anticipating. If you are, then move on to the PHP code. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.