MySQL-Link resource not valid

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • exoticdevil
    New Member
    • Mar 2010
    • 3

    MySQL-Link resource not valid

    I get this error:

    Warning: mysql_query(): 3 is not a valid MySQL-Link resource in C:\xampp\htdocs \Admin\deleteus er.php on line 19

    And my script is:

    Code:
    <?php
    include ('sqlcon.php');
    mysql_select_db("shop",$conn);
     
    global $conn;
    $id = $_POST[id];
     echo $id;
    include('users.php');
    
    if ($_POST['delete'])
    {
        echo 'delete'; 
        mysql_query("DELETE FROM test WHERE id=$id",$conn);
        } 
       
    else if ($_POST['info'])
     {
        echo 'info'; 
        $last = mysql_query("SELECT lastname FROM test WHERE id=$id",$conn) or die(mysql_error());
        echo $last;
        }
         
    $thispage = $_SERVER['PHP_SELF'];
    $form_page = <<< EOFORMPAGE
    
    <body>
    
    <form method="POST" action="--WEBBOT-SELF--">
    	<p><input type="text" name="T1" value="$last"size="20"></p>
    </form>
    
    </body>
    
    
    EOFORMPAGE;
    echo $form_page;
    ?>
    thanx for help.
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Please see this article written by Atli.

    Comment

    • exoticdevil
      New Member
      • Mar 2010
      • 3

      #3
      Article didn't helped for me... maby somedody can show an example of working code, or fix this?

      Comment

      • philipwayne
        New Member
        • Mar 2010
        • 50

        #4
        Your connection is invalid. The article Markus posted the link to does contain your answer you just didn't read it.

        "1.1. MySQL "link" resources
        These tell PHP how to communicate with MySQL.

        When you call mysql_connect, PHP opens a connection to the MySQL server. If successful, the connection is opened and the connection details are stored in memory. The "mysql_link " resource is a link to the memory location where those details are stored."

        Comment

        • exoticdevil
          New Member
          • Mar 2010
          • 3

          #5
          I have chaged my script abit, now i get another error..

          Warning: mysql_fetch_arr ay() expects parameter 1 to be resource, string given in C:\xampp\htdocs \Admin\deleteus er.php on line 23

          I have changed this:
          $last = mysql_query("SE LECT lastname FROM test WHERE id=$id",$conn) or die(mysql_error ());
          to this:

          $getinfo = "SELECT lastname FROM test WHERE id=$id";
          while ($myrow = mysql_fetch_arr ay($getinfo))
          {
          $last = $myrow["lastname"];
          }
          i don't understand this..

          Comment

          • Markus
            Recognized Expert Expert
            • Jun 2007
            • 6092

            #6
            I suggest you take a look at some MySQL & PHP tutorials.

            Comment

            • philipwayne
              New Member
              • Mar 2010
              • 50

              #7
              Your no longer preforming a query meaning you have no result for mysql to fetch an array from it's a database not magic can't really pluck things out of the air.

              Agree with Markus but I recommend tutorialspoint. com and w3schools.com I would rate tizag.com third though.

              Comment

              Working...