Again - since I don't see any error checking code, how do you know it ran?
When I run a query I always do:
In development I send them to the screen. Once in prod they go to my error logs
if ( !$results)
(show error messages)
PS - It might be a good idea to not re-use your variable that holds the query statement to store your result object in. That way when you have an error you can display the query that you ran to help debug.
Thanks for the reply!
I used the code you provided and it just says:
I was messing around with the sql query and found something odd. my query looks like this
Notice: Query returned 0 rows: SELECT * FROM `realtyimages` WHERE rname = 'Pacific Monarch Resorts' AND rcity = 'Las Vegas' AND rstate = 'NV'; in C:\xampp\htdocs\Auto Listing\database_class.php on line 32
I tried to only use one WHERE clause like
$query = "SELECT * FROM `realtyimages` WHERE rname = '$rname' AND rcity = '$rcity' AND rstate = '$rstate' ";
$query = "SELECT * FROM `realtyimages` WHERE rname = '$rname'";
$query = "SELECT * FROM `realtyimages` WHERE rcity = '$rcity'";
What i noticed is that rname has results, and rstate has results, but rcity is coming up with 0 rows. So i believe the problem is being caused my rcity. I am looking into it and will let you guys know.
$query = "SELECT * FROM `realtyimages` WHERE rstate = '$rstate' ";
So I currently still facing this problem. From all the testing I have figure out that the Query is not liking when i give fcity a variable value. I echoed the query out and it works fine in my MySQL Client.
What could cause this? It only is doing it to the fcity, not fname or fstate. Code works fine, rcity is defined and is correct, etc.
I started a topic on stackoverflow if anyone is interested in looking there.
Am I missing something? All along you have been referring to rcity rstate, etc. and today you post fcity and fstate.
Is there a column named rcity?
Oops, that was a spelling error when I typed that reply. In the code and db columns, the names are rname, rcity, rstate.
Originally Posted by ginerjm
I think i found the problem, I feel pretty dump I overlooked something so simple. my $rcity which had the value "Las Vegas", when I var_dumped it, it showed it as string(10). Which Las Vegas should only have 9 characters including the space. Some reason it was adding another space, which was returning 0 results in the database. But to get even more odd, when I echoed out $rcity (with the added space) it looked normal, can't highlight the extra space and even was able to cut and paste it into phpmyadmin/mysqli client and it worked fine. So for some reason PHP was adding an extra character only between Las and Vegas.
Thanks for all your help. Something so simple cause me all this problem. But hey I learned new ways to handle errors.
Remember that web browsers remove duplicate word spaces when they format most HTML elements (with specific exceptions such as <pre> elements), so you may need to actually do a "view source" on the page to see the actual output. Or when outputting debug info, use <pre> tags. In fact, I have a macro in my editor that creates the following bit of PHP code:
...which saves me a lot of time. (The macro actually takes whatever is in the clipboard and inserts it where "$data" is.)
echo "<pre>".var_dump($data, 1)."</pre>";
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)