Jump to content

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


valdepenas

Recommended Posts

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: "" . $trimmed . "" 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> "" . $var . "" </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 :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.