Jump to content

[SOLVED] Array problems!


ukweb

Recommended Posts

Hi peeps,

 

I'm making results from a query build an array, and I'm having problems with it but strangely, PHP is not outputting any notices, errors or warnings, it just returns a blank page. error reporting is on in my config, but I can;t see whats up with my code

 

Basically the results from a query are to be put into a multidimensional array, and like I say as far as I can see i have coded correctly, so cant see whats up!

 

Any ideas or suggestions are welcome!

 

heres the code:

// Function to Generate an array for the language list
function lang_list() {

global $database_sql, $sql;

mysql_select_db($database_sql, $sql);
$query_langs = "SELECT short_name AS name, long_name AS desc FROM languages";
$langs = mysql_query($query_langs, $sql) or die(mysql_error());
$row_langs = mysql_fetch_assoc($langs);
$totalRows_langs = mysql_num_rows($langs);

$languages = array();

if ($totalRows_langs == 0) {
	$languages = false;
} else {
	do {
		$languages[] = array("name" => $row_langs['name'], "description" => $row_langs['desc']);
	} while ($langs = mysql_fetch_assoc($langs));
}
return $languages;
}

 

THis bit is just to see if its working ok:

$lang_list = lang_list();
if (!($lang_list == false)) {
$rows = count($lang_list);
print_r $lang_list;
print "number of rows ".$rows;
}

Thanks again

Stephen

Link to comment
https://forums.phpfreaks.com/topic/127840-solved-array-problems/
Share on other sites

Already got it there, no luck  ??? I tried changing my php.ini too to show all errors with no luck! rubbish!!! Think error reporting is working ok too because its displaying notice for a variable without a value, and did show up a parse error when I was writing the function and forgot a '}'

 

bit confused.com on this one. the query works fine too, tried running the query outside a function and it did return the db values.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.