how-to replace hard coded array with data from mysql?
Posted: Sun Feb 17, 2008 7:38 pm
Hi everyone,
I have a problem that I can't sort out.
I'm trying to replace a hard coded piece of code with dynamic data.
I have;
$data=array(
"PETER" => "Peter is nice",
"JANE" => "Jane is nice too"
);
I want to change this piece of the script so I can store these names in mysql but have no success doing so. I tried to replace the above with this but it's not working;
mysql_select_db($database_xyz, $xyz);
$query_person = "SELECT name,description";
$rs_person = mysql_query($query_person, $xyz) or die(mysql_error());
$data = mysql_fetch_object($rs_person);
So $data should hold the exact same set of data but the script does not work.
Anyone who can see what is wrong and be kind enough to tell me? Really appreciate it.
I have a problem that I can't sort out.
I'm trying to replace a hard coded piece of code with dynamic data.
I have;
$data=array(
"PETER" => "Peter is nice",
"JANE" => "Jane is nice too"
);
I want to change this piece of the script so I can store these names in mysql but have no success doing so. I tried to replace the above with this but it's not working;
mysql_select_db($database_xyz, $xyz);
$query_person = "SELECT name,description";
$rs_person = mysql_query($query_person, $xyz) or die(mysql_error());
$data = mysql_fetch_object($rs_person);
So $data should hold the exact same set of data but the script does not work.
Anyone who can see what is wrong and be kind enough to tell me? Really appreciate it.