0

I just cannot get this solved and after way too much time on this, I'm here for help.

Here's my code snippet:

while ($row = mysql_fetch_assoc($result)) {
    $domain = $row["domain"];
    $domainwww = "www.".$domain;
    //$domainwww = "www.google.com";
     $sql2 = "SELECT url_id, url 
	     FROM urls
             WHERE url='".$domainwww."'";

My problem is that my query $sql2 returns no rows when I have $domainwww set to:
$domainwww = "www.".$domain;
[when I echo $domainwww is prints just fine]

However if I comment that out to hard code the value of $domainwww like:
$domainwww = "www.google.com";

The query works just fine. What am I missing?

thank you. Jeff

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by tireytv
0

hm, maybe in "www.".$domain you have space or other symbols. give me all code, maybe i am help you.

0

Thank you both for your help and time. Your comments helped me to see that i have a single character of trailing whitespace in the query which I couldn't immediately see when echoing $domainwww (why did I not check it in source code view!) The output from the query looks like

SELECT url_id, url FROM urls WHERE url='www.0-0.com '

where you can see there's a space at the end. I don't know if this space is coming from the database record, from the concatentation of the string to the variable, or the sql query but I should be able to figure out the culprit.

thank you again - jeff

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.