Page 1 of 1

problems with submitting form

Posted: Sat Jan 03, 2004 9:07 am
by dakkonz
i dunno why this script does not work for my database......can anyone give me any help??
once i click submit i only get back this page... with the error "You could not be upload due to a system error. We apologize for any inconvenience"



Code: Select all

<?php # Script 11.7 - add_file.php
// This page allows users to upload files to the server.

// Set the page title and include the HTML header.
$page_title = 'Upload a File';


if (isset($_POST&#1111;'submit'])) &#123; // Handle the form.

	require_once ('../mysql_connect.php'); // Connect to the database.


	// Check for a description (not required).
	if (!empty($_POST&#1111;'description'])) &#123;
		$d = escape_data($_POST&#1111;'description']);
	&#125; else &#123;
		$d = '';
	&#125;
echo "hello";
	// Add the record to the database.
			$query = "INSERT INTO song (filename, describe) VALUES ('&#123;$_FILES&#1111;'upload']&#1111;'name']&#125;', '$d')";		
			$result = @mysql_query ($query); // Run the query.

			if ($result) &#123; // If it ran OK.

				echo '<h3>Thank you for upload!</h3>';
	
				exit();				
				
			&#125; else &#123; // If it did not run OK.
				// Send a message to the error log, if desired.
				echo '<p><font color="red" size="+1">You could not be upload due to a system error. We apologize for any inconvenience.</font></p>'; 
			&#125;	

	mysql_close(); // Close the database connection.

&#125; // End of the main Submit conditional.
?>

<form enctype="multipart/form-data" action="<?php echo $_SERVER&#1111;'PHP_SELF']; ?>" method="post">

<input type="hidden" name="MAX_FILE_SIZE" value="524288">

<fieldset><legend>Fill out the form to upload a file:</legend>

<p><b>File:</b> <input type="file" name="upload" /></p>

<p><b>Description:</b> <textarea name="description" cols="40" rows="5"></textarea></p>

</fieldset>

<div align="center"><input type="submit" name="submit" value="Submit" /></div>

</form><!-- End of Form -->


These is the specs

Code: Select all

<?php 
echo '<pre>'; 
echo 'PHP Version: '.phpversion()."\n"; 
echo 'Display Errors: '.(ini_get('display_errors') == '1' ? 'On' : 'Off')."\n"; 
echo 'Error Level: '.(ini_get('error_reporting') == '2047' ? 'E_ALL' : 'Not E_ALL')."\n"; 
echo 'Register Globals: '.(ini_get('register_globals') == '' ? 'Off' : 'On')."\n"; 
echo '</pre>'; 

/* 
PHP Version: 4.3.2
Display Errors: On
Error Level: Not E_ALL
Register Globals: On
*/ 
?>

Posted: Sat Jan 03, 2004 9:31 am
by JAM

Code: Select all

// Replace:
        $result = @mysql_query ($query); // Run the query. 
// With:
        $result = mysql_query ($query) or die("Invalid query: " . mysql_error());
Get any different error messages?

Posted: Sat Jan 03, 2004 10:10 am
by dakkonz
got this msg
"helloInvalid query: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'describe) VALUES ('eyes.mp3', 'bvcxbvc')' at line 1"
instead

Posted: Sat Jan 03, 2004 10:16 am
by JAM
So the error lies arond those parts...

Code: Select all

// From
$query = "INSERT INTO song (filename, describe) VALUES ('{$_FILES['upload']['name']}', '$d')";
// To
$query = "INSERT INTO song (filename, describe) VALUES ('{$_FILES[upload][name]}', '$d')";
A shot in the dark... If that wont help, at least you have a better idea of where to look.

Posted: Sat Jan 03, 2004 10:19 am
by dakkonz
okie thanks.... is there a possible of any problem with my db configuration causing this problem??