Renlok Posted February 23, 2011 Share Posted February 23, 2011 in my code i have $query = "DELETE " . $DBPrefix . "bids WHERE auction = " . $Auction['id']; $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__); but if WHERE auction = " . $Auction['id'] doesnt match anything i returns the 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 auction = 8' at line 1 I really dont understand why its returning an error is this just a case of having to add some code to check if theres anything that actualy needs deleting first? Quote Link to comment https://forums.phpfreaks.com/topic/228601-error-when-trying-to-delete-0-rows/ Share on other sites More sharing options...
Pikachu2000 Posted February 23, 2011 Share Posted February 23, 2011 That error isn't caused by not finding a matching record. A DELETE query that simply matches no records will execute but mysql_affected_rows will show 0. It's more likely that $Auction['id'] has no value. Have you echoed the query string to see what the actual problem might be? Quote Link to comment https://forums.phpfreaks.com/topic/228601-error-when-trying-to-delete-0-rows/#findComment-1178651 Share on other sites More sharing options...
Renlok Posted February 23, 2011 Author Share Posted February 23, 2011 yeah it does have a value ive tried that and its not the problem. Quote Link to comment https://forums.phpfreaks.com/topic/228601-error-when-trying-to-delete-0-rows/#findComment-1178667 Share on other sites More sharing options...
Pikachu2000 Posted February 23, 2011 Share Posted February 23, 2011 And what does the query string echo when that happens, then? That's where the problem has to be. Quote Link to comment https://forums.phpfreaks.com/topic/228601-error-when-trying-to-delete-0-rows/#findComment-1178669 Share on other sites More sharing options...
Muddy_Funster Posted February 23, 2011 Share Posted February 23, 2011 Does this ever work? and could you echo out an example of $DBprefix and let us see that's in there? Quote Link to comment https://forums.phpfreaks.com/topic/228601-error-when-trying-to-delete-0-rows/#findComment-1178673 Share on other sites More sharing options...
Renlok Posted February 23, 2011 Author Share Posted February 23, 2011 oh nevermind i just forgot the FROM *facepalm* but thanks anyway Quote Link to comment https://forums.phpfreaks.com/topic/228601-error-when-trying-to-delete-0-rows/#findComment-1178679 Share on other sites More sharing options...
Pikachu2000 Posted February 23, 2011 Share Posted February 23, 2011 D'oh! Quote Link to comment https://forums.phpfreaks.com/topic/228601-error-when-trying-to-delete-0-rows/#findComment-1178683 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.