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 5 of 5
  1. #1
    New Coder
    Join Date
    Dec 2011
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Resource id #6 error .. please help ..

    Code:
    <?php
    $email=$_POST['email'];
    $password=$_POST['password'];
    mysql_connect("localhost","root","") or die ("Cannot connect to server");
    mysql_select_db("blood") or die ("Cannot connect to database.");
    $sql=("SELECT mobile FROM user WHERE email='$email' and password='$password'");
    $mobile=mysql_query($sql);
    $sql1=("SELECT * FROM donor WHERE mobile='$mobile'");
    $result=mysql_query($sql1);
    $count=mysql_num_rows($result);
    if($count==1){
    $sql2=("DELETE FROM donor WHERE mobile='$mobile' LIMIT 1");
    mysql_query($sql2);
    echo("Successfully removed from donor list.");
    header("Refresh: 3 url=http://localhost:8080/phpmyadmin/websites/Home(User)/page.php");
    }
    else{
    $sql3=("SELECT city FROM user WHERE email='$email' and password='$password'");
    $city=mysql_query($sql3);
    $sql4=("INSERT INTO donor (mobile, city) VALUES ('$mobile', '$city')");
    mysql_query($sql4);
    echo ("Successfully added to donor list.");
    header("Refresh: 3 url=http://localhost:8080/phpmyadmin/websites/User%20Change%20From%20Donor%20List/page.php");
    }
    ?>

  • #2
    Regular Coder
    Join Date
    Jan 2012
    Posts
    134
    Thanks
    0
    Thanked 32 Times in 32 Posts
    Could you provide a little bit more detail about this error? Whenever you get something like Resource ID in mysql, it typically means you're echoing the result resource instead of a row.

  • #3
    New Coder
    Join Date
    Dec 2011
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    here im echoing nothing, what im doing is :
    1) obtain email and password
    2) query the table "user" to get the mobile number of the specified user info (email and password)
    3) query the table "donor" to check if the obtained mobile number exists in the table or no (via $count)
    4) if it exists (in other words, $count==1), delete it from the table "donor"
    5) if it doesn't (in other words, $count!=1), query the table "user" to get the city where we have a match in email and password
    6) insert mobile and city into table "donor"

  • #4
    Regular Coder
    Join Date
    Jan 2012
    Posts
    134
    Thanks
    0
    Thanked 32 Times in 32 Posts
    So at which part of the code do you get the error? If you're not sure, comment out sections starting at the bottom until the error goes away.

  • #5
    Regular Coder
    Join Date
    Jan 2012
    Posts
    134
    Thanks
    0
    Thanked 32 Times in 32 Posts
    I'll also say that

    Code:
    $value = mysql_query($query);
    does not quite work. You need to also make use of mysql_fetch_assoc() to actually get the data.


  •  

    Posting Permissions

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