I have been working on this file for over 5 hours and i finaly got it all completed but now i am getting this messsage any ideas? The underlined code is the problem and i don' know how to fix it. <?php //Start session session_start(); //Include database connection details require_once('config.php'); //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } //Function to sanitize values received from the form. Prevents SQL injection function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } Please help
The error lies in the first lines of config.php, not the code you posted. It would be helpful if you can post your config file (removing sensitive information) and more information on your PHP version (useful in the event your config.php contains classes).
<?php define('DB_HOST', 'localhost'); define('DB_USER', ''); define('DB_PASSWORD', ''); define('DB_DATABASE', '); ?>
This part is missing an apostrophe: define('DB_DATABASE', '); should be define('DB_DATABASE', ''); Did that solve your problem?
Unfortunatly no it was is the same of what u have put as you have put the ' must of gotten deleted in the detion of the inportant data. Any others ideas. Once i gfet this to work i can apply it to my other uses for it 2 but i can't get ti to work
Mod_Upload.php ==================================== <?php //Start session session_start(); //Include database connection details require_once('config.php'); //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } //Function to sanitize values received from the form. Prevents SQL injection function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } ?> ==================================== config.php ============================ <?php define('DB_HOST', 'db_host'); define('DB_USER', 'db_user'); define('DB_PASSWORD', 'db_pass'); define('DB_DATABASE', 'db_name'); ?> =================================== replace db credentials in config.php with your credentials and it will work. Enjoy
Hey guys its me again i go teh 1st part working but now i getting Parse error: syntax error, unexpected $end in Mod_Upload.php on line 96. Any ideas? code is below it follows on from what i 1st posted if(isset($_POST['upload']) && $_FILES['Mod_ID']['size'] > 0) { //Sanitize the POST Values $Mod_Name = clean($_POST['Mod_Name']); $member_id = clean ($_POST['member_id']); $Description = clean ($_POST['Description']); $Date_Added = clean ($_POST['Date_Added']); $Date_Modified = clean ($_POST['Date_Modified']); $Image_ID = clean ($_POST['Image_ID']); $fileName = $_FILES['Mod_ID']['name']; $tmpName = $_FILES['Mod_ID']['tmp_name']; $fileSize = $_FILES['Mod_ID']['size']; $fileType = $_FILES['Mod_ID']['type']; $binary_date = addslashes(fread(fopen($Image_ID, "r"), filesize($Image_ID))); //Validations if($Mod_Name ==''){ $errmsg_arr[] = 'Mod Name Missing'; $errflag = true; } if($Description ==''){ $errmsg_arr[] = 'Description Missing'; $errflag = true; } if($Image_ID ==''){ $errmsg_arr[] = 'Please select the mod image to upload'; $errflag = true; } if($Mod_ID ==''){ $errmsg_arr[] = 'Please select an mod to upload'; $errflag = true; } //If there a input validations, redirect back to the reqistration form if($errmflag){ $_SESSION['ERRMSG_ARR'] = $errmsg_arr; session_write_close(); header("location: Supreme_Commander_Upload.php"); exit(); } //Insert Query $qry = "INSERT INTO mod(Mod_Name, member_id, Description, Date_Added, Date_Modified) Values('$Mod_Name','$member_id','$Description','$Date_Added','$Date_Modified')"; "INSERT INTO mod_file(name, filesize, type, binary_date ) VALUES ('$fileName', '$fileSize', '$fileType', '$content')"; "INSERT INTO mod_images VALUES ('','$binary_data','$Image_ID_name','$Image_ID_size','$Image_ID_type')"; $result = @mysql_query($gry); //Check whether the query was successful or failed if($result) { header("location: Mod_Success.php"); exit(); }else { die("Query failed"); } ?>
ok now this is weird i am just getting a blank sceen theres no data gone in mysql and theres no error file to be seen.
if(isset($_POST['upload']) && $_FILES['Mod_ID']['size'] > 0) all your actions trigger if there is a filed name called "upload" sent via POST and also a file size > 0 if above conditions are not met .. you will receive blank screen to see that for yourself do this: replace this: ?> with this: else echo 'nothing done because either no post request of file size greater than 0'; ?>
now i am getting Parse error: syntax error, unexpected T_STRING in /home/reddev32/public_html/Vault/supremecommander/Mod_Upload.php on line 90