• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 356
  • Last Modified:

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,
eX.
0
Gaute Rønningen
Asked:
Gaute Rønningen
  • 4
1 Solution
 
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 ....
0
 
enachemcCommented:
maybe you should use ' instead of "
0
 
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);
		$i++;
	} // end while
	if ( $i ) {
		$result[0]['rows'] = $i;
	} // end if
	if($debug_All) err_dump(array($sql,$result));
	return $result;
}

Open in new window

0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
Gaute RønningenOwner, DeveloperAuthor Commented:
Replaced " with \' in the code and it worked, thanks.
0
 
Gaute RønningenOwner, DeveloperAuthor Commented:
Actually it didn't work, I just thought it worked cause I got no error messages...
0
 
Gaute RønningenOwner, DeveloperAuthor Commented:
0
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.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now