Results 1 to 4 of 4

Thread: Mysql fetch problems...

  1. #1
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default Mysql fetch problems...

    I am having a lot of problems with Mysql and localhost. When I got my new computer I downloaded wampserver. Since it works I use it. Before on my old computer, I used netserver only because wamp wouldn't work. Though now I am having problems with MySQL.

    Problem. When I try to get info via php from a database it gives me this error:
    Code:
    mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\getaband.net\cp\index.php on line 39
    Though I know my code is correct because when I made a test database called test with a table named table1 with two rows in there it showed both rows. But it refuses to show what I want it to show.
    Comp info:
    I am using windows vista, brand new computer
    Database I want to access info:
    Storage Engine: MyISAM
    Collation: utf8_unicode_ci

    I would have liked to test it on my site to see if it is a localhost problem but my site is down

    Thanks for help...
    Let me know if you need anything else...

  2. #2
    Join Date
    Jul 2007
    Location
    Azerbaijan, Baku
    Posts
    144
    Thanks
    11
    Thanked 27 Times in 25 Posts

    Default

    Can you show us all your code?

  3. #3
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    PHP Code:
    <?php
    $con 
    mysql_connect("localhost","","");
    if (!
    $con)
      {
      die(
    'Could not connect: ' mysql_error());
      }

    mysql_select_db("users"$con);

    $result mysql_query("SELECT * FROM table3 WHERE id=1");
    while(
    $row mysql_fetch_array($result))
      {
            echo 
    "Welcome, " $row['name'];
        }
    ?>
    There is the only php code on the page... the rest is illreverent html and css junk...

  4. #4
    Join Date
    Jul 2007
    Location
    Azerbaijan, Baku
    Posts
    144
    Thanks
    11
    Thanked 27 Times in 25 Posts

    Default

    Change this:
    Code:
    $result = mysql_query("SELECT * FROM table3 WHERE id=1");
    To this:
    Code:
    $result = mysql_query("SELECT * FROM table3 WHERE id=1") or die(mysql_error());
    When you will open your page there will be error(i think so). Different one. Then you will be able to fix that. If you couldn't paste that error here

  5. The Following User Says Thank You to allahverdi For This Useful Post:

    Rockonmetal (09-09-2008)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •