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
https://forums.phpfreaks.com/topic/206506-errors-within-code/
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
https://forums.phpfreaks.com/topic/206506-errors-within-code/#findComment-1080187
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.