Jump to content

[SOLVED] Query does not get variable from DB


monkeybidz

Recommended Posts

The following code only gets user and title from database, but does not get the rest. They do exsist in database.

 

$query = "select * from PHPAUCTIONREVERSE_auctions where id=".intval($_REQUEST[id]);

$result = mysql_query($query);

if ( !$result ) {

print "aki 3"; exit;

   MySQLError($query);

   exit;

}

 

$user           = stripslashes(mysql_result ( $result, 0, "user" ));

$title          = stripslashes(mysql_result ( $result, 0, "title" ));

$origin_zip = mysql_result($result, 0, "origin_zip");

$destination_zip     = mysql_result ( $result, 0, "destination_zip" );

$pickup_date     = mysql_result ( $result, 0, "pickup_date" );

$delivery_date     = mysql_result ( $result, 0, "delivery_date" );

$origin_type     = mysql_result ( $result, 0, "origin_type" );

$destination_type     = mysql_result ( $result, 0, "destination_type" );

$city_details1 =  mysql_result( $result, 0, "city_details1" );

$state1     = mysql_result ( $result, 0, "state1" );

$city_details2     = mysql_result ( $result, 0, "city_details2" );

$state2     = mysql_result ( $result, 0, "state2" );

$miles     = mysql_result ( $result, 0, "miles" );

Link to comment
Share on other sites

Please, after 165 posts, could you please use the BBCode format for posting code?

 

Anyways, try this and post the results:

 

$query = "select * from PHPAUCTIONREVERSE_auctions where id=".intval($_REQUEST[id]);
$result = mysql_query($query);
if ( !$result ) {
print "aki 3"; exit;
    MySQLError($query);
    exit;
}
$row = mysql_fetch_array($result);
echo "<pre>";
print_r($row);
die("</pre>");

 

PhREEEk

Link to comment
Share on other sites

You said only user and title is returned. I posted code to see exactly what all is being pulled. If it's all there, then do this:

 

$row = mysql_fetch_array($result);
$user             = stripslashes($row['user']);
$title            = stripslashes($row['title']);
$origin_zip       =  $row['origin_zip'];
$destination_zip  = $row['destination_zip'];
etc, etc...

 

PhREEEk

Link to comment
Share on other sites

DOPE!!!!!

There was nothing wrong, turns out I added the new fields to DB after items had already been inserted to DB. Last input was ID 19. When I tried to look at that item on site, the information did not exsist for this item, but when I looked at all newer items ID's 20 and up everything looks good.

 

By the way your code also worked when viewing the updated items.

 

Thanks for your help.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.