Jump to content

code error on testing


gwh

Recommended Posts

Hi everyone,

 

Does anyone know what's wrong with the following code:

 

mysql_select_db($database_localhost, $localhost);
$query_rsShirts_Desc = "SELECT shirtID, shirtDescLadies, shirtDescMen FROM shirts WHERE shirtID IS '$shirtID'";
$rsShirts_Desc = mysql_query($query_rsShirts_Desc, $localhost) or die(mysql_error());
$row_rsShirts_Desc = mysql_fetch_assoc($rsShirts_Desc);
$totalRows_rsShirts_Desc = mysql_num_rows($rsShirts_Desc);

$shirtID = 4; //The shirtID of the item you are currently viewing

 

I get the following error:

 

Notice: Undefined variable: shirtID in /Applications/MAMP/htdocs/new_site/catalogue.php on line 47

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '''' at line 1

 

Appreciate any advice.

Link to comment
https://forums.phpfreaks.com/topic/184786-code-error-on-testing/
Share on other sites

Where is shirtID coming from? I see you have it defined after the query. Is that suppose to be before so the variable is defined and the query will actually pull the contents from shirts where shirtid = 4?

 

Also your "IS" statement should be an =

 

"SELECT shirtID, shirtDescLadies, shirtDescMen FROM shirts WHERE shirtID = '$shirtID'"

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.