Jump to content

problem iin here


zeeshan

Recommended Posts

what is the problem in this script<?phpfunction usernameTaken($username){   global $conn;   if(!get_magic_quotes_gpc()){	  $username = addslashes($username);   }   $q = "select username from info = '$username'";   $result = mysql_query($q,$conn);   return (mysql_numrows($result) > 0);$con = mysql_connect("localhost","tutkings_zxq_net_z","computer");if (!$con)  {  die('Could not connect: ' . mysql_error());  }mysql_select_db("tutkings_zxq_net_info", $con);$sql="INSERT INTO info (username,password,confirmpassword,email)VALUES('$_POST[username]','$_POST[password]','$_POST[confirmpassword]','$_POST[email]')";if (!mysql_query($sql,$con))  {  die('Error: ' . mysql_error());  }echo "you username has been added,Sucessfully now you can log in";mysql_close($con)?>

Link to comment
Share on other sites

$q = "select username from info = '$username'";

That's an incorrect question, I think. It should look like this:
"SELECT this_column FROM this_table WHERE this_column = 'this_value'"

If you use mysql_error you will properly get an error message:

mysql_query($sql) or die(mysql_error());

Link to comment
Share on other sites

I'm working on my English, so if I use the language wrong, tell me please, or I will never be better.
That's an incorrect question, I think. It should look like this:
Even though they are exact synonyms (mean the same thing), when we refer to SQL statements we call them "queries" instead of "questions".
ok i will edit it and tell u is it works or not as some one said where should i add this "}"
Add it after the return statement. A return statement stops the function, so that's where you should put the closing bracket.
Link to comment
Share on other sites

Even though they are exact synonyms (mean the same thing), when we refer to SQL statements we call them "queries" instead of "questions".
Ohh... I should have figured that out (mysql_query etc.), but thanks.And zeeshan, if you read the reply from Wander carefully, you'll see that he mentioned where.
Link to comment
Share on other sites

here is the edited script but it is giving me this message on the browserphrase errror:problem in the script called insert.php the below is the insert.php script

<?php$con = mysql_connect("localhost","tutkings_zxq_net_z","computer");if (!$con)  {  die('Could not connect: ' . mysql_error());  }mysql_select_db("tutkings_zxq_net_info", $con);$sql="INSERT INTO info (username,password,confirmpassword,email)VALUES('$_POST[username]','$_POST[password]','$_POST[confirmpassword]','$_POST[email]')";if (!mysql_query($sql,$con))  {  die('Error: ' . mysql_error());  }echo "you username has been added,Sucessfully now you can log in";mysql_close($con)function usernameTaken($username){   global $conn;   if(!get_magic_quotes_gpc()){	  $username = addslashes($username);   }   $q = "select username from users where username = '$username'";   $result = mysql_query($q,$conn);   return (mysql_numrows($result) > 0);}?>

Link to comment
Share on other sites

You never use the function. You define the function, you say what it is, but you don't use it. You don't actually check if the username is taken, you only set up a function that will do that if you actually use it, but you don't use it. You'll probably want to read through at least the language reference, read from "basic syntax" up through "functions". You might also be able to read in your native language.http://www.php.net/manual/en/langref.phpBut you're going to need to learn how to use PHP before you actually try to use it.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...