Jump to content

Errors within code.


dean7

Recommended Posts

Hi all, i've coded a script for my website but ive got a few error's in the code which i'm not sure how to sort:

 

 

Notice: Undefined variable: carid in /home/www/**********/hts2.php on line 11

 

Notice: Undefined variable: fuel in /home/www/*******/hts2.php on line 13

 

Notice: Trying to get property of non-object in /home/www/*****/hts2.php on line 23

 

$timenow = time();
$username = $_SESSION['username'];
$query=mysql_query("SELECT * FROM garage WHERE id='$carid' LIMIT 1"); // Line 11
$info = mysql_fetch_object($query);
$query1=mysql_query("SELECT * FROM garage WHERE fuel='$fuel' LIMIT 2"); // Line 13
$info2 = mysql_fetch_object($query1);

// -------------------

if($info->fuel < 15){ // Line 23

 

There the bit's of the code i'm having problems with. I've tried de-bugging it but carn't seem to sort it.

 

Anyone know why I'm getting these error's?

 

Thanks.

 

 

Link to comment
Share on other sites

The undefined variable notices are simply alerting you that you're trying to use a variable that doesn't exist. As they don't exist though that then means your queries are returning 0 results, and so when you try to use $info->fuel you're being notified that the property "fuel" doesn't exist (as there's no results).

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.