+ Reply to Thread
Results 1 to 3 of 3

Thread: search query help

  1. #1
    stesouthby is offline x10 Sophmore stesouthby is an unknown quantity at this point
    Join Date
    Sep 2009
    Location
    UK
    Posts
    115

    Thumbs up search query help

    hey guys am doing a simple mysql query but keep gettingan error with this part of the php file

    while ($row = mysql_fetch_array($sql)){

    and this is the error i get i cant work out why wonder if you knew any better?

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in ///l/search.php on line 9


    <?php
    mysql_connect ("localhost", "","") or die (mysql_error());
    mysql_select_db ("");

    $company_name = $_POST['company_name'];

    $sql = mysql_query("select * from customertable where company_name like '%$company_name%'");

    while ($row = mysql_fetch_array($sql)){
    echo 'ID: '.$row['customer_ID'];
    echo '<br/> First Name: '.$row['company_name'];
    echo '<br/> Last Name: '.$row['customer_name'];
    echo '<br/> Phone: '.$row['email'];
    echo '<br/><br/>';
    }
    ?>
    "It's time to prove to your friends that you're worth a damn. Sometimes that means dying, sometimes it means killing a whole lot of people."- sin city "You either die a hero or you live long enough to see yourself become the villain" - TDK

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: search query help

    Here we go again...
    Last edited by misson; 07-09-2010 at 04:09 AM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  3. #3
    bdistler's Avatar
    bdistler is offline x10 Lieutenant bdistler is an unknown quantity at this point
    Join Date
    May 2010
    Location
    Catalina AZ USA
    Posts
    349

    Re: search query help

    See me post in this thread in this forum:

    "PHP/SQL: Increment Integer Value in Database via Form"

+ Reply to Thread

Similar Threads

  1. Replies: 0
    Last Post: 03-13-2010, 04:57 PM
  2. my Query
    By sam1186 in forum Free Hosting
    Replies: 2
    Last Post: 02-02-2010, 02:13 AM
  3. Replies: 1
    Last Post: 02-03-2008, 12:29 PM
  4. Google Search engine or Yahoo Search engine?
    By satheesh in forum Crossfire
    Replies: 39
    Last Post: 12-06-2007, 11:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers