Get rid of your die().

$res = mysql_query(...);
if(!res)
{
  $_SESSION['mysqlerror'] = mysql_error();
  header("Location: error.php");
  exit();
}
else
{
  header("Location index.php");
}

---John Holmes...

> -----Original Message-----
> From: Peter Houchin [mailto:[EMAIL PROTECTED]]
> Sent: Monday, October 14, 2002 11:44 PM
> To: 'php_gen'
> Subject: RE: [PHP] passing mysql_error() out put to a different page?
> 
> I think that should work but for some reason nothing is getting
written
> into
> the session
> 
> function new_user() {
> 
>    $res = mysql_query("INSERT INTO users WHERE uname='$_POST[uname]' ,
> passwd='$_POST[pass]', firstname='$_POST[firstname]',
> lastname='$_POST[lastname]', email='$_POST[email]',
> company='$_POST[company]'")
> //I get out put here in mysql_error() when uncommented
> //or die (mysql_error());
> 
> //no output from mysql_error() in $_SESSION['mysqlerror'] when i call
> $_SESSION['mysqlerror'] but does take the redirect
> 
> or die ($_SESSION['mysqlerror'] = mysql_error() && Header("Location:
> logerror.php?op=insert_error"));
> 
> Header("Location: index.php");
> }
> 
> here is the code am calling it with :
> 
> function insert_error()
> {
> echo "<div align=center> <font class=\"option\"> There was an error
> <br><br>";
> echo $_SESSION['mysqlerror'];
> echo "</font></div>";
>  }
> 
> I have tripple checked that both pages have the session_start() on
them
> before any function is started.
> 
> any idea's?
> 
> > -----Original Message-----
> > From: John W. Holmes [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, 15 October 2002 11:21 AM
> > To: 'Peter Houchin'; 'Brad Bonkoski'
> > Cc: 'php_gen'
> > Subject: RE: [PHP] passing mysql_error() out put to a different
page?
> >
> >
> > Maybe you should just save the error message into a cookie or
session
> > and then use header() to redirect to the error page.
> >
> > ---John Holmes...
> >
> > > -----Original Message-----
> > > From: Peter Houchin [mailto:[EMAIL PROTECTED]]
> > > Sent: Monday, October 14, 2002 9:22 PM
> > > To: Brad Bonkoski
> > > Cc: php_gen
> > > Subject: RE: [PHP] passing mysql_error() out put to a different
page?
> > >
> > > i have tried this .. but am getting errors at the moment .. (the
sql
> > error
> > > is deliberate)
> > >
> > > can figure out why.. but other wise i can't figure out how to pass
the
> > die
> > > value through if i make the error redirect  out side the die and
have
> > it
> > >
> >
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to