Gtkmasters Posted June 13, 2007 Share Posted June 13, 2007 I am creating an email validation system. I have added this to my verify.php page. <?php if (isset($code)) { @mysql_connect("localhost", "username", "password"); @mysql_select_db("database"); $query = "SELECT username FROM verification WHERE verification_number = $code"; $result = @mysql_query($query); $row = @mysql_fetch_array('$result', MYSQL_ASSOC); echo $row['username']; } ?> I was told to add the "@" symbol to each of my functions for connecting to the database to avoid the MySQL syntax error. However, my script is not working correctly. No information is being displayed. The $code variable is in the browser. (i.e. http://www.example.com/verify.php?code=f546b352205652bbdeab043bc9a030762ef5b5). I have checked to make sure that the code I am entering into my browser is indeed in the database. I had previously changed my Global Variables to On in my PHP.ini file. My host is http://www.hostmonster.com . Oh, I also replaced my actual database information with the information you see up there now. Just so you know. xD Quote Link to comment https://forums.phpfreaks.com/topic/55377-solved-email-validation/ Share on other sites More sharing options...
mmarif4u Posted June 13, 2007 Share Posted June 13, 2007 Try this: $query = "SELECT username FROM verification WHERE verification_number = '$code'"; Quote Link to comment https://forums.phpfreaks.com/topic/55377-solved-email-validation/#findComment-273682 Share on other sites More sharing options...
Gtkmasters Posted June 13, 2007 Author Share Posted June 13, 2007 I changed the script and it continued to show up as nothing. That is very odd. Quote Link to comment https://forums.phpfreaks.com/topic/55377-solved-email-validation/#findComment-273684 Share on other sites More sharing options...
mmarif4u Posted June 13, 2007 Share Posted June 13, 2007 Please remove the @ sign from every line. And add this line to ur code: $result = mysql_query($query) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/55377-solved-email-validation/#findComment-273687 Share on other sites More sharing options...
Gtkmasters Posted June 13, 2007 Author Share Posted June 13, 2007 I removed every @ symbol but as I said before it results in an error. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/malevol1/public_html/arderia/verify.php on line 13 I had the query the database function in my script but I removed the one I had and added the one you suggested in my script because of the die function with it. It showed no change. Quote Link to comment https://forums.phpfreaks.com/topic/55377-solved-email-validation/#findComment-273694 Share on other sites More sharing options...
Nhoj Posted June 13, 2007 Share Posted June 13, 2007 Try doing: <?php if (isset($code)) { $code = preg_replace('|[^A-z0-9]|', '', $code); $dbconn = @mysql_connect($dbhost, $dbuser, $dbpass) or die('MySQL Error: Could not establish a connection to the databse.'); @mysql_select_db($dbname, $dbconn) or die('MySQL Error: Could not locate the specified database'); $query = 'SELECT `username` FROM `verification` WHERE `verification_number` = "'.$code.'"'; $result = mysql_query($query); $row = mysql_fetch_assoc($result); echo $row['username']; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/55377-solved-email-validation/#findComment-273695 Share on other sites More sharing options...
Gtkmasters Posted June 13, 2007 Author Share Posted June 13, 2007 I changed what you said and it still did not work. I compared the two verification numbers again and I was missing a number if the verification code. I changed it and the program ran correctly. Thank you for your help. Quote Link to comment https://forums.phpfreaks.com/topic/55377-solved-email-validation/#findComment-273701 Share on other sites More sharing options...
neel_basu Posted June 13, 2007 Share Posted June 13, 2007 Use $_GET['code'] Instead of just $code Quote Link to comment https://forums.phpfreaks.com/topic/55377-solved-email-validation/#findComment-273703 Share on other sites More sharing options...
Nhoj Posted June 13, 2007 Share Posted June 13, 2007 Not sure if you are but you come across as a beginner in PHP. I would honestly highly recommend you disable register_globals and use $_POST and $_GET variables to fetch objects from your URL. Register_globals isn't unsafe itself but if you don't know what you are doing it can be very very unsafe. Quote Link to comment https://forums.phpfreaks.com/topic/55377-solved-email-validation/#findComment-273716 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.