Avatar of breeze351
breeze351
 asked on

Php unexplained results form mysql query

I'm doing a query with php.  The data doesn't exist in the table but mysql_num_rows is returning a count of "1".  Here's the code in question:

// Build Sql query & execute
$Work = str_replace(" ","",$Street);
$SqlString1 = "SELECT * FROM saka WHERE HUH LIKE '$Work%'";
echo "$SqlString1 <br>";
$Saka_File = mysql_query($SqlString1);
$count = mysql_num_rows($Saka_File);

// If no street name
echo "count = $count <br>";

The query is correct.  I'm not sure what this could be.

Also, I'm not sure if this is the correct forum.   I have a login page which displays correctly in Firefox but not in IE.  If you would like to take a look it's "mrbreeze.net".

Thanks
Glenn
PHP

Avatar of undefined
Last Comment
EMB01

8/22/2022 - Mon
EMB01

I wouldn't use mysql_num_rows, I would use this:

if ($aka_File = mysql_query($SqlString1))

Ref.  http://stackoverflow.com/questions/3772791/mysql-num-rows-always-returns-1
Dave Baldwin

Try putting a value in place of $Work in the SQL statement and see what happens.  I'm wondering if you ending up with a blank string that matches something in the database.

Your page looks the same in both IE8 and Firefox12.  But you haven't fixed the errors that were there the last time you posted.  So I fixed them for you.  I put the <form> tag where it belongs and fixed the image link.  And in the CSS I changed 'hissen' to 'hidden' like it should be.  You may find that those three fix your display problem.
mrbreeze.net.htm
lansco.css
breeze351

ASKER
I need to know the number of rows.  So you're solution doesn't work for me.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER CERTIFIED SOLUTION
EMB01

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
breeze351

ASKER
To EMB01:
I tried the code you suggested at the end of your message.  This is what I got!!:

SELECT * FROM saka WHERE HUH LIKE 'FRED%'
count = 1
result = FREDERICKDOUGLASSB

The table name saka stands for "Street Also Know As".   I can assure you that in Manhattan there is no "FREDERICKDOUGLAS..." in this table.   I have no idea where this data is coming from.  

To Ray:
Thanks for the lead.  My experience was using php with ODBC.  I have several sites using ODBC that are very similar to what I'm trying to do now.  How hard could be this be?  I already have the logic!  

Glenn
Saka-from-query-from-hosting24
EMB01

The computer isn't just making up "FREDERICKDOUGLASSB" so it must be coming from somewhere.  There simply must be an entry in your database called "FREDERICKDOUGLASSB."  Have you checked?  Thanks.
breeze351

ASKER
Yes I did. Look at the attached print screen.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
EMB01

For some reason I can't open your file (Saka-from-query-from-hosting24).
breeze351

ASKER
See if this works better.
saka-query.doc
EMB01

You should just attach a .GIF.  But, that worked.  So, from the image, "FREDERICKDOUGLASSB" was being returned from the query because it's in the database!  So, your query accurately returns one result (the correct result).  Let me know if I am misunderstanding you.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Ray Paseur

Using phpMyAdmin you can run any query you want in a "test mode" and see the results immediately.  It helps remove mysteries like this one!
breeze351

ASKER
No you have it right.  

I'm going to kill my partner on this deal.  He updates the data from the client and doesn't tell me (so you can tell the client's data sucks, as I said before there is no "Fred.." street in Manhattan).  I ran this query on Monday and there were no results.  I didn't even look at the new query because I assumed the data was the same.

I'm sorry for wasting your time.

Thanks
Glenn
breeze351

ASKER
I've requested that this question be closed as follows:

Accepted answer: 0 points for breeze351's comment #38003642

for the following reason:

My bad, didn't know someone else updated the data.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
EMB01

I recommend choosing a solution since, technically, the solution was reached.  Glad you found out what the problem was, after all.  Thanks.
Ray Paseur

@EMB01:
I recommend choosing a solution...
Yep!  Couldn't agree more.

And I recommend getting a copy of phpMyAdmin, installing it, and learning to use it frequently to look at the data.  It would have saved hours, if not days, on this problem.  And since everything we do in information technology is all about transforming data from one kind to another, it's not an overstatement to say that data visualization is the single most important thing a software developer can do.
EMB01

3) Accept one or more Expert posts as the answer

ID#:  37994978
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck