Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-12-2012, 01:40 PM   PM User | #1
mjabado
New Coder

 
Join Date: Dec 2011
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
mjabado is an unknown quantity at this point
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");
}
?>
mjabado is offline   Reply With Quote
Old 02-12-2012, 01:56 PM   PM User | #2
KuriosJon
Regular Coder

 
Join Date: Jan 2012
Posts: 134
Thanks: 0
Thanked 32 Times in 32 Posts
KuriosJon is on a distinguished road
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.
__________________
Roundabout Time Tracking
KuriosJon is offline   Reply With Quote
Old 02-12-2012, 02:02 PM   PM User | #3
mjabado
New Coder

 
Join Date: Dec 2011
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
mjabado is an unknown quantity at this point
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"
mjabado is offline   Reply With Quote
Old 02-12-2012, 02:05 PM   PM User | #4
KuriosJon
Regular Coder

 
Join Date: Jan 2012
Posts: 134
Thanks: 0
Thanked 32 Times in 32 Posts
KuriosJon is on a distinguished road
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.
__________________
Roundabout Time Tracking
KuriosJon is offline   Reply With Quote
Old 02-12-2012, 02:16 PM   PM User | #5
KuriosJon
Regular Coder

 
Join Date: Jan 2012
Posts: 134
Thanks: 0
Thanked 32 Times in 32 Posts
KuriosJon is on a distinguished road
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.
__________________
Roundabout Time Tracking
KuriosJon is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:14 PM.


Advertisement
Log in to turn off these ads.