dub_beat Posted November 15, 2009 Share Posted November 15, 2009 Hi, I'm trying to make multiple inserts into a table with selections from a dropdown box. I don't understand why it is not working. Im not getting any errors in my code and I'm not getting an or die print out either. Could somebody please help me solve this problem? $query2 = 'INSERT INTO video_cat_ass (cat_id,sub_cat_id,vid_id) VALUES '; $subcount = count($_POST['subcat']); echo 'count is:'.$subcount; foreach ($_POST['subcat'] as $v) { $query2 .= "($_GET[cat], $v, $upload_id), "; } $query2 = substr ($query2, 0, -2); // Chop off the last comma and space. echo "q".$query2; $result2 = @mysql_query2 ($query2) or die('Could not connect to MySQL: ' . mysql_error() ); // Run the query. I've printed out the complete query and it seems ok INSERT INTO video_cat_ass (cat_id,sub_cat_id,vid_id) VALUES (18, 27, 48), (18, 26, 48), (18, 29, 48), (18, 28, 48) Quote Link to comment https://forums.phpfreaks.com/topic/181614-solved-what-wrong-with-this-insert/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 15, 2009 Share Posted November 15, 2009 @mysql_query2 ($query2) What is your code for a user written function named mysql_query2? That that is supposed to be the built-in function mysql_query(), then please DON'T ever put @ in your code to suppress error messages. You should have display_errors turned ON for development and turned OFF for a live server, so there is absolutely no reason to put @ in any code to suppress error messages. Quote Link to comment https://forums.phpfreaks.com/topic/181614-solved-what-wrong-with-this-insert/#findComment-957950 Share on other sites More sharing options...
dub_beat Posted November 15, 2009 Author Share Posted November 15, 2009 well that solved the problem thanks. I didnt know that @ supresses code errors. Whats the potential consequence of doing this? How can I check if I have display_errors turned on? Quote Link to comment https://forums.phpfreaks.com/topic/181614-solved-what-wrong-with-this-insert/#findComment-957970 Share on other sites More sharing options...
mrMarcus Posted November 15, 2009 Share Posted November 15, 2009 I didnt know that @ supresses code errors. Whats the potential consequence of doing this?you don't see the error messages. How can I check if I have display_errors turned on?if you have access to your php.ini, you can check for: display_error = On/Off, in there. or you can add: ini_set ('display_errors',1); to the top of your scripts. Quote Link to comment https://forums.phpfreaks.com/topic/181614-solved-what-wrong-with-this-insert/#findComment-957973 Share on other sites More sharing options...
PFMaBiSmAd Posted November 15, 2009 Share Posted November 15, 2009 suppresses code errors. It suppresses the error message. The code still has an error, but with the @ the error message is not produced and your code still does not work. With full php error_reporting/display_errors turned on you would have gotten a fatal runtime undefined function error message that would have alerted you to where and what the problem was. Quote Link to comment https://forums.phpfreaks.com/topic/181614-solved-what-wrong-with-this-insert/#findComment-957990 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.