jeff.tet wrote:I want to be able to return mysql_error() mesage to my previously run script.
something like this:
test1.php
<?php
fill in proper fields and post them to test2.php
?>
test2.pbp
<?php
run query too insert data and if error return error to test1.php
?>
Hello Jeff,
Try this code below. It is relatively basic, but you should be able to get the idea.
<?php
/* Post back to page1.php and at the top, run this check.
If the query returns an error, it will stay on page 1 and display the error
If it succeeeds, the page will redirect to page2.php.
Note: Header() must be called BEFORE any HTML is displayed on the page.
*/
$link = mysql_connect("localhost", "mysql_user", "mysql_password");
$query = mysql_query("SELECT & FROM tablethatdoesnotexist", $link);
if (mysql_errno())
{
echo mysql_errno($link) . ": " . mysql_error($link) . "\n";
}
else
{
header("Location: http://www.domain.com/page2.php");
}
?>