[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Weird MySQL Results

Posted on 2011-02-11
6
Medium Priority
?
351 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 143

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 2000 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
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
The viewer will learn how to dynamically set the form action using jQuery.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

656 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