Mr Chris Posted May 4, 2006 Share Posted May 4, 2006 Hi Guys,Trying to write a script that will GET unique rows (story_id’s) from a MYSQL database and post them back on the below page where I can UPDATE them, but it just seems to do nothing and I get an error on this line:Parse error: parse error, unexpected '{', expecting '(' in /home/sleaz/public_html/greenock/news/edit.php on line 14[b] $result = mysql_query("Update table set section='$section', added_by='$added_by', headline='$headline', byline_name='$byline_name', appeared='$appeared', opening='$opening', body_text='$body_text', picture='$picture', pic_caption='$pic_caption', pic_ref='$pic_ref', notes='$notes' where story_id=".$_GET['story_id']); [/b]Can someone please explain where I have gone wrong in how I achieve the above?Thanks[code]<?php// Set the variables for access;include("**************");// Update Queryif{ $result = mysql_query("Update cms_stories set section='$section', added_by='$added_by', headline='$headline', byline_name='$byline_name', appeared='$appeared', opening='$opening', body_text='$body_text', picture='$picture', pic_caption='$pic_caption', pic_ref='$pic_ref', notes='$notes' where story_id=".$_GET['story_id']); $msg = "The Story record has been updated in the database - Please Click <a href=\"menu.php\">Here</a> to return to the main menu";}// Get Story ID From Databaseif(isset($_GET['story_id'])){$result = mysql_db_query("Select * From table where story_id=".$_GET['story_id'],$Link);$row = mysql_fetch_array($result, MYSQL_BOTH);$section = $row['section'];$added_by = $row['added_by'];$headline = $row['headline'];$byline_name = $row['byline_name'];$appeared = $row['appeared'];$opening = $row['opening'];$body_text = $row['body_text'];$picture = $row['picture'];$pic_caption = $row['pic_caption'];$pic_ref = $row['pic_ref'];$notes = $row['notes'];} } // Run Query $link = mysql_connect; mysql_select_db($db); $result = mysql_query($query) or die('Query failed: ' . mysql_error()); mysql_close(); } ?><html><head><title>Website Admin</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css"> BODY,H1,H2,H3,H4,H5,UL,LI,INPUT,A,B,TEXTAREA { font-family: Geneva, Helvetica, Arial, sans-serif } P { font-family: Geneva, Helvetica, Arial, sans-serif; } A { color: #1c1c1c } A:visited { color: #1c1c1c } A:hover { text-decoration: none; color: #ffffff; background-color: #3333cc } </style></head><body bgcolor="#CCCCCC"><table width="95%" border="0" align="center" bgcolor="#FFFFFF"> <tr> <td> </td> </tr> <tr bgcolor="#CC0000"> <td height="24"> <div align="center"><b><font color="#FFFFFF">ADD A STORY</font></b></div> </td> </tr> <tr> <td> <table width="70%" border="0" align="center"> <tr> <td><?php echo $msg?></td> </tr> </table> <br> <form action="" method="post" enctype="multipart/form-data" name="uploadform"> <table width="70%" border="0" align="center" bgcolor="#000000"> <tr> <td height="442"> <table width="100%" border="0" bgcolor="#FFFFFF" cellpadding="3" cellspacing="1"> <tr> <td width="26%" bgcolor="#CCCCCC" height="24"><b>Edition:</b></td> <td width="74%" height="24"><b><font color="#CC0000">Website.</font></b></td> </tr> <tr> <td width="26%" bgcolor="#CCCCCC"><b>Section:</b></td> <td width="74%"> <select name="section"> <option><?php echo $section?></option> <option value="news">News</option> <option value="sport">Sport</option> <option value="business">Business</option> <option value="viator">Viator</option> </select> </td> </tr> <tr> <td width="26%" bgcolor="#CCCCCC"><b>Added by:</b></td> <td width="74%"> <input name="added_by" type="text" id="added_by" value="<?php echo $added_by?>" size="50"> </td> </tr> <tr> <td width="26%" bgcolor="#CCCCCC"><b>Headline:</b></td> <td width="74%"> <input name="headline" type="text" id="headline" value="<?php echo $headline?>" size="50"> </td> </tr> <tr> <td width="26%" bgcolor="#CCCCCC"><b>Byline Name:</b></td> <td width="74%"> <input name="byline_name" type="text" id="byline_name" value="<?php echo $byline_name?>" size="35" maxlength="128"> </td> </tr> <tr> <td width="26%" bgcolor="#CCCCCC"> <p><b>Appeared in G Telegraph:</b></p> </td> <td width="74%"> <input name="appeared" type="text" id="appeared" value="<?php echo $appeared?>" size="30"> </td> </tr> <tr bgcolor="#CC0000"> <td colspan="2"> <div align="center"><b><font color="#FFFFFF">OPENING PARAGRAPH</font></b></div> </td> </tr> <tr> <td colspan="2"> <div align="center"> <textarea name="opening" id="opening" cols="80" rows="7"><?php echo $opening?></textarea> </div> </td> </tr> <tr bgcolor="#CC0000"> <td colspan="2"> <div align="center"><b><font color="#FFFFFF">BODY TEXT</font></b></div> </td> </tr> <tr> <td colspan="2"> <div align="center"> <textarea name="body_text" id="body_text" cols="80" rows="25"><?php echo $body_text?></textarea> </div> </td> </tr> <tr bgcolor="#CC0000"> <td colspan="2"> <div align="center"><b><font color="#FFFFFF">PICTURE (IF REQUIRED)</font></b></div> </td> </tr> <tr> <td width="26%" bgcolor="#CCCCCC"><b>Pic to Upload:</b></td> <td width="74%"> </td> </tr> <tr> <td width="26%" bgcolor="#CCCCCC" valign="top"><b>Caption:</b></td> <td width="74%"> <textarea name="pic_caption" id="pic_caption" cols="40"><?php echo $pic_caption?></textarea> </td> </tr> <tr> <td width="26%" bgcolor="#CCCCCC"><b>Pic Ref No:</b></td> <td width="74%"> <input name="pic_ref" type="text" id="pic_ref" value="<?php echo $pic_ref?>" size="30"> <br> </td> </tr> <tr bgcolor="#CC0000"> <td colspan="2"> <div align="center"><b><font color="#FFFFFF">ADDITIONAL NOTES (NOT PUBLISHED)</font></b></div> </td> </tr> <tr> <td width="26%" bgcolor="#CCCCCC" valign="top"><b>Notes:</b></td> <td width="74%"> <textarea name="notes" id="notes" rows="4" cols="65"><?php echo $notes?></textarea> </td> </tr> <tr> <td width="26%"> </td> <td width="74%"> <input name="upload" type="submit" class="box" id="upload" value=" Upload "> <input type="reset" name="Reset" value="Clear Story"> </td> </tr> </table> </td> </tr> </table> </form> </td> </tr></table></body></html>[/code] Link to comment https://forums.phpfreaks.com/topic/9042-getting-and-updating-data/ Share on other sites More sharing options...
onepixel Posted May 4, 2006 Share Posted May 4, 2006 Your first "if" condition if not specified; Link to comment https://forums.phpfreaks.com/topic/9042-getting-and-updating-data/#findComment-33232 Share on other sites More sharing options...
Mr Chris Posted May 4, 2006 Author Share Posted May 4, 2006 Whoops:First IF should be:[code]if(!isset($_GET['story_id']){ $result = mysql_query("Update news set section='$section', added_by='$added_by', headline='$headline', byline_name='$byline_name', appeared='$appeared', opening='$opening', body_text='$body_text', picture='$picture', pic_caption='$pic_caption', pic_ref='$pic_ref', notes='$notes' where story_id=".$_GET['story_id']); $msg = "The Story record has been updated in the database - Please Click <a href=\"menu.php\">Here</a> to return to the main menu";}[/code]But still the same error - any further ideas please? Link to comment https://forums.phpfreaks.com/topic/9042-getting-and-updating-data/#findComment-33238 Share on other sites More sharing options...
ansarka Posted May 4, 2006 Share Posted May 4, 2006 [b] Plz try this by removing the single quote in the getwhere story_id=".$_GET[story_id]);and you hv put an extra "}" in line number 31 plz check taht alsoand try to connect mysql before sending any sql queries[/b] Link to comment https://forums.phpfreaks.com/topic/9042-getting-and-updating-data/#findComment-33243 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.