slaterino Posted July 11, 2008 Share Posted July 11, 2008 Hi, I have built a simple PHP CMS system based on a tutorial but am having some serious problems with it. The tutorial I used was for adding 2 fields to a database item and worked fine. However, I have amended the files so they now are capable of amending 3 fields (there will be more fields evenutally but thought I should start off with just one extra). This works fine in the add field to database section but in the edit fields section keeps throwing up this line after I press the update button: 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 'WHERE id = '5'' at line 1 This is the url of the page this happens on is : http://www.thedaffodilsociety.com/cms-edit.php The script used on this page is: <?php include 'library/config.php'; include 'library/opendb.php'; if(isset($_GET['id'])) { $query = "SELECT id, name, description, add1 ". "FROM suppliers_uk ". "WHERE id = '{$_GET['id']}'"; $result = mysql_query($query) or die('Error : ' . mysql_error()); list($id, $name, $description, $add1) = mysql_fetch_array($result, MYSQL_NUM); $description = htmlspecialchars($description); } else if(isset($_POST['name'])) { $id = $_POST['id']; $name = $_POST['name']; $description = $_POST['description']; $add1 = $_POST['add1']; if(!get_magic_quotes_gpc()) { $name = addslashes($name); $description = addslashes($description); $add1 = addslashes($add1); } // update the article in the database $query = "UPDATE suppliers_uk ". "SET name = '$name', description = '$description', add1 = '$add1', ". "WHERE id = '$id'"; mysql_query($query) or die('Error : ' . mysql_error()); // then remove the cached file $cacheDir = dirname(__FILE__) . '/cache/'; $cacheFile = $cacheDir . '_' . $_GET['id'] . '.html'; @unlink($cacheFile); // and remove the index.html too because the file list // is changed @unlink($cacheDir . 'index.html'); echo "<p align='center'>Supplier updated</p>"; // now we will display $name & description // so strip out any slashes $name = stripslashes($name); $description = stripslashes($description); $add1 = stripslashes($add1); } include 'library/closedb.php'; ?> <form method="post" action="cms-edit.php"> <input type="hidden" name="id" value="<?=$id;?>"> <table width="700" border="0" cellpadding="2" cellspacing="1" class="box" align="center"> <tr> <td width="100">name</td> <td><input name="name" type="text" class="box" id="name" value="<?=$name;?>"></td> </tr> <tr> <td width="100">description</td> <td><textarea name="description" cols="50" rows="10" class="box" id="description"><?=$description;?></textarea></td> </tr> <tr> <td width="100">add1</td> <td><textarea name="add1" cols="50" rows="10" class="box" id="add1"><?=$add1;?></textarea></td> </tr> <tr> <td width="100"> </td> <td> </td> </tr> <tr> <td colspan="2" align="center"><input name="update" type="submit" class="box" id="update" value="Update Article"></td> </tr> </table> <p align="center"><a href="cms-admin.php">Back to admin page</a></p> </form> When I changed from editing 2 fields to 3 fields I literally added an extra option for the $add1 field wherever I saw the other two fields. Can anyone please help me with this problem and let me know why this error is occurring. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/114258-problem-with-php-cms-system/ Share on other sites More sharing options...
Lamez Posted July 11, 2008 Share Posted July 11, 2008 please put your code in the code tags, and it is very unsafe to link to your admin page. I suggest you use a pre built login system to help secure your website. Here use this one: http://www.evolt.org/PHP-Login-System-with-Admin-Features Quote Link to comment https://forums.phpfreaks.com/topic/114258-problem-with-php-cms-system/#findComment-587498 Share on other sites More sharing options...
slaterino Posted July 11, 2008 Author Share Posted July 11, 2008 Hey, Is it possible to make those amends to my topic now? I can't seem to see any options for amending these things. Also, what are the code tags? Sorry about these things, it's my first post! Cheers Quote Link to comment https://forums.phpfreaks.com/topic/114258-problem-with-php-cms-system/#findComment-587527 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.