vlowe Posted November 19, 2006 Share Posted November 19, 2006 Hello,I am using PHP5, MySQL5 and APACHE2i an trying to delete a row from a table useing the following syntax.$query = "DELETE FROM cru_name WHERE id = $name_id";$result = mysql_query($query) or die("Error number:" . mysql_errno() . ""); if($result){ echo "Name deleted from the database!";} else { $message = "Failed to delete! This is the MySQL Error output:<br>" + mysql_error();}For this i get an 1064 (Syntax) error, but i can not find the problem. i have used the same code on another server running apache and php4 (a hosting company) and still get the same error.Permissions are fine and still get error as root.If i type the mysql query into a mysql command line on my server it works, but via php i get the error?? ??? ???Any help would be fantastic ;) Link to comment https://forums.phpfreaks.com/topic/27759-mysql-delete-problems/ Share on other sites More sharing options...
ronverdonk Posted November 19, 2006 Share Posted November 19, 2006 Could $name_id contain a blank inbetween, like you are deleting on a numeric table field but the $name_id is CHAR and contains e.g. '1 2'? That gives you a 1064 error.Ronald 8) Link to comment https://forums.phpfreaks.com/topic/27759-mysql-delete-problems/#findComment-127014 Share on other sites More sharing options...
vlowe Posted November 19, 2006 Author Share Posted November 19, 2006 no i can see the id is correct in the url$query = "DELETE FROM cru_name WHERE id = 10";gives the same error ??? ???tried$query = "DELETE FROM cru_name WHERE id = '10'";also but same.can someone post a definate working delete query with the 'mysql_query($query)' bits to execute it.i will try that and see what i get Link to comment https://forums.phpfreaks.com/topic/27759-mysql-delete-problems/#findComment-127023 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.