Jump to content

Recommended Posts

Fairly new to html, php etc. I can create rudimentary forms but now I'm trying to add multiple records at a time.

 

How do I make the following a variable?
 
I'd like to have this as my insert...
 
$sql = "INSERT INTO  `somedb` (  `ffid` ,  `email` ,  `sku`) VALUES (  $somenewvariable  )";
 
Where $somenewvariable equals this;
 
' ', 'email1@gmail.com', '408'),
(' ', 'email2@example.com', '400'),
(' ', '
email3@example.com', '412'
 
 I'm missing something very basic, ie back slashes! The variable is turning into something like this;
 
\'\', \'email1@gmail.com\', \'408\'), (\'\', \'email2@gmail.com\', \'400\'
Edited by asevie
Link to comment
https://forums.phpfreaks.com/topic/276050-phpmysql-insert-for-multiple-records/
Share on other sites

you must be escaping the actual query statement insted of just the data going into the query statement. the syntax of the query, quotes and such that you add around the data to produce the query, don't get escaped.

 

 

Thanks for the tip.

Edited by asevie
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.