Forum Moderators: coopster
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Inetpub\wwwroot\thegreatest\nominate.php on line 35
not added due to database 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 '\" (name,reason) VALUES ('testing ','testing one two')' at line
2 things
1. echo the full constructed query before sending it to mysql_query
echo '<p>',$addnomsql;
2. add an or die to your query statement
$query = mysql_query($addnomsql) or die ('<p>' . mysql_error());
though that may be the error from mysql, I hate those ones, they don't tell you anything. My guess is that the $thislist var is not a proper tablename or there is something extra in there
.
This is driving me nuts. I cazn't figure it out and my debugger isn't helping my at all. OF course it doesn't help that the only time I get to work on it is aboult 30 min before bed when everything is blurry and my eyes are stinging.
if(isset($_POST['name'])){
$sql="SELECT name FROM $thislist";
echo " sql2= $sql<br>";
$results=mysql_query($sql);
if(!$results){
exit('<p>erros retrieving data!<br />' . 'Error:' . mysql_error() . '</p>');}
$validnominecheck='yes';
$nomname=$_POST['name'];
$nomreason=$_POST['reason'];
echo " <br>Nominee name= $nomname";
while($stuff=mysql_fetch_array($results)){
$dbname=$stuff['name'];
if($dbname==$nomname)
{$validnominecheck='no'; }
}
if($validnominecheck=='yes'){
$addnomsql="INSERT INTO $thislist name=$nomname, reason=$nomreason";
echo "$addnomsql <br>";
if(@mysql_query($addnomsql)){
echo'<p>Your nominee has been added</p>';
}else{
echo'<p>Nominee was not added due to database error:' . mysql_error().'</p>';
}
}else{
echo '<p>Nominee not added because nominee has already been nominated</p>';
}
exit();
Nominee name= testing
INSERT INTO tg_american name=testing, reason=123
Nominee was not added due to database 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 'name=testing, reason=123' at line 1
this is the error i get
Nominee name= testing
INSERT INTO tg_american SET (name,reason) VALUES ('testing','1234')
Nominee was not added due to database 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 '(name,reason) VALUES ('testing','1234')' at line 1
INSERT INTO $thislist (name,reason) VALUES ('$nomname','$nomreason');
I can`t really see any reason for that failing unless there is a problem with the $thislist variable, which there doesn`t seem to be as the name of the table is in the error query.