what's wrong with my code?

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Post Reply
User avatar
simplypixie
php-forum Active User
php-forum Active User
Posts: 300
Joined: Sun Dec 11, 2011 12:51 am
Location: Shrewsbury, Shropshire
Contact:

Re: what's wrong with my code?

Post by simplypixie » Wed Dec 05, 2012 9:18 am

I am not sure why you can't show your post data names or table and column names in your query as it won't hurt and can help people help you.

Anyway, the error is telling you that the value in your query is missing or incorrect (in this case the $_POST['user_id'] is either empty or an incorrect format). The first thing to do is dump your posted data to check the values are there

Code: Select all

var_dump($_POST);
I would also separate your mysql_num_rows from your mysql_query (in fact I have never seen this done before but there you go) to make error checking easier for one

Code: Select all

else {
var_dump($_POST); 
$sql = "select * from xxx where xxx='".mysql_real_escape_string($_POST['user_id'])."'";
// If your posted data is correct echo your query to check and run in phpmyadmin
echo $sql;
$query = mysql_query($sql);
$num_rows = mysql_num_rows($query);
if ($num_rows > 0) {
echo 'xxx';
}

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest