Problem with inserting variable data into database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shantothegreat
Forum Newbie
Posts: 4
Joined: Wed Oct 19, 2011 10:53 am

Problem with inserting variable data into database

Post by shantothegreat »

I separate some data from a page with preg_match_all function. and store the data into $out variable. when I print the data it is ok but when i try to insert the data in the mysql database using

Code: Select all

mysql_query("INSERT INTO livedata (name, ltp, chng) VALUES ('$out[0][1]','$out[0][2]','$out[0][3]')")
it creates following data in the database

Code: Select all

Array[1] 0 0
That is not correct. The name is text type and ltp and chng is float type. Can anyone plz tell me where is the problem?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Problem with inserting variable data into database

Post by Celauran »

Code: Select all

mysql_query("INSERT INTO livedata (name, ltp, chng) VALUES ('{$out[0][1]}',{$out[0][2]},{$out[0][3]})");
Post Reply