SQL syntax problem

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
Smackie
Forum Contributor
Posts: 302
Joined: Sat Jan 29, 2005 2:33 pm

SQL syntax problem

Post by Smackie »

I made a poetry script and started adding the submit script so users can add there poems and well i keep coming up with this 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 2
here is the two scripts

poempost.php

Code: Select all

<?php

if (($_SESSION['user_level'] == 1) || ($_SESSION['user_level'] == 2) || ($_SESSION['user_level'] == 3) || ($_SESSION['user_level'] == 4) || ($_SESSION['user_level'] == 5)) {

               	echo '<div align="center">
<form name="poemscript" method="post" action="../index.php?pages=poemsubmit">
   <table width="25%" border="0" cellpadding="4" cellspacing="0" bordercolor="#3399CC">
      <tr> 
        <td width="12%" class="txt"><div align="right">Name:</div></td>
        <td width="88%"class="txt"><b>'.$_SESSION['user_name'].'</b><input name="name" type="hidden" value="'.$_SESSION['user_name'].'"></td>
      </tr>
      <tr> 
        <td ><font color="red">*</font></td> 
		<td ><div align="right" class="txt">Poem Name:</div></td>
        <td><input name="poemname" type="text" value="" size="30" maxlength="100" class="input-box"></td>
      </tr>
      <tr> 
        <td ><font color="red">*</font></td>
		<td ><div align="right" class="txt">Poem:</div></td>
        <td><textarea name="poem" cols="50" rows="5" id="message" class="input-box"></textarea></td>
      </tr>
      <tr> 
        <td>&nbsp;</td>
        <td><div align="right"><input name="poempost" type="submit" id="poempost" value="post" class="submit-button"></div></td>
      </tr>
    </table>';
}
?>
poemsubmit.php

Code: Select all

<?php

$user_name = $_POST['user_name'];
$poemname = $_POST['poemname'];
$poem = $_POST['poem'];

if ((!$poemname) || (!$poem)){
	
	echo '<center><font size="1" face="tahoma" color="red"><b>Error!</b> Fields marked * are required to continue.</font></center><br>';
	require 'Poem/poempost.php';
	return;
}

echo '<center><font class="txt">Thank you for submitting your poem at hauntedgraveyard.net....</font></center>';

$sql = mysql_query("INSERT INTO poems (user_name, poemname, poem)
		VALUES('$user_name', '$poemname', '$poem'())") or die (mysql_error());


if (!$sql) {
	
	echo '<center><font class="txt">There has been an error creating your account. Please contact the webmaster.</font></center>';

}
?>

Can someone help please
Thanx
Smackie
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

Looks like its the extra '()' you have at the end of the query, after poem.
Smackie
Forum Contributor
Posts: 302
Joined: Sat Jan 29, 2005 2:33 pm

Post by Smackie »

Thanx :? :? that was a little hard to find lol :? thanx
Post Reply