RE: [PHP] Oh, the problem

From: Date: Mon, 22 Jul 2002 04:15:17 +0000
Subject: RE: [PHP] Oh, the problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-108811@lists.php.net to get a copy of this message
Chris. Thanks for living me a hand in such a fast way. It helped me fine. César. > -----Original Message----- > From: Chris Earle [mailto:chris@earleweb.com] > Sent: Monday, July 22, 2002 12:51 AM > To: php-general@lists.php.net > Subject: [PHP] Oh, the problem > > It appears that $username isn't being defined within the scope of the > query. > You define it only in the function. > > Try do this instead: > > $username = ""; > > function pic_upload($userid) > { > global $username; > //... the rest of the code > } > // now do the queries and everything else. > > I think that will fix your problem. > > "César aracena" <icaam@icaam.com.ar> wrote in message > news:000301c23129$aebbab30$adc405c8@gateway... > Hi all. I'm trying to handle a picture upload. So far, I've made my > script store it where I want with the name I want. The only problem now, > is that it should store that given name into a MySQL DB table. I tried > it by calling a function which stores the picture and returns a variable > called $picname then use an UPDATE statement but that variable isn't > passed. any ideas? The code looks like this: > > function pic_upload($userid) > { > if (is_uploaded_file($_FILES['devpicture']['tmp_name'])) > { > $filename = $_FILES['devpicture']['tmp_name']; > > $realname = $_FILES['devpicture']['name']; > > $username = $userid.".jpg"; > > copy($_FILES['devpicture']['tmp_name'], > "c:/apache/htdocs/os-seek/photos\\".$username); > > $username; > } > else > { > echo "Possible file upload attack: filename > ".$_FILES['devpicture']['name'].".<br>"; > } > } > > ------------------------------------------- > and then the updating > ------------------------------------------- > > pic_upload($id); > > $query = "UPDATE os_developers SET devpicture = '$username' WHERE devid > = $id"; > $result = mysql_query($query) or die(mysql_error()); > > Thanks in advance, > > Cesar Aracena > CE / MCSE+I > Neuquen, Argentina > +54.299.6356688 > +54.299.4466621 > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#108811) next »