View Single Post
  #1   Spotlight this post!  
Unread 23-05-2004, 16:41
Raven_Writer's Avatar
Raven_Writer Raven_Writer is offline
2004 Detroit & Pittsburgh Winners
AKA: Eric Hansen
FRC #0005 (RoboCards)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2002
Location: Melvindale
Posts: 1,549
Raven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really nice
Send a message via ICQ to Raven_Writer Send a message via AIM to Raven_Writer Send a message via MSN to Raven_Writer Send a message via Yahoo to Raven_Writer
MySQL/PHP Query question

I've decided to create a comment script for a beginning project. Right now, I'm working on the registering part of the script. My problem is checking to see if the username already exists within the database. Here's the code I'm using right now:

PHP Code:
<?
$user 
$_POST['username'];
$pass $_POST['password'];
$check $_POST['passcheck'];
$conn mysql_connect(/* connect to mysql */);
if(!
$conn){
 echo(
"Unable to connect to MySQL: "mysql_error());
 exit;
}
$db mysql_select_db(/* try to connect to database */);
if(!
$db){
 echo(
"Unable to select database: "mysql_error());
 exit;
}
 
/* ::: LOOK BELOW ::: */
$result mysql_query("SELECT * FROM information WHERE user = '"$user ."'");
if(
$result != ""){
 echo(
"Username already exists in database.  Please choose a different username to continue.");
 exit;
}
/* ^^^^  LOOK ABOVE ^^^^ */
?>
I can connect to MySQL and the database just fine.
__________________
AIM: wisprmylastbreth
EMail: nightskywriter@gmail.com
Y!: synsoflife

"ai yoru ga" -- "Love the nights"