Jump to content

Recommended Posts

Good Day all..

 

I am querying entrants from on table and placing them in another table. When I query the entrants, store them in an array and echo them, I can see that the tables are being accessed and the values are being read.

 

However when i query to put the values into the other, if I put in the entrants with numbers only ( float type or integer type), the following statement works but it doesnt work for the entrants that are of type VARCHAR

 

Here is the statement I use.

 

it works for this

 

 

$query = mysql_query("INSERT INTO store_data (network_ID, store_num) VALUES ($network_ID, $store_num)");

 

 

Doesnt work for this

 

 

 

$query = mysql_query("INSERT INTO store_data (network_ID, store_name, store_num, store_type) VALUES ($network_ID, $store_name, $store_num, $store_type)");

 

 

$network_ID is an 'int'

$store_name is a 'VARCHAR(255)

$store_num is an 'int'

$store_type is a 'VARCHAR(255)

 

can anybody tell me what wrong?

Link to comment
https://forums.phpfreaks.com/topic/272929-sql-insert-statement/
Share on other sites

There is no need to

 

SELECT data

Store in an array

foreach array item

INSERT into a table from array.

 

You can do it with a single query instead of multiple queries in a loop (which is bad practice).

 

INSERT INTO table2 SELECT whatever FROM table1

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.