You have an error in your SQL syntax; check the manual that corresponds to your MySQL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hamid Alizada
    New Member
    • Apr 2013
    • 1

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL

    hi everybody!

    i have one error in sql like this. 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
    and i could not fine the problem there was answer but not helpfull

    here is the code

    Code:
    > <?php // put the action here ?> <form
    > action="http://onevatan.net/?page_id=15" method="post"> <p>Please
    > Enter Your ID: <input name="frm" type="text" />   <input
    > name="searchbtn" type="submit" value="Search"  /></p>
    > 
    > </form>
    > 
    > <?php 	$frm= $_POST['frm']; 	$result = mysql_query("SELECT * FROM
    > wp_participants_database WHERE sid = $frm"); 	if(!$result){
    > 		die(mysql_error()); 	} echo "<table border='1'> <tr> <th>photo</th>
    > <th>Student ID</th> <th>First Name</th> <th>Father Name</th>
    > <th>address</th> <th>Class</th> </tr>";
    > 
    > while($row = mysql_fetch_array($result))   {   echo "<tr>";   echo
    > "<td>" . $row['photo'] . "</td>";   echo "<td>" . $row['sid'] .
    > "</td>";   echo "<td>" . $row['first_name'] . "</td>";   echo "<td>" .
    > $row['last_name'] . "</td>";   echo "<td>" . $row['address'] .
    > "</td>";   echo "<td>" . $row['class'] . "</td>";   echo "</tr>";   }
    > echo "</table>"; ?> </body> </html>
    > 
    > <?php //close mysql_close(); ?>
    thanks
    Last edited by Rabbit; Apr 2 '13, 08:49 PM. Reason: Please use code tags when posting code.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You should double check your query string and see if it's returning the SQL you want. And if it is, see if it runs in MySQL without going through PHP.

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #3
      I stab a guess at missing quotes.

      Comment

      Working...