Lambneck Posted April 12, 2008 Share Posted April 12, 2008 Hello, I have here, echoed as a link, the subject of my submitted forms. What I am trying to do is make it so each individual subject from a form submission becomes a link to a page displaying the rest of its form entry (ie. name, email, message). The links page: $result = mysql_query("SELECT col_4 FROM {$table} ORDER BY submission_date DESC"); if (!$result) { die("Query to show fields from table failed:".mysql_error()); } while($row = mysql_fetch_array($result)) { echo '<a href="ResumeDisplay.php?id='.$row['id'].'">'.$row['col_4'].'</a>'; echo "<br />"; } mysql_free_result($result); ?> and the display page: $id = (int) $_GET['submission_id']; $sql = "SELECT * FROM {$table} WHERE submission_id=$id, "; $result = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($result) == 1){ $row = mysql_fetch_assoc($sql); //print out information }else{ echo 'That record ID does not exist!'; } ?> the problem is with the code on the display page. I get the error message: 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 I cant figure out where the problem is. ??? any ideas? Link to comment https://forums.phpfreaks.com/topic/100856-mysql-select-problem/ Share on other sites More sharing options...
AndyB Posted April 13, 2008 Share Posted April 13, 2008 Chaange $sql = "SELECT * FROM {$table} WHERE submission_id=$id, "; $result = mysql_query($sql) or die(mysql_error()); To this. It should work AND be more informative if errors arise. $sql = "SELECT * FROM $table WHERE submission_id='$id'"; $result = mysql_query($sql) or die("Error ". mysql_error(). " with query ". $sql); Link to comment https://forums.phpfreaks.com/topic/100856-mysql-select-problem/#findComment-515790 Share on other sites More sharing options...
Lambneck Posted April 13, 2008 Author Share Posted April 13, 2008 Hi sorry about the double post. i wasn't sure where this question belonged. so now i'm getting the message. "That record ID does not exist!" my table looks like this: submission_id col_2 col_3 col_4 col_5 submission_date ip_address Im trying to display col_2, col_3, col_4, col_5, and submission_date in the display page based upon the corresponding submission ID of the link originally clicked on in the links page. not sure if im explaining this clearly enough, but if anyone has an idea of what i'm talking about I'd appreciate any help at all. Thanks. Link to comment https://forums.phpfreaks.com/topic/100856-mysql-select-problem/#findComment-515796 Share on other sites More sharing options...
Lambneck Posted April 15, 2008 Author Share Posted April 15, 2008 anyone..? any idea what i'm talking about? Link to comment https://forums.phpfreaks.com/topic/100856-mysql-select-problem/#findComment-517276 Share on other sites More sharing options...
soycharliente Posted April 15, 2008 Share Posted April 15, 2008 It sounds like your problem is that it's not returning any results. Either your query is wrong or your searching for data that doesn't exist. Link to comment https://forums.phpfreaks.com/topic/100856-mysql-select-problem/#findComment-517282 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.