Current location: Hot Scripts Forums » Programming Languages » PHP » using PHP to handle MySQL error

using PHP to handle MySQL error

 
Prev Previous Post   Next Post Next
  #1  
Old 05-09-07, 10:09 AM
Alith7's Avatar
Alith7 Alith7 is offline
Newbie Coder
 
Join Date: Oct 2006
Location: Lost in the black hole of my mind
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
using PHP to handle MySQL error

I have a database with 2 UNIQUE columns for phone and email.
it's working to block duplicate entries, however I'm having a problem managing the error message to something that will make sense to the user.

Here is the code I have so far.
PHP Code:
<?php
$dbinsert 
false;

$editFormAction $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}

// sest store location to dictate which table to post to
$storetable $_POST['store'];

if ((isset(
$_POST["MM_insert"])) && ($_POST["MM_insert"] == "regForm")) {
  
$insertSQL sprintf("INSERT INTO {$storetable} (first_name, last_name, email, phone) VALUES (%s, %s, %s, %s)",
                       
GetSQLValueString($_POST['first_name'], "text"),
                       
GetSQLValueString($_POST['last_name'], "text"),
                       
GetSQLValueString($_POST['email'], "text"),
                       
GetSQLValueString($_POST['phone'], "text"));

  
mysql_select_db($database_Registration$Registration);
  
$Result1 mysql_query($insertSQL$Registration) or die(mysql_error());

  
$insertGoTo $_SERVER['PHP_SELF'];
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
    
$insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$insertGoTo));
}

?>
How do I overwrite the default error message with one that would use something like this to plug back into the page

PHP Code:
if ($Result1) {
     
$dbinsert true;
     }
if (!
$Result1) {
     
$error['already_reg'] = 'The email or phone that you entered is already registered.  You can only enter once.  If you feel that this is an error, please contact the webmaster at bugs@digitaledgecc.com.';
     } 
help?
Reply With Quote
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to solve this PHP error? j14nhAo PHP 1 02-16-06 08:48 AM
WEB HOSTING - $4.99/MONTH For 1GB HD & 25GB BW! CPanel, PHP, MySQL & MORE! IncognitoNet General Advertisements 0 10-20-05 08:26 AM
single quote "'" error in mysql query by php sjems PHP 4 09-27-05 09:36 AM
PHP multi-dimensional array sorting issue aqw PHP 2 06-25-05 12:09 AM
RESELLER WEB HOSTING - $9.99/MONTH For 4GB HD & 30GB BW! CPanel, PHP, MySQL & MORE! IncognitoNet General Advertisements 0 10-30-04 02:19 PM


All times are GMT -5. The time now is 12:17 AM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2 (Unregistered)