Re: Not a Valid MySQL-Link Resource

From: Date: Sat, 19 Oct 2002 20:50:59 +0000
Subject: Re: Not a Valid MySQL-Link Resource
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-120632@lists.php.net to get a copy of this message
No, but I have fixed it. I created a function to connect to the db instead of connecting to it each time using mysql_pconnect(). Thanks for your help! ----- Original Message ----- From: "John Nichel" <jnichel@by-tor.com> To: "Stephen" <webmaster@melchior.us> Sent: Saturday, October 19, 2002 3:50 PM Subject: Re: [PHP] Not a Valid MySQL-Link Resource > Are you closing off the connection anywhere in the script? Possible > that it's getting closed prior to excuting the query? Have you tried it > without using a persistant connection, just mysql_connect()? > > Stephen wrote: > > Same error. I did put mysql_select_db() once before I sent the email and I > > got the same error but twice. > > > > > > ----- Original Message ----- > > From: "John Nichel" <jnichel@by-tor.com> > > To: "Stephen" <webmaster@melchior.us> > > Cc: "PHP List" <php-general@lists.php.net> > > Sent: Saturday, October 19, 2002 3:41 PM > > Subject: Re: [PHP] Not a Valid MySQL-Link Resource > > > > > > > >>Try this... > >> > >>Before you run the query.... > >> > >>mysql_select_db ( "database_the_table_is_in" ); > >> > >>or change your query to read.... > >> > >>"SELECT * FROM database_the_table_is_in.users WHERE key='$key' AND > >>email='$email'"; > >> > >>Stephen wrote: > >> > >>>Here's $main: > >>> > >>>$main = mysql_pconnect($hostname_main, $username_main, $password_main) > >> > > or > > > >>>die(mysql_error()); > >>> > >>>I won't give the user, host, pass, etc for obvious reasons. I'm > >> > > connecting > > > >>>to the database jsut fine though. > >>> > >>>----- Original Message ----- > >>>From: "John Nichel" <jnichel@by-tor.com> > >>>To: "Stephen" <webmaster@melchior.us> > >>>Cc: "PHP List" <php-general@lists.php.net> > >>>Sent: Saturday, October 19, 2002 3:33 PM > >>>Subject: Re: [PHP] Not a Valid MySQL-Link Resource > >>> > >>> > >>> > >>> > >>>>What's $main? What does you connection string look like? > >>>> > >>>>Stephen wrote: > >>>> > >>>> > >>>>>Hello, > >>>>> > >>>>>I'm having some trouble understanding this error I'm getting. > >>>>>Here's > >>>> > > the > > > >>>error: > >>> > >>> > >>>>>Warning: mysql_query(): supplied resource is not a valid MySQL-Link > >>>> > >>>resource in c:\phpdev5\www\newsletter\index.php on line 38 > >>> > >>> > >>>>>Now here's the block of code that goes into the query: > >>>>> > >>>>> $key = $HTTP_GET_VARS['key']; > >>>>> $email = $HTTP_GET_VARS['email']; > >>>>> $sql = "SELECT * FROM users WHERE key='$key' AND > >>>>> email='$email'"; > >>>>> $query = mysql_query($sql, $main); > >>>>> > >>>>>Please help! > >>>>> > >>>>> > >>>>>Thanks, > >>>>>Stephen Craton > >>>>>http://www.melchior.us > >>>>>http://php.melchior.us > >>>> > >>>> > >>>> > >>>>-- > >>>>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 > >> > >> > > > > > > > > > > > > > > >

« previous php.general (#120632) next »