Re: Struggling with code

From: Date: Thu, 05 Dec 2002 08:43:17 +0000
Subject: Re: Struggling with code
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-127118@lists.php.net to get a copy of this message
Great to hear it works! I'd still consider using addslashes and the only way I've gotten it to work is to write them in like the following: url='".addslashes($url)."' Looks messy but works. Oh, and stripslashes on the output too. Good Night! Hugh ----- Original Message ----- From: "Ben C." <benc@cox.net> To: <php-general@lists.php.net> Sent: Thursday, December 05, 2002 12:17 AM Subject: RE: [PHP] Struggling with code > Hugh, I took away the comma from $url and it works. > > Everyone, Thanks for your help! > > Ben > > -----Original Message----- > From: Ben C. [mailto:benc@cox.net] > Sent: Thursday, December 05, 2002 12:15 AM > To: php-general@lists.php.net > Subject: RE: [PHP] Struggling with code > > > I have incorporated most of the suggestions. My most recent code is: > > <? > > $db_name = "db1"; > $table_name = "user"; > > $connection = mysql_connect("localhost", "user", "password") or > die("Couldn't connect."); > > $db = mysql_select_db($db_name, $connection) or die("Couldn't select > database."); > > $sql = "UPDATE user > SET > name = '$name', > lname = '$lname', > mobil = '$mobil', > email = '$email', > url = '$url', > WHERE id= '$id' > > "; > > $result = mysql_query($sql,$connection) or mysql_error("Couldn't execute > query."); > > > ?> > > -----Original Message----- > From: Hugh Danaher [mailto:hdanaher@earthlink.net] > Sent: Thursday, December 05, 2002 12:07 AM > To: Ben C. > Cc: php-general@lists.php.net > Subject: Re: [PHP] Struggling with code > > > please post lines 20 and 21, get rid of all @, the comma after url='$url' > and show your most recent code. Others have posted and given you good > advice, you should incorporate their suggestions. > > hugh > ----- Original Message ----- > From: "Ben C." <benc@cox.net> > To: <php-general@lists.php.net> > Sent: Wednesday, December 04, 2002 11:44 PM > Subject: RE: [PHP] Struggling with code > > > > I am now getting the following error: > > > > Warning: Supplied argument is not a valid MySQL-Link resource in > > /home/httpd/vhosts/localhost/httpdocs/data/up.php > > on line 21 > > > > Why do you think that is? > > > > -----Original Message----- > > From: Jason Wong [mailto:php-general@gremlins.biz] > > Sent: Wednesday, December 04, 2002 9:53 PM > > To: php-general@lists.php.net > > Subject: Re: [PHP] Struggling with code > > > > > > On Thursday 05 December 2002 13:24, Ben C. wrote: > > > I am struggling with the code below. I keep getting the error "Couldn't > > > execute query". Please help me out, let me know where I am going wrong. > > > > > > <? > > > > > > $db_name = "db1"; > > > $table_name = "user"; > > > > > > $connection = @mysql_connect("localhost", "user", > > > "password") or > > > die("Couldn't connect."); > > > > > > $db = @mysql_select_db($db_name, $connection) or die("Couldn't select > > > database."); > > > > > > $sql = "UPDATE $table_name > > > SET > > > name = \"$name\", > > > lname = \"$lname\", > > > mobil = \"$mobil\", > > > email = \"$email\", > > > url = \"$url\", > > > WHERE id= \"$id\" > > > "; > > > > > > $result = @mysql_query($sql,$connection) or die("Couldn't execute > > query."); > > > > > > ?> > > > > How about NOT masking the error message by using mysql_query(), instead of > > @mysql_query(). And instead of using die(), use echo mysql_error(). > > > > -- > > Jason Wong -> Gremlins Associates -> www.gremlins.biz > > Open Source Software Systems Integrators > > * Web Design & Hosting * Internet & Intranet Applications Development * > > > > /* > > A rolling stone gathers no moss. > > -- Publilius Syrus > > */ > > > > > > -- > > 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 > > > > > -- > 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 (#127118) next »