Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Aug 2002
    Location
    Toronto, Canada
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts

    getting this error ... Warning: mysql_fetch_row():

    am not sure what am doing wrong ...

    am trying to get results after user input but i only need one row so i did this;

    PHP Code:

    //this is my connection script that i use on all my pages
    include('connect.php'); 
    //this is my query
    $query "SELECT name FROM mytable where value='$uservalue'";
    //this where i do query $link is within connect.php
    $result mysql_query($query$link)

    while(
    $r mysql_fetch_row($result))
    {

    hello my name is$r[0]


    i have also tried this :


    PHP Code:

    //this is my connection script that i use on all my pages
    include('connect.php'); 
    //this is my query
    $query "SELECT * FROM mytable where value='$uservalue'";
    //this where i do query $link is within connect.php
    $result mysql_query($query$link)

    while(
    $r mysql_fetch_row($result))
    {

    $name $r['name'];

    hello my name is$name



    And in both time i get this error....


    Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/domain/public_html/myfile.php on line 103



    Please help me...


    HormonX
    Last edited by HormonX; 11-21-2002 at 03:24 PM.

  • #2
    mat
    mat is offline
    Regular Coder
    Join Date
    Jul 2002
    Posts
    199
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try to Use a more descriptive subject line next time. I think you are looking in the wrong place in terms of what is causing this error. ( 'Warning: mysql_fetch_row():' )

    What exactly is '$link' ?

  • #3
    New Coder
    Join Date
    Aug 2002
    Location
    Toronto, Canada
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you are right ... i should use a more descriptive subject ....

    here is how i use link ...

    PHP Code:

    $user 
    "username";
    $pass "password";
    $db "db_name";
    $link mysql_pconnect("localhost"$user$pass);
    if  ( ! 
    $link 
    die( 
    " Can not connect to MySQL database");
    mysql_select_db$db )
    or die (
    "Can not open database: ".mysql_error() ); 
    so would you have any ide why am getting this error message ?

    HormonX

  • #4
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    if you are using $link here...


    <?
    $link = mysql_pconnect("localhost", $user, $pass);
    ?>
    then I am pretty sure you need to use it here as well
    <?
    mysql_select_db( $db , $link )
    ?>

    but regardless unless you expect to be accessing more than 1 database in your script just drop the connection identifier completely, i.e.

    PHP Code:
    <?
    $user 
    "username";
    $pass "password";
    $db "db_name";
    mysql_connect("localhost"$user$pass) or die( " Can not connect to MySQL database");
    mysql_select_db$db )
    or die (
    "Can not open database: ".mysql_error() );
    ?>
    then ..

    PHP Code:
    <?
    include('connect.php'); 
    $query "SELECT name FROM mytable where value='$uservalue'";
    $result mysql_query($query);
      while(
    $r mysql_fetch_row($result))
        {
          echo 
    'hello my name is: '.$r[0].'<br />';
        }

    ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #5
    New Coder
    Join Date
    Aug 2002
    Location
    Toronto, Canada
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanx for all your help .. but it was my mistake that i made while writing it on my computer... i wrote everything ok on the forum here .. but made an error on my computer

    instead of

    PHP Code:

    while($r=mysql_fetch_row($result)) 
    i have put

    PHP Code:

    while($r=mysql_fetch_row($query)) 
    i can't belive am so blind

    thanx again .. and sorry for all the trouble

    HormonX

  • #6
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    On another note in the future you need to use a proper subject line for threads. "Please help" is not a proper subject line. Read the Posting guidelines.

    Also this should have been posted in the MySQL forum as stated by the Must Read thread at the top of the PHP forum and by the MySQL forum description.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster


  •  

    Posting Permissions

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