php and mysql problem
Posted: Mon Dec 18, 2006 6:06 pm
feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
hi,
why does the code below return " array: , , , , , , , , , , , , , , , , , , , " ?
the num_rows returned is 1 and i'm only querying 10 columns so the maximum number of values in the array should be no more than this.
when i try to remove the empty values using the loop, it makes no difference either.
what am i doing wrong and why are there so many values in the $row array?Code: Select all
/***********get db record for the current current pub crawl ***************/
db_connect();
$sql = mysql_query("SELECT e1,e2,e3,e4,e5,e6,e7,e8,e9,e10 from Pub_Crawl_Order
WHERE crawlID = $crawl_id")
or die ('query1 invalid on table_data.php: ' . mysql_error() );
$row = mysql_fetch_array($sql); //creat array of the record
/*****remove empty values from array********/
foreach ($row as &$val) {
if ($val == 'NULL' || '') {
unset($val);
}
}
$a = implode(", ", $row ); //test code
print 'array values: ' . $a;feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]