Solved

Weird MySQL Results

Posted on 2011-02-11
6
346 Views
Last Modified: 2012-06-27
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
Comment
Question by:Gaute Rønningen
  • 4
6 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 34870692
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
 
LVL 12

Accepted Solution

by:
enachemc earned 500 total points
ID: 34870703
maybe you should use ' instead of "
0
 

Author Comment

by:Gaute Rønningen
ID: 34870746
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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Closing Comment

by:Gaute Rønningen
ID: 34870771
Replaced " with \' in the code and it worked, thanks.
0
 

Author Comment

by:Gaute Rønningen
ID: 34870822
Actually it didn't work, I just thought it worked cause I got no error messages...
0
 

Author Comment

by:Gaute Rønningen
ID: 34870864
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question