Jump to content

Recommended Posts

My query keeps saying "user does not exist" even when the user exists... im not sure why.. everything is case matched too..

 

 

$GetUserName = mysql_query("SELECT * FROM userregistration
                    WHERE UserName='$Username'");
if (!($row = mysql_fetch_assoc($GetUserID))) {
	die('This Username does not exist!');
}

 

 

i also echo'd it and got this:

 

Resource id #5Column count doesn't match value count at row 1

argh good spot I just changed it but same result occurred.

 

current code:

 

$GetUserName = mysql_query("SELECT * FROM userregistration
                    WHERE UserName='$Username'");
if (!($row = mysql_fetch_assoc($GetUserName))) {
	Echo $Username;
	Echo $GetUserName;

}

 

the response:

Resource id #5Column count doesn't match value count at row 1

Check for errors

 

$GetUserName = mysql_query("SELECT * FROM userregistration

                    WHERE UserName='$Username'") or die (mysql_error());

 

 

The error message you quoted is normally from an insert statement

 

There is one a few lines after it here:

 

$UserID = $row["UserID"];					
$Sender = $_SESSION['Current_User'];
$query = "INSERT INTO `messages` (Reciever, Sender, Senttime, MessageText, Subject)
				Values ('$UserID', '$Sender', '$Date', '$MessageText', '$Subject', '$Date')";
	mysql_query($query) or die(mysql_error());

 

 

But i put the die back in the previous query i get : "This Username does not exist!" as the first post had shown which is the die itself. So i don't get how the insert could be invovled?

The query you just quoted will not work.  There are five fields defined and six values in the query!

 

While testing, I really recommend you trap errors usefully and more fully so you'll know exactly what's happening.

 

mysql_query($query) or die(mysql_error(). " with query ". $query); // get useful error message

well the issue lies with the first query. Not the second one. I hadn't got that far yet but cos Barand mentioned it i pasted it here. The first query as posted on the first post cannot find the user even though its correct and the username does exist.... =/

Let's try again. Tell us specifically which query is failing and how, as well as (re)posting the code relevant to the first query.  And does 'fail' mean you get an error or just that you don't get the results you expect?  Either way, clarify that please.

ok code:

 

$GetUserName = mysql_query("SELECT * FROM userregistration
                    WHERE Username='$Username'");
if (!($row = mysql_fetch_assoc($GetUserName))) {
	die('This Username does not exist!');
}	

 

 

the input is "SirChick"

 

and the result back is the die "Username does not exist".

Try replacing

 

$GetUserName = mysql_query("SELECT * FROM userregistration
                    WHERE Username='$Username'");

 

with this:

$query = "SELECT * FROM userregistration WHERE Username='$Username'";
$GetUserName = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query);

 

If that reports an error, please post its output completely here.

can you ecko $Username; before start query

i think that $Username is not set

 

Possibly, but we'll get there one step at a time.

 

yup i believe resource id saying something like empty set for your query or variable

 

Zero evidence for that so far.  resource is what's returned from the query - and THEN its value(s) need to be extracted. And that's code we haven't seen any evidence of yet.

AndyB the returned error was :

 

"This Username does not exist!" suggestion the code is infact ok but it really isnt finding the username (possibly blank) So i checked the form that im using. I did an echo for $Username, your right nothing echo'd.

 

How ever on my form i see no problems in terms of why it shouldn't be working. This is what i have:

 

The input box that the play puts the username into which is in the form:

<input type="text" id="Username" style="position:absolute;left:31px;top:580px;width:144px;font-family:Courier;font-size:19px;z-index:1" size="16" name="Editbox1" value="">

 

Then its set to a variable in PHP:

 

$Username = mysql_real_escape_string($_POST['Username']);

<input type="text" id="Username" style="position:absolute;left:31px;top:580px;width:144px;font-family:Courier;font-size:19px;z-index:1" size="16" name="Editbox1" value="">

 

The NAME of the variable from that input is Editbox1 not Username.  Your php code should be looking for $_POST['Editbox1'].

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.