mysql - Insert php array into RDS -


so, have php script writes rds instance. however, 1 variable trying insert array value giving me trouble. here code. advice appreciated.

<?php session_start(); $name=mysql_real_escape_string($_session['username']);  include 'mysql_connect.php';  // select database use mysql_select_db("database",$con);  // describe now-running instance public url $result = $ec2client->describeinstances(array(     'instanceids' => $instanceids, ));   $server_record = mysql_query("insert server_tbl (username, servername, serverid, isrunning) values ('$name', 'runtest', '$instanceids', 'x'");  print_r($instanceids);  ?> 

there many methods, depend on choice.

1.

$instanceidsstr = serialize($instanceids);//to save in db $instanceids    = unserialize($instanceidsstr);//to extract 

2.

$instanceidsstr =json_encode($instanceids);//to save in db $instanceids    =  json_decode($instanceidsstr);//to extract 

3.

$instanceidsstr = implode("|mydeli|",$instanceids);//to save in db $instanceids    = explode("|mydeli|",$instanceidsstr);//to extract 

another option can save xml.

example:

$test=array('username'=>$username,'field2'=>'value2'); $instanceidsstr =json_encode($test);//this keep info in string 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -