error:
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
Its valid sql I checked I just don't understand what would cause that error. I also tried different statements and they worked. So I don't get it.
code:
<?php $con = mysql_connect('localhost','me','omglol');
mysql_select_db('dancks_db',$con);
?>
<?php
session_start();
$session_name = "forces";
$com=0;
function logout()
{
$_SESSION = array();
session_destroy();
//header('Location:http://cs4.sunyocc.edu/~j.d.dancks/index.php');
}
if(!isset($_SESSION['time']) || !isset($_SESSION['nick']))
{
$com=2;
logout();
}
else if($_SESSION['time'] < time())
{
$com=3;
logout();
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$query_Recordset1 = sprintf("select * from Item where ItemID=%i",$_GET['id']);
$Recordset1 = mysql_query($query_Recordset1, $con) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if(mysql_num_rows($Recordset1)!=1)
{
header('Location:http://cs4.sunyocc.edu/~j.d.dancks/onestopshop/productnotfound.html');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<?php echo "<title>".$row_Recordset1['name']."</title>\n"; ?>
</head>
<body>
<div id="header">
<?php echo "<h1>".$row_Recordset1['name']."</h1>\n"; ?>
</div>
<div id="content">
<div id="image-container-left">
<div style="background-color:black; border:thick;">
<?php
if(isset($row_Recordset1['image']))
{
echo "<img src=\"images/".$row_Recordset1['image']."\" />\n";
}
else
{
echo "<img src=\"images/noimage.jpg\" />\n";
}
?>
</div>
</div>
<div id="right-container">
<div id="info">
<div id="description">
<?php
echo "<p>".$row_Recordset1['descr']."</p>\n";
?>
</div>
<div id="bids">
<?php echo "<h2>Highest Bid: $".$row_Recordset1['highest_bid']."</h2>\n"; ?>
<?php if(isset($_SESSION['name']))
{
echo " <p>Place your bid here:</p>
<form id=\"bid-enter\" action=\"registerbid.php\" method=\"post\">\n
<input type=\"text\" name=\"bid\" />\n
<input type=\"hidden\" name=\"prod\" value=".$row_Recordset1['ItemID']."\" />\n
<input type=\"submit\" />\n
</form>\n";
}
?>
</div>
</div>
<div id="nav-pane">
</div>
</div>
</div>
<div id="footer">
</div>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>