sudsy1970 Posted November 15, 2010 Share Posted November 15, 2010 Hi guys, Am having trouble with my OO php blog. i can add, delete and search for messages but cannot update them as i get the folowing eror message (see below) Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 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 'FROM messages WHERE id = NULL' at line 1' Have checked that when i hover over the link i do get an id number and it is pointing to the correct cmd i.e. blogAmend. Any ideas as to where i am going wrong, files attatched for further info. [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/218753-oo-php-blog-amend/ Share on other sites More sharing options...
Mchl Posted November 15, 2010 Share Posted November 15, 2010 There are two things wrong with this query. 1. Something is wrong before FROM messages ... - maybe a column missing, or an extra comma (,). 2. Should be WHERE id IS NULL Link to comment https://forums.phpfreaks.com/topic/218753-oo-php-blog-amend/#findComment-1134577 Share on other sites More sharing options...
sudsy1970 Posted November 15, 2010 Author Share Posted November 15, 2010 ok i can't see it it but here is what i am thinking should happen: the id of the selected blog gets sent to the function amendMessage, it puts it in an array called $values then calls the SQL statement below to find the entry in the db, which is returned to populate the form and should be displayed on the screen. Is that right ? static $amend_message = "SELECT * FROM messages WHERE id = ?";[code=php:0] function amendMessage($id) { $values = array($id); $stmt = $this->doStatement(self::$amend_message, $values); } [/code] function doExecute(Request $request) { $search = $request->getProperty('search'); // Create manager object $manager = new ManagerMessage(); $data = $manager->amendMessage($search); // Include view include("views/add_form.php"); Link to comment https://forums.phpfreaks.com/topic/218753-oo-php-blog-amend/#findComment-1134584 Share on other sites More sharing options...
ajcarr1989 Posted November 24, 2010 Share Posted November 24, 2010 I'm guessing your from Wolves Uni? Coz im doing the same thing and im stuck. Its working as such, but instead of amending the blog its just posting a new one which is strange. Did you get that working? Very confused! I've got similar code as you too, so youve probably had the same problem If you could help i'd be really thankful! I've been racking my brains at it for weeks now! Link to comment https://forums.phpfreaks.com/topic/218753-oo-php-blog-amend/#findComment-1138901 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.