Well, the die() function takes a limited number of parameters, which as you
noted is why it doesn't like the assignment of the mysql_error() and the header
statements both inside the die() function.  So, why not something like this:

$res = mysql_query(.....);
if ($res == FALSE)  //which is what I _believe_ die() looks at
/* or at least this is what the manual says the function returns on a query
error */
{
    $error = mysql_error();
    Header("Location: logerror.php?op=insert_error&err_value=$error");
}
// else continue as normal

HTH
-Brad

Peter Houchin wrote:

> i have tried this .. but am getting errors at the moment .. (the sql error
> is deliberate)
>
> 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]' ")
>
> // pass error onto logerror page
>
> or die ('<form> <input type=hidden name=mysqlerror value=\"<?php echo
> mysql_error();?>\"></form>' Header("Location:
> logerror.php?op=insert_error"));
>
> // insert into db worked  redirect
> Header("Location: index.php");
> }
>
> but so far it's not likeing the Header inside the die that's fair enough I
> 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 in
> a if statement or the like...
>
> > -----Original Message-----
> > From: Brad Bonkoski [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, 15 October 2002 11:07 AM
> > To: Peter Houchin
> > Cc: php_gen
> > Subject: Re: [PHP] passing mysql_error() out put to a different page?
> >
> >
> > Very interesting question....
> >
> > The only thing I can come up with right now is if you detect an error
> > (one of the functions returning FALSE,)
> > you can write the contents of mysql_error() to a file log and display that
> > file on another page?  Or pass the output of that (mysql_error()) as an
> > HTTP/form variable to another page?
> > ...spark any additional ideas??
> > -Brad
> >
> > Peter Houchin wrote:
> >
> > > howdy,
> > >
> > > I have a page that I want to control the errors etc for a site,
> > now what I
> > > want is to perform a query on one page but if there's an error
> > it opens a
> > > different page with the error message on it including the out put from
> > > mysql_error() can this be done?
> > >
> > > Cheers
> > >
> > > Peter
> > > "the only dumb question is the one that wasn't asked"
> > >
> > > --
> > > 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