SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot Teraflops's Avatar
    Join Date
    Apr 2002
    Location
    NYC
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Argument is not a vaild MYSQL

    Hey all,
    I ran into a problem where I can not figure what is wrong here.
    PHP Code:
    <?php
    //Display current picture. 
    //Allow new picture to be uploaded
    $main=@mysql_query("SELECT picname From linkage Where id=$id);
    if (!
    main) {
    echo(
    "<p> Error fetching Query: " 
    mysql_error() . "<p>" );
    exit();
    }
    while (
    $r mysql_fetch_array($main)) {
    $id=$r["id"];
    $picname=$r["picname"];
    echo(
    "<IMG Src=""\"../../../lk_image//$picname\">" );
    }
    ?>
    I get this error :
    Code:
    Warning: Supplied argument is not a valid MySQL result resource in E:\Inetpub\wwwroot\One\controlone\admin\Link_files\change.php on line 98
    Line 98 is = while ($r = mysql_fetch_array($main)) {
    Appreciate the help.
    OneX Square Creation
    One man said Why ? ... Another man said Why not ?

  2. #2
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    If that is your whole PHP Block, when are you actually connecting to the database?
    Wayne Luke
    ------------


  3. #3
    SitePoint Zealot Teraflops's Avatar
    Join Date
    Apr 2002
    Location
    NYC
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry about that
    Here it is :

    PHP Code:
    <?php
    $dbcnx
    =@mysql_pconnect($localhost,$username,$password);
     if (!
    $dbcnx){
       echo (
    "<p> Unable to Connect to the" 
        
    "database at this time.</p>");
      exit();
      }
    mysql_select_db($linkdb);
    $main=@mysql_query("SELECT picname From linkage Where id=$id");
    if (!
    main) {
     echo(
    "<p> Error fetching Query: " 
       
    mysql_error() . "<p>");
     exit();
     }
      while (
    $r mysql_fetch_array($main)) {
         
    $id=$r["id"];
          
    $picname=$r["picname"];
    echo(
    "<IMG Src=""\"../../../lk_image//$picname\">");
     }
     
    ?>
    OneX Square Creation
    One man said Why ? ... Another man said Why not ?

  4. #4
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Remove the @ signs from your mysql calls so errors are suppressed and you can actually look at them.

    The most common reason for this error is because you have an invalid connection or the user that you connected with doesn't have permissions to access the database and/or tables you are looking for.
    Wayne Luke
    ------------


  5. #5
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This line is wrong:
    Code:
    if (!main) {
    Change main to $main.
    Aaron Brazell
    Technosailor



  6. #6
    SitePoint Zealot Teraflops's Avatar
    Join Date
    Apr 2002
    Location
    NYC
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yup that what was missing. It works well now.
    Thanks for the help.
    OneX Square Creation
    One man said Why ? ... Another man said Why not ?


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
  •