Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Record Added - is there a way to "catch" this message?

Status
Not open for further replies.

peterv12

Technical User
Dec 31, 2008
108
0
0
US
I have the following query to add a record to a table. When it's successful, it displays a blank page with "Record added". What I want to do is catch that message in a variable to display in a formatted message. Can someone tell me how to capture that message into a variable?
$query2 ="INSERT INTO leadsTable
VALUES ('0','$company',
'$contact',
'$phone',
'$fax',
'$street',
'$city',
'$state',
'$zip',
'$license',
'$experience')";
//
$result = mysql_query($query2);
if (!$result) {
print "<b>Update Failed:</b> <br>" . mysql_error();
print "<br>Whole query: " . $query2 . "<br>";
die;
 
There has to be something more, cause the code you posted above cannot in any way generate the message you describe.




----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
hi, right after the mysql_query(), you can run the mysql_affected_rows().

Code:
if (mysql_affected_rows()>0) {
$blah = "<b>Company:</b>&nbsp;{$company}<br />\n<b>Experience:</b>&nbsp;...";
}
else {
// alert user that nothing was done
if (!isset($contact)) {
  $contact = "dear visitor";
  }
$blah = "Sorry, {$contact}. bla bla bla";
}

Olav Alexander Mjelde
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top