PHP Question [SOLVED]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

PHP Question [SOLVED]

Post by John Cartwright »

Code: Select all

<?php
if ($submitrecord == "SUBMIT") { 
     if ($league == "cal") { 


	$sql = "INSERT INTO 'records_cal', 'records_total' SET opponents='$opponent', date='$date', map='$map', league='$league', outcome='$outcome'" ; 
	
	}

// Confirming data has been entered or not
  if (@mysql_query($sql)) { 
    echo("<div align="center">Your Record has been added.</div>"); 
  } else { 
    echo ("<div align="center">Error adding submitted record: " . mysql_error() . "</div>"); 
  } 
}
?>
I come on and try it, and i start getting this error:

Error adding submitted record: 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 ''records_cal' SET opponents='Test', date='2004-01-01', map='de_
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

In this line try echoing out the entire query so we can see whats happening:

Code: Select all

<?php
else {
    echo ("<div align="center">Error adding submitted record: " . mysql_error() . "<br />Original Query: " . $sql . "</div>");
  } 
?>
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Post by Cruzado_Mainfrm »

phenom, don't ask the moderators of this forum to delete this post, it might help other people someday that had the same problem...
or is it that you don't want to look back in the future and see a question like this one being one of yours? :wink: it's ok, maybe you'll look back at this post to fix your code again if u have the same problem another time...
Straterra
Forum Regular
Posts: 527
Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:

Post by Straterra »

Yes, please make the name of this topic back to its normal, but with [FIXED] or something of that matter in it.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Wish granted.
Post Reply