HighDots Forums  

Handling MySQL errors with PHP

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss Handling MySQL errors with PHP in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Shaun
 
Posts: n/a

Default Handling MySQL errors with PHP - 07-03-2004 , 11:08 AM






Hi,

Is there a way to handle MySQL errors gracefully such as a duplicate entry
into a UNIQUE field, the method I've been using seems a little laborious...

//see if user exists
$query = "SELECT *
FROM users
WHERE Username = '".$_POST[username]."'";
$result = @mysql_query($query);
$num = @mysql_num_rows($result);
if($num > 0){
$error = "Username already exists, please choose a another one";
header("Location: add_user.php?error=$error");
exit;
}

Thanks for your help



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.