Jump to content

Recommended Posts

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)

Link to comment
https://forums.phpfreaks.com/topic/181614-solved-what-wrong-with-this-insert/
Share on other sites

@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.

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.