Upload Question Pt.II (Naming Conventions)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

Upload Question Pt.II (Naming Conventions)

Post by $var »

Yesterday I was asking about how to get the files onto the server, via mkdir...
Success! Thanks everyone...

Today, I have a question about the file names.

The files are being copied, but the data entered into the table
is still the default 'none' that I have put as the VALUE of the image.

Here's what I've got:

Code: Select all

$sql = "INSERT INTO members (
		Mem_Logo,
		Mem_CImage,
		Mem_Password,
		Mem_Username) 
		VALUES (
		'none'
		'none'
		'".$_POST["password"]."',
		'".$_POST["username"]."')";
               if(!$result = mysql_query($sql))
			{
				echo mysql_error();
				echo "error on select";
			}
			
		$sql = "SELECT 
		Mem_ID, 
		Mem_Username, 
		Mem_Password FROM members WHERE 
		Mem_Username='".str_replace("'","'",$_POST["username"])."' AND 
                Mem_Password ='".str_replace("'","'",$_POST["password"])."'";
			
                        $memberresults = mysql_fetch_array($result);
			$memberid = $memberresults["Mem_ID"];
			//setcookie ("Mem_ID", $memberid);
			mkdir("f:/www/vhosts/advantageboard.com/httpdocs/Imi/Mem_Img/".$memberid);
			$picname="noimage.jpg";
			$picname2="noimage2.jpg";
			$Mem_Image = "Mem_Logo";	
			$Mem_CImage = "Mem_CImage";	
			foreach( $HTTP_POST_FILES as $aFile )
			{
				if ($aFile['type'] == "image/gif" || 
                                    $aFile['type'] == "image/jpeg" ||         
                                    $aFile['type']=="image/pjpeg")
				{
					copy ($aFile['tmp_name'],       
                                        "Path/".$memberid."/".$aFile['name']) 
					or die ("Could not copy"); 
					echo "";
				
				//	$picname=$aFile['name'];
				
				}
			}


- The 2 image field values are imagefile1, imagefile2
- Files are going to the server
- The database is reading the files default value as if nothing were being entered into imagefile
ruchit
Forum Commoner
Posts: 53
Joined: Mon Sep 26, 2005 6:03 am

Post by ruchit »

are you sure this is working??

Code: Select all

$sql = "INSERT INTO members (
        Mem_Logo,
        Mem_CImage,
        Mem_Password,
        Mem_Username)
        VALUES (
        'none'
        'none'
        '".$_POST["password"]."',
        '".$_POST["username"]."')";
there's an error here, it should look like

Code: Select all

$sql = "INSERT INTO members (
        Mem_Logo,
        Mem_CImage,
        Mem_Password,
        Mem_Username)
        VALUES (
        'none',
        'none',
        '".$_POST["password"]."',
        '".$_POST["username"]."')";
Now if you are inserting 'none', how can you expect the image name to show up in the database, since i see no update queries in the code you've posted.
omega-systems
Forum Newbie
Posts: 14
Joined: Tue Sep 27, 2005 5:01 am
Contact:

Re: Upload Question Pt.II (Naming Conventions)

Post by omega-systems »

You forgot to update members tsable after uploading.

Code: Select all

$sql = "update members set 
  Mem_Logo='".$Mem_Image."', 
  Mem_CImage'".$Mem_CImage."'
  where
	Mem_ID='".$memberid."';
 if(!$result = mysql_query($sql)) 
   { 
    echo mysql_error(); 
    echo "error on select"; 
   }
Regards,
Michael.

Project Manager
Omega Systems Ltd
Email: info@omega-systems.biz
ICQ: 264962449
MSN: omega-systems@hotmail.com
AIM: OmegaSys Ltd
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

SQL Injection alert. :)
Post Reply