ubuntu Posted May 10, 2007 Share Posted May 10, 2007 Dear all, Below is my coding, I don't know what's wrong with this, the output is a blank page. Is it any syntax error or I miss something else? $connection = mysql_connect("$host", "$user", "$password") or die(mysql_error()); $db = mysql_select_db($database, $connection) or die(mysql_error()); //build and issue query $sql = "SELECT * FROM pendaftaran WHERE username = '$_POST['username']'"; $result = mysql_query($sql) or die (mysql_error()); //get the number of rows in the result set $num = mysql_numrows($result); //if the username exists, print the message if ($num != 0) { die("The Username '$_POST['username']' already exists, please select another username."); } Your advice or suggestion are most welcome. Thank you for your kind attention. Quote Link to comment https://forums.phpfreaks.com/topic/50814-check-whether-the-username-exists-registration-authentication/ Share on other sites More sharing options...
per1os Posted May 10, 2007 Share Posted May 10, 2007 This should throw a syntax error: <?php // ffixed version die("The Username " . $_POST['username'] . " already exists, please select another username."); } <?php $num = mysql_numrows($result); //should be $num = mysql_num_rows($result); <?php //build and issue query $sql = "SELECT * FROM pendaftaran WHERE username = '" . $_POST['username'] . "'"; // syntax issue here also. It seems you have turned off error reporting, probably not the best idea for development. Quote Link to comment https://forums.phpfreaks.com/topic/50814-check-whether-the-username-exists-registration-authentication/#findComment-249866 Share on other sites More sharing options...
ubuntu Posted May 10, 2007 Author Share Posted May 10, 2007 Thank you bro frost110, Your code worked. Appreciated! However, how to turn on error_reporting? Sorry, I'm a dummy. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/50814-check-whether-the-username-exists-registration-authentication/#findComment-249899 Share on other sites More sharing options...
chronister Posted May 10, 2007 Share Posted May 10, 2007 You can turn on error reporting in your php.ini file in /etc/php5/apache2 I have noticed that Ubuntu (6.01 is what I run) does not report errors very well. I have it set to E_ERROR, and I don't get the same feedback as my windows xp machine running XAMPP also set to E_ERROR or to turn on error reporting for some pages, you can use at the top of the pages you want it to report on error_reporting(E_WARNING); ini_set('display_errors', '1'); Quote Link to comment https://forums.phpfreaks.com/topic/50814-check-whether-the-username-exists-registration-authentication/#findComment-250017 Share on other sites More sharing options...
ubuntu Posted May 11, 2007 Author Share Posted May 11, 2007 Thank you chronister, but I running my code on Windows machine, is it the setting is the same as your stated on Ubuntu machine? Quote Link to comment https://forums.phpfreaks.com/topic/50814-check-whether-the-username-exists-registration-authentication/#findComment-250434 Share on other sites More sharing options...
per1os Posted May 11, 2007 Share Posted May 11, 2007 No you can use that same setup for Windows. He was just stating that Ubuntu usually has a low level of error reporting and that is a work around to put inside code. Quote Link to comment https://forums.phpfreaks.com/topic/50814-check-whether-the-username-exists-registration-authentication/#findComment-250536 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.