Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Problem adding arrays into a databasic coulm

Codes here !

Moderators: macek, egami, gesf

Problem adding arrays into a databasic coulm

Postby madcitysw » Wed Jan 15, 2003 9:32 am

Hello, I would like to add arrays into a databasic colum, like

$test = array("test", "EHEH", "Dad");

mysql_query("INSERT INTO Score_$halo_nickname (score_data) VALUES ($test)");

But this don't work right, it displays Array in the database and not the array data. Can any one help me?
madcitysw
New php-forum User
New php-forum User
 
Posts: 4
Joined: Wed Jan 15, 2003 9:20 am

Postby jemy » Thu Jan 16, 2003 8:49 am

$test = array("test", "EHEH", "Dad");

mysql_query("INSERT INTO Score_$halo_nickname (score_data) VALUES ($test)");


Hi,

1) if "Score_$halo_nickname" should be a table name you build with the variable $halo, you should procede the following way:
$table = "Score_".$halo."_nickname";
and then: insert into $table ... whatever...

2) do you like to have 3 rows, like:
1. row ---> score_data = "test"
2. row ---> score_data = "EHEH"
3. row ---> score_data = "Dad"
do it like that:
foreach ($test as $value) {
$query = "insert .... values($value)";
$res = mysql_query(......);
}

3) if you wish only 1 row, like:
1. row ---> score_data = array("test", "EHEH", "Dad")
it's not working.
create 3 fields: score_data1 - score_data2 - score_data3
in which you put your score datas separated.
jemy
New php-forum User
New php-forum User
 
Posts: 6
Joined: Thu Jan 02, 2003 5:27 am
Location: Munich / Germany


Return to mySQL & php coding

Who is online

Users browsing this forum: No registered users and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.