Solved

Weird MySQL Results

Posted on 2011-02-11
6
343 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now