Announcement

Collapse
No announcement yet.

PHP Questions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • MartynJ
    replied
    Thanks, I get the same local, though get a problem where it seems to be working sometimes, not others, like i get no results on a search one time, and if I run it again a second later get results. Thanks a lot. Had a few ideas about improving the form so people can search with more refined parameters etc, so will post that up here tomorrow some time I think. Thanks a lot for this.

    Leave a comment:


  • scoutt
    replied
    sorry I got busy.

    http://www.snippetlibrary.com/test/searchresults.php

    search for something you think is in there.

    Leave a comment:


  • MartynJ
    replied
    IS it on your site, I had a quick look about the one listed in your WWW link and don't see it?

    Leave a comment:


  • scoutt
    replied
    well like I said the last script I posted works. I used your sql from phpmyAdmin and made a database of all the shows. then ran that script. I found there was some table name problems so I changed it in the script. look at my last one and you can see it.

    I have the script at home and I will put it up on my site so you can see it work.

    Leave a comment:


  • MartynJ
    replied
    My apologies. Well, as I think I might have posted, the errors are all gone, but the form returns no results for anything, regardless of what I search for, all I get is a blank page. I can set up a dyndns client on my comp to let you see what I mean?

    Leave a comment:


  • scoutt
    replied
    so what is the problem now. you want help when it works and you don't say what the problem was.

    Leave a comment:


  • MartynJ
    replied
    Help with this, anyone? vB team guys? Somebody? It's that close to working, yet doesn't...

    Leave a comment:


  • Dan615
    replied
    quote:
    --------------------------------------------------------------------------------

    SQL pattern matching allows you to use `_' to match any single character and `%' to match an arbitrary number of characters (including zero characters). In MySQL, SQL patterns are case insensitive by default. Some examples are shown below. Note that you do not use = or != when you use SQL patterns; use the LIKE or NOT LIKE comparison operators instead.

    To find names beginning with `b':

    mysql> SELECT * FROM pet WHERE name LIKE "b%";
    --------------------------------------------------------------------------------

    so THAT was my problem! I just put WHERE LIKE, without the row name, and I was wondering what the hell I was doing wrong the whole time...AGH! thanx

    Leave a comment:


  • MartynJ
    replied
    Well, will try tomorrow, too tired, too drunk right now... Good old Sat night. Well, thanks anyway guys, really appreciate it.

    Leave a comment:


  • scoutt
    replied
    that is fine, just make the form on the other page. I just had it there for testing purposes. it doesn't have to be there.
    Last edited by scoutt; Sat 8 Jun '02, 3:31pm.

    Leave a comment:


  • MartynJ
    replied
    The approach I was looking for was something like:

    http://hostname/seach.htm

    which posts data to

    http://hostname/searchresults.php

    This kinda weird, cause it's always "neaarly there". The searchresults.php should be exaclty as the demo at

    http://www.somethingreal.net/test - reading results etc

    Leave a comment:


  • scoutt
    replied
    here this works. you had some problems with table names.

    PHP Code:
    <?
    echo "<html><head></head><body>";
    if(
    $_REQUEST["submit"]){
    // make sure search word doesn't contain special characters
    $searchword htmlspecialchars($_REQUEST['searchword']);

    echo
    "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" width=\"65%\" id=\"AutoNumber1\">";

    $db mysql_connect("localhost","root","*****");
    mysql_select_db("DB_name");
    $search = ("SELECT epName, epShortReview, epRating, epImage1 FROM episodes WHERE epName LIKE '%$searchword%' "); // get the everything field from the_table (the name of the table) that = the search word
    $result mysql_query($search);
    if (!
    $result){echo mysql_error();}
    $num mysql_num_rows($result);
    if (
    $num){
    while (
    $row mysql_fetch_array($result)) {
    echo <<<myhtml
     <tr>
        <td width="26%"><u><font face="Verdana" size="2"><b>
    $row[epName]</b></font></u></td>
        <td width="174%">&nbsp;</td>
      </tr>
      <tr>
        <td width="26%"><font face="Verdana" size="1">
    $row[epRating]</font></td>
        <td width="174%">
        <img src="
    $row[epImage1]"></td>
      </tr>
      <tr>
        <td width="26%">&nbsp;</td>
        <td width="174%"><font size="1">
    $row[epShortReview]</font></td>
      </tr>
      <tr>
        <td width="26%">&nbsp;</td>
        <td width="174%">&nbsp;</td>
      </tr>
      <tr>
        <td width="26%"><font size="1">Result1</font></td>
        <td width="174%"><a href="review.php&id=
    $row[id]"><font size="1">eplongreview.php&$id=</font></a></td>
      </tr>
    myhtml;
    }
    }else{
    echo 
    "<tr><td>Sorry no results found";
    }
    echo
    "</table>";
    }
    ?>
    <form action="searchresults.php" method="POST">
    <input type=text name="searchword">
    <input type="submit" name="submit" value="submit">
    </form>
    </body>
    </html>

    Leave a comment:


  • scoutt
    replied
    do you have a form on the same page? what is the whole page? can you upload it here

    Leave a comment:


  • MartynJ
    replied
    Yay! No more errors, but, now nothing at all. It just goes to a blank page. Even if I put in the *exact* phrase I know to exist in the table.

    Leave a comment:


  • scoutt
    replied
    well all though it works I don't like it, but try this.
    PHP Code:
    <?
    if($_REQUEST["submit"]){
    // make sure search word doesn't contain special characters
    $searchword htmlspecialchars($_REQUEST['searchword']);
    ?>
    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="65%" id="AutoNumber1">
    <?
    $db 
    mysql_connect("localhost","root");
    mysql_db_select("sg1",$db);
    $result mysql_query("SELECT epTitle, epReview, epRating, epImage1 FROM episodes WHERE epTitle LIKE '%$searchword%' "); // get the everything field from the_table (the name of the table) that = the search word 
    while ($row mysql_fetch_array($result)) {
    echo <<<myhtml
     <tr>
        <td width="26%"><u><font face="Verdana" size="2"><b>
    $row[epTitle]</b></font></u></td>
        <td width="174%">&nbsp;</td>
      </tr>
      <tr>
        <td width="26%"><font face="Verdana" size="1">
    $row[epRating]</font></td>
        <td width="174%">
        <font size="1"><img src="
    $row[epImage1]">    </font></td>
      </tr>
      <tr>
        <td width="26%">&nbsp;</td>
        <td width="174%"><font size="1">
    $row[epReview]</font></td>
      </tr>
      <tr>
        <td width="26%">&nbsp;</td>
        <td width="174%">&nbsp;</td>
      </tr>
      <tr>
        <td width="26%"><font size="1">Result1</font></td>
        <td width="174%"><a href="review.php&id=
    $row[id]"><font size="1">eplongreview.php&$id=</font></a></td>
      </tr>
    myhtml;
    }

    echo
    "</table>";
    }
    ?>

    Leave a comment:

widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...
X