Uploading files with "%" not working

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
loadafile
Forum Newbie
Posts: 7
Joined: Sun Oct 23, 2011 10:27 pm

Uploading files with "%" not working

Post by loadafile »

A little road block...

If you go to my site www.loadafile.com and upload any file with a "%" in the title you get this error

Warning: sprintf() [function.sprintf]: Too few arguments in /home/content/54/6252454/html/library/database/mysql.php on line 125
A database error has been encountered

I am not sure if the mysql.php is set correctly here is line 125 is anyone know what could be the problem?

Code: Select all

public function query( $query, $shutdown=false )
	{
		if( $shutdown )
		{
			$this->_shutdownQueries[]	= $query;
			return null;
		}

		//-----------------------------------------
		// Set our prefix
		//-----------------------------------------
		
		if( strpos( $query, '%s' ) !== false )
		{
			$query	= sprintf( str_replace( '%s', '%1$s', $query ), $this->_settings['prefix'] );
		}
		
		//-----------------------------------------
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Uploading files with "%" not working

Post by social_experiment »

The script should check the filenames before uploading them and if possible rename the file before uploading
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
loadafile
Forum Newbie
Posts: 7
Joined: Sun Oct 23, 2011 10:27 pm

Re: Uploading files with "%" not working

Post by loadafile »

how is that done? can somone help......


why is it giving me that error
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Uploading files with "%" not working

Post by social_experiment »

For each argument you supply you need a conversion specification (%s). The error is probably triggered because the % in the filename is seen as another conversion specification for which you don't supply an argument.

How do you use the files within the context of this script, user profile photos, etc?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply