Weird MySQL Results

Hi experts,

I'm trying to do a simple SELECT query on my database, yet something is not working as it should be. When I print the query and the array it returns it comes up blank PHP Output., but when I run the query directly on the database it comes up populated... Database Output. My DBHandler works on every other query so it's not that...

Help greatly appreciated,
Gaute RønningenOwner, DeveloperAsked:
Who is Participating?
enachemcConnect With a Mentor Commented:
maybe you should use ' instead of "
Guy Hengel [angelIII / a3]Billing EngineerCommented:
well, either you connect to another database, or have some uncommitted data ...

another detail is the double quotes you use... for numerical fields, you shall not need those double quotes at all ....
Gaute RønningenOwner, DeveloperAuthor Commented:
Including my DBHandler.
// Run a SQL-query and return a array of hashes //
function getHash( $sql ) {
	$i = 0;
	global $dbh,$debug_All;
	$result = array();
	$sth = mysql_query($sql, $dbh) or die (err_dump(array($sql,mysql_error($dbh))));
	while ($row = mysql_fetch_array($sth)) {
		array_push($result , $row);
	} // end while
	if ( $i ) {
		$result[0]['rows'] = $i;
	} // end if
	if($debug_All) err_dump(array($sql,$result));
	return $result;

Open in new window

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Gaute RønningenOwner, DeveloperAuthor Commented:
Replaced " with \' in the code and it worked, thanks.
Gaute RønningenOwner, DeveloperAuthor Commented:
Actually it didn't work, I just thought it worked cause I got no error messages...
Gaute RønningenOwner, DeveloperAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.