Aureole Posted August 14, 2007 Share Posted August 14, 2007 I have no idea why this isn't working...basically on step one you enter your username password email address etc. then it sends a validation code to your email and I have a header that takes you to step two then you enter your validation code which is sent to this file but it doens't work. <?php /*--------------------------*\ File: steptwo.php Author: Joe Created: 14/August/07 6:06 PM Modified: 14/August/07 6:37 PM Revision: 2 \*--------------------------*/ include("connect.php"); if (isset($_POST['submit'])) { if (empty($_POST['mem_validate'])) { die('You didn\'t enter a validation code.'); } else { $mem_validate = mysql_real_escape_string($_POST['mem_validate']); } $query = mysql_query("SELECT * FROM gs_mem WHERE mem_validate = '".$mem_validate."'"); $result = mysql_query($query); if ($result) { $update = mysql_query("UPDATE gs_mem SET mem_active = 1 WHERE mem_validate = '".$mem_validate."'"); mysql_query($update) or die(); header("Location: signup.php?step=three"); } else { die(); } } else { echo('Form not submitted'); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/64888-solved-gah-i-hate-mysql-queries/ Share on other sites More sharing options...
d22552000 Posted August 14, 2007 Share Posted August 14, 2007 at the end of the page AND instead of all DIE(); clauses use: die('ERROR: bla bla bla.<br />Mysql Said: '.mysql_error()); that will tell you about what happened to the sql. Quote Link to comment https://forums.phpfreaks.com/topic/64888-solved-gah-i-hate-mysql-queries/#findComment-323743 Share on other sites More sharing options...
Aureole Posted August 14, 2007 Author Share Posted August 14, 2007 ERROR: bla bla bla. Mysql Said: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #3' at line 1 I have no idea what that means. Quote Link to comment https://forums.phpfreaks.com/topic/64888-solved-gah-i-hate-mysql-queries/#findComment-323746 Share on other sites More sharing options...
d22552000 Posted August 14, 2007 Share Posted August 14, 2007 these are your mysl lines, right? $query = mysql_query("SELECT * FROM gs_mem WHERE mem_validate = '".$mem_validate."'"); and $update = mysql_query("UPDATE gs_mem SET mem_active = 1 WHERE mem_validate = '".$mem_validate."'"); ? Ill go validate them now.... Quote Link to comment https://forums.phpfreaks.com/topic/64888-solved-gah-i-hate-mysql-queries/#findComment-323752 Share on other sites More sharing options...
Aureole Posted August 14, 2007 Author Share Posted August 14, 2007 Yeah basicaly if the validation code that is entered is found in the database it needs to update mem_active to 1 to activate the account for the row which has that validation code. ??? Quote Link to comment https://forums.phpfreaks.com/topic/64888-solved-gah-i-hate-mysql-queries/#findComment-323754 Share on other sites More sharing options...
d22552000 Posted August 14, 2007 Share Posted August 14, 2007 TRY: $query = "mysql_query(\"SELECT * FROM gs_mem WHERE mem_validate = '".$mem_validate"\'\"); == and == $update = "mysql_query(\"UPDATE gs_mem SET mem_active = 1 WHERE mem_validate = '".$mem_validate."'\"); Quote Link to comment https://forums.phpfreaks.com/topic/64888-solved-gah-i-hate-mysql-queries/#findComment-323755 Share on other sites More sharing options...
Aureole Posted August 14, 2007 Author Share Posted August 14, 2007 That's not going to work. ??? It messes up all the syntax. Quote Link to comment https://forums.phpfreaks.com/topic/64888-solved-gah-i-hate-mysql-queries/#findComment-323760 Share on other sites More sharing options...
d22552000 Posted August 14, 2007 Share Posted August 14, 2007 not really. I just escaped your extra quotations. This infact fixes the mysql syntax. Its a conundrum really. MySQL is really picky. I ran thath through PHPMYADMIN and it worked. Quote Link to comment https://forums.phpfreaks.com/topic/64888-solved-gah-i-hate-mysql-queries/#findComment-323767 Share on other sites More sharing options...
Aureole Posted August 14, 2007 Author Share Posted August 14, 2007 Your edits give me sytnax errors. ??? Thanks but it doesn't work... Quote Link to comment https://forums.phpfreaks.com/topic/64888-solved-gah-i-hate-mysql-queries/#findComment-323780 Share on other sites More sharing options...
d22552000 Posted August 14, 2007 Share Posted August 14, 2007 I don't know... I will look again. Quote Link to comment https://forums.phpfreaks.com/topic/64888-solved-gah-i-hate-mysql-queries/#findComment-323783 Share on other sites More sharing options...
Aureole Posted August 14, 2007 Author Share Posted August 14, 2007 Even something as simple as this isn't working: <?php $query = mysql_query("SELECT mem_dname FROM gs_mem WHERE mem_validate = '".$mem_validate."'"); $result = mysql_query($query); if ($result) { header("Location: http://www.veraci7y.net/GameSpaces/signup.php?step=three"); } else { die(mysql_error()); } ?> It's giving me: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #3' at line 1 What is it talking about I don't see anything wrong with it at all...it's talking about line 1.....line 1 is <?php LOL. Quote Link to comment https://forums.phpfreaks.com/topic/64888-solved-gah-i-hate-mysql-queries/#findComment-323786 Share on other sites More sharing options...
d22552000 Posted August 14, 2007 Share Posted August 14, 2007 IT is taling about line one in your SQL SELECT mem_dname FROM gs_mem WHERE mem_validate = 'somecode'; what are you looking for in the datbase (examlple of what goes in mem_validate Run that through an SQL host... dio you have PHPMYADMIN acess? Quote Link to comment https://forums.phpfreaks.com/topic/64888-solved-gah-i-hate-mysql-queries/#findComment-323790 Share on other sites More sharing options...
Aureole Posted August 14, 2007 Author Share Posted August 14, 2007 Yes I just ran this in PHPMyAdmin: SELECT mem_dname FROM gs_mem WHERE mem_validate = e4b0f8a3528fe910f5225c95380f4417 I also tried: SELECT mem_dname FROM gs_mem WHERE e4b0f8a3528fe910f5225c95380f4417 = mem_validate mem_validate is a random string that is generated when the user enters there username and password and hits enter it is also added to the database in mem_validate... It is then sent to their Email address. They have to input it into a text area then it checks to see if the code exists in the database and if so sets mem_active to 1 therefore activating their account... ...but it's just being stupid. Both times it said: MySQL said: Documentation #1054 - Unknown column 'e4b0f8a3528fe910f5225c95380f4417' in 'where clause' And there is a row that has that id in mem_validate and that row does have an entry for mem_dname... Quote Link to comment https://forums.phpfreaks.com/topic/64888-solved-gah-i-hate-mysql-queries/#findComment-323795 Share on other sites More sharing options...
d22552000 Posted August 14, 2007 Share Posted August 14, 2007 its because your hash is not in quotes... try SELECT mem_dname FROM gs_mem WHERE mem_validate='e4b0f8a3528fe910f5225c95380f4417' instead, in the phpmyadmin console. Quote Link to comment https://forums.phpfreaks.com/topic/64888-solved-gah-i-hate-mysql-queries/#findComment-323802 Share on other sites More sharing options...
Aureole Posted August 14, 2007 Author Share Posted August 14, 2007 Ok so that worked in PHPMyAdmin but it won't work in my PHP file... ??? Thanks for all the help anyway, much appreciated.. Quote Link to comment https://forums.phpfreaks.com/topic/64888-solved-gah-i-hate-mysql-queries/#findComment-323806 Share on other sites More sharing options...
Barand Posted August 14, 2007 Share Posted August 14, 2007 It seems like you expect $result to be false if no record is found. This is not so. It only returns false if there is an error. Finding no matching records is not an error. Quote Link to comment https://forums.phpfreaks.com/topic/64888-solved-gah-i-hate-mysql-queries/#findComment-323809 Share on other sites More sharing options...
d22552000 Posted August 14, 2007 Share Posted August 14, 2007 try using quotations in the php then: <?php $query = "SELECT mem_dname FROM gs_mem WHERE mem_validate='".$mem_validate."'"; $result = mysql_query($query); if ($result) { header("Location: http://www.veraci7y.net/GameSpaces/signup.php?step=three"); } else { die(mysql_error()); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/64888-solved-gah-i-hate-mysql-queries/#findComment-323810 Share on other sites More sharing options...
Aureole Posted August 14, 2007 Author Share Posted August 14, 2007 In response to Barand, I didn't know that. But all I want it to do is if it finds something in the database in the mem_validate row which is equal to the variable mem_validate that came in via POST then...do something...otherwise don't do something, how would I approach this? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/64888-solved-gah-i-hate-mysql-queries/#findComment-323813 Share on other sites More sharing options...
kenrbnsn Posted August 14, 2007 Share Posted August 14, 2007 When you're having trouble with MySQL queries, it is always helpful to print the generated query out with the error message: <?php $query = "SELECT mem_dname FROM gs_mem WHERE mem_validate = '".$mem_validate."'"; $result = mysql_query($query) or die("Problem with the query: $query<br>" . mysql_error())l header("Location: http://www.veraci7y.net/GameSpaces/signup.php?step=three"); ?> While changing your code to the above code, I noticed you were calling the mysq_query() function twice. The second time you were passing it the results of the first call. This is what is giving you the error. Remove the second call to mysql_query(). Ken Quote Link to comment https://forums.phpfreaks.com/topic/64888-solved-gah-i-hate-mysql-queries/#findComment-323815 Share on other sites More sharing options...
Aureole Posted August 14, 2007 Author Share Posted August 14, 2007 Ok now it's taking me to step three regardless of if the hash exists in the database or not! Quote Link to comment https://forums.phpfreaks.com/topic/64888-solved-gah-i-hate-mysql-queries/#findComment-323831 Share on other sites More sharing options...
Barand Posted August 14, 2007 Share Posted August 14, 2007 In response to Barand, I didn't know that. But all I want it to do is if it finds something in the database in the mem_validate row which is equal to the variable mem_validate that came in via POST then...do something...otherwise don't do something, how would I approach this? Thanks. if (mysql_num_rows($result) > 0) // record/s found else // not found Quote Link to comment https://forums.phpfreaks.com/topic/64888-solved-gah-i-hate-mysql-queries/#findComment-323845 Share on other sites More sharing options...
Aureole Posted August 14, 2007 Author Share Posted August 14, 2007 I finally got it working, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/64888-solved-gah-i-hate-mysql-queries/#findComment-323868 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.