SirChick Posted August 26, 2007 Share Posted August 26, 2007 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 Quote Link to comment Share on other sites More sharing options...
Barand Posted August 26, 2007 Share Posted August 26, 2007 You'll have more success with if (!($row = mysql_fetch_assoc($GetUserName))) { Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 26, 2007 Author Share Posted August 26, 2007 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 Quote Link to comment Share on other sites More sharing options...
Barand Posted August 26, 2007 Share Posted August 26, 2007 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 Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 26, 2007 Author Share Posted August 26, 2007 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? Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 26, 2007 Share Posted August 26, 2007 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 Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 26, 2007 Author Share Posted August 26, 2007 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.... =/ Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 26, 2007 Share Posted August 26, 2007 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. Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 26, 2007 Author Share Posted August 26, 2007 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". Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 26, 2007 Share Posted August 26, 2007 use die(mysql_error()); instead of your "username does not exist" message, as was suggested a few times now. Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 26, 2007 Share Posted August 26, 2007 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. Quote Link to comment Share on other sites More sharing options...
sasa Posted August 26, 2007 Share Posted August 26, 2007 can you ecko $Username; before start query i think that $Username is not set Quote Link to comment Share on other sites More sharing options...
teng84 Posted August 26, 2007 Share Posted August 26, 2007 yup i believe resource id saying something like empty set for your query or variable Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 26, 2007 Share Posted August 26, 2007 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. Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 27, 2007 Author Share Posted August 27, 2007 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']); Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 27, 2007 Share Posted August 27, 2007 <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']. Quote Link to comment Share on other sites More sharing options...
thefollower Posted August 27, 2007 Share Posted August 27, 2007 This is sirchick still btw...i think my other accounts been hacked :/ i corrected what you said and i get this: SirChickThis Username does not exist! the "sirchick" is the echo of $Username but it still bounces to the Die :S Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 27, 2007 Author Share Posted August 27, 2007 ok got my account back. Yeh $Username has "sirchick" as value but the query dies Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 27, 2007 Author Share Posted August 27, 2007 bump Quote Link to comment Share on other sites More sharing options...
sasa Posted August 27, 2007 Share Posted August 27, 2007 change $Username = mysql_real_escape_string($_POST['Username']); to $Username = mysql_real_escape_string($_POST['Editbox1']); or change name property to Username Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 27, 2007 Author Share Posted August 27, 2007 yeh i done that i changed the editbox1 to Username Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 27, 2007 Author Share Posted August 27, 2007 bump Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 27, 2007 Author Share Posted August 27, 2007 bump again Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 27, 2007 Share Posted August 27, 2007 Post all of your form processing code, as it presently exists. Post the html form that collects the data. Quote Link to comment Share on other sites More sharing options...
socratesone Posted August 27, 2007 Share Posted August 27, 2007 Is the method of the form POST? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.