Pikachu2000 Posted August 21, 2012 Share Posted August 21, 2012 No, it isn't a bug. A string value used as an array index needs to be quoted. If left unquoted, php interprets it as a constant, just like it would do with any other unquoted string value. Don't believe me? Turn on error reporting (since it should be on while you're developing anyhow), and see for yourself. error_reporting(-1); ini_set('display_errors', 'On'); define('string', 'index'); $array = array( 'string' => 'Element with index "string"', 'index' => 'Element with index "index"' ); echo $array[string]; echo '<br>'; echo $array['string']; echo '<br>'; echo $array['index']; echo '<br>'; echo $array[index]; Quote Link to comment Share on other sites More sharing options...
aliento Posted August 21, 2012 Share Posted August 21, 2012 nice. thank you ! Quote Link to comment Share on other sites More sharing options...
namasteji1 Posted August 29, 2012 Author Share Posted August 29, 2012 <?php session_start();session_destroy(); session_start(); if($_POST["regname"] && $_POST["regemail"] && $_POST["regmobile"] && $_POST["regpass1"] && $_POST["regpass2"] ) { if($_POST["regpass1"]==$_POST["regpass2"]) { $servername="localhost"; $username="root"; $conn= mysql_connect($servername,$username)or die(mysql_error()); mysql_select_db("test",$conn); $sql = "SELECT `id` from users where `email`= ".$_POST['regemail']."' LIMIT 1"; $result=mysql_query($sql,$conn) or die(mysql_error()); $mail_rows = mysql_num_rows($result); $sql = "SELECT `id` from users where `regname`= '".$_POST['regname']."' LIMIT 1"; $result=mysql_query($sql,$conn) or die(mysql_error()); $name_rows = mysql_num_rows($result); if($mail_rows==0&&$name_rows==0) { $sql="insert into users (name,email,mobile,password)values('$_POST[regname]','$_POST[regemail]','$_POST[regmobile]','$_POST[regpass1]')"; $result=mysql_query($sql,$conn) or die(mysql_error()); print "<h1>you have registered sucessfully</h1>"; print "<a href='index.php'>go to login page</a>"; } else echo "duplicated data"; } else print "Passwords doesn't match"; } else print"Invalid input data"; ?> I am getting a sql error, error in where clause for regname and also i would like to know where to put separate echo statements for duplicate username as well as username please? Quote Link to comment Share on other sites More sharing options...
namasteji1 Posted September 3, 2012 Author Share Posted September 3, 2012 please help anyone? 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.