Jump to content


Photo

[SOLVED] running mysql query yields a bunch of dots in the rendered HTML


  • Please log in to reply
3 replies to this topic

#1 valdepenas

valdepenas

    Newbie

  • New Members
  • Pip
  • 2 posts

Posted 28 October 2009 - 04:27 PM

Hi, I'm a total noob, and this makes no sense to me.

My query (using the PHP MySQL functions) does actually execute with no errors per se, but as it's executing, it seems each time through the loop is creating a dot that prints out to the page, before the search results are rendered. The more results a query has, it seems the number of dots grows.

These dots don't show up when you "view source" in a browser. They also render differently in different browsers, as shown in these screenshots:


This is the code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>lcws search (live)</title>
</head>
<body>
    <p>
        <a href="http://blah">Return to Menu</a>
    </p>
    <h1>Search For A Product</h1>
    <hr style="border:1px solid red;">
    <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
        <input type="text" name="q" />
        <input type="submit" name="ElSubmit" value="SELECT"  style="background:yellow;"/>
    </form>

<?php
// Get the search variable(S) from URL
    $s =   @$_POST['s'] ; // this crucial line was missing from original script!!!!!!!!!!!!!!!!!!!!!!!
    $var = @$_POST['q'] ;
    $trimmed = trim($var); //trim whitespace
    $trimmed = str_replace("%","\%",$trimmed); // escape percentage signs
    // best thing I could probably do with apostrophes is not  use them in db
    // and strip them out of $trimmed

// check for an empty string and display a message.
    if ($trimmed == "")  {
      echo "<p>Please enter a search...</p>";
      exit;  }
// check for a search parameter
    if (!isset($var))  {
      echo "<p>We dont seem to have a search parameter!</p>";
      exit;  }
// Connects to your Database
    require_once('includes/inc.dbconnect.php');
//Here we count the number of results
// next line has to be included here, but can't be included in the edit module --why?!
    mysql_query("SET NAMES 'utf8' COLLATE 'utf8_unicode_ci'");
    $query = "select * from vuPHP_searchProducts where productName like \"%$trimmed%\" order by productName";
    $numresults=mysql_query($query);
    $numrows=mysql_num_rows($numresults);
// rows to return
    //$limit=25; 
// If we have no results, tell the user
   if ($numrows == 0){
      echo "<p>Sorry, your search: &quot;" . $trimmed . "&quot; returned zero results</p>";
    }
    else {
          // next determine if s has been passed to script via the URL in the links below, if not use 0
              if (empty($s)) {    $s=0; }
           // get results
           // $query .= " limit $s,$limit";
            $result = mysql_query($query) or die(mysql_error());
          // display what the person searched for
          echo "<p>Here are the results for your search for <strong> &quot;" . $var . "&quot; </strong></p>";
          // many many dots print out here for some reason; number of dots increase with
          // number of rows returned
          // also noticed NEXT link isn't working as of october 6, 2009
          echo '<table border="1" cellpadding="4"><tr>
                    .<th>Count</th>
                    .<th>product Name</th>
                    .<th>Size</th>
                    .<th>Rep</th>
                    .<th>Retail</th>
                    .<th>Edit</th>
                    .<th>View Private Detail</th>
                    .<th>View Public Detail</th>
                    .</tr>';
          $count = 1 + $s ;
          
          // now you can display the results returned
            while ($row = mysql_fetch_array($result)) {
            $idItemNum = $row["idItemNum"];
            $productName = $row["productName"];
            $size = $row["size"];
            $rep = $row["rep"];
            $retail = $row["retail"];
         
            echo "  <tr>
                    .<td>$count</td>
                    .<td>$productName</td>
                    .<td>$size</td>
                    .<td>$rep</td>
                    .<td>$retail</td>
            .<td class='bodyRight'><a href='editProduct.php?idItemNum=$idItemNum'>Edit</a></td>
            .<td class='bodyRight'><a href='viewDetailsPrivate.php?idItemNum=$idItemNum'>Private Details</a></td>
            .<td class='bodyRight'><a href='viewDetailsPublic.php?idItemNum=$idItemNum'>Public Details</a></td>
                    .</tr>";
            $count++ ;
            }
          echo "</table>";
    } // end of else block
?>

</body>
</html>

Have you ever seen anything like this? Any ideas what would cause this annoyance?

Thanks for any ideas :)

#2 MadTechie

MadTechie

    Advanced Member

  • Staff Alumni
  • 9,403 posts
  • LocationUK

Posted 28 October 2009 - 04:32 PM

I'm sure they do appear in source,
you probably have
echo "."
in a loop some where
Computers are good at following instructions, but not at reading your mind.

The quality of a response, is usually directly related to the quality of the question. ©2009 mjdamato

I dunno about that. A regular expression has a 0% chance of touching my penis.

the code is professionally made up but not working

Remember to Click Solved, how to ask questions - the smart way

#3 valdepenas

valdepenas

    Newbie

  • New Members
  • Pip
  • 2 posts

Posted 28 October 2009 - 04:48 PM

Ok I feel dumb now lol

I tried taking out my concatenation operators (I thought I had to concatenate if I was splitting up an echo statement across multiple lines in my editor), and that removed my dots.

Thanks for pointing this out to me :)

#4 MadTechie

MadTechie

    Advanced Member

  • Staff Alumni
  • 9,403 posts
  • LocationUK

Posted 28 October 2009 - 04:55 PM

LOL, well you found it.. that's the main thing :)
Computers are good at following instructions, but not at reading your mind.

The quality of a response, is usually directly related to the quality of the question. ©2009 mjdamato

I dunno about that. A regular expression has a 0% chance of touching my penis.

the code is professionally made up but not working

Remember to Click Solved, how to ask questions - the smart way




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com