xanie Posted January 10, 2013 Share Posted January 10, 2013 <?php include('../config/db.php') if(isset($_POST['submit'])) { $title = $_POST['title']; $details = $_POST['details']; $date = $_POST['date_from']; $image = $_POST['image']; if(!empty($_FILES['image']['name'])) { $fileName = $_FILES['image']['name']; $tmpName = $_FILES['image']['tmp_name']; $fileSize = $_FILES['image']['size']; $fileType = $_FILES['image']['type']; $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } } else { $content = "NULL"; $fileName = "NULL"; $fileType = "NULL"; } cdv $date = date('Y-m-d', strtotime($date)); // outputs 2006-01-24 mysql_query("INSERT INTO newsandevents (date, details, title, photo, photo_name, photo_file_type) VALUES (''Now(), '$ddetails', '$title' ,'$content', '$fileName', '$fileType')") or die(mysql_error()); header('location:News.php'); } print '<script type="text/javascript">'; print 'alert("Successfully added!")'; print '</script>'; ?> thanks.. Link to comment Share on other sites More sharing options...
thara Posted January 10, 2013 Share Posted January 10, 2013 please post your code using code tags. You can do this it using the <> button in the editor which you use to ask questions and post reply. Link to comment Share on other sites More sharing options...
Muddy_Funster Posted January 10, 2013 Share Posted January 10, 2013 you didn't put the ; at the end of the include line just before the IF. thus you didn't terminate the line and PHP was taken unaware when it fame up against the IF. Link to comment Share on other sites More sharing options...
xanie Posted January 11, 2013 Author Share Posted January 11, 2013 <?php include('../config/db.php'); if(isset($_POST['submit'])) { $title = $_POST['title']; $details = $_POST['details']; $date = $_POST['date_from']; $image = $_POST['image']; if(!empty($_FILES['image']['name'])) { $fileName = $_FILES['image']['name']; $tmpName = $_FILES['image']['tmp_name']; $fileSize = $_FILES['image']['size']; $fileType = $_FILES['image']['type']; $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } } else { $content = "NULL"; $fileName = "NULL"; $fileType = "NULL"; } cdv $date = date('Y-m-d', strtotime($date)); // outputs 2006-01-24 mysql_query("INSERT INTO newsandevents (date, details, title, photo, photo_name, photo_file_type) VALUES (''Now(), '$ddetails', '$title' ,'$content', '$fileName', '$fileType')") or die(mysql_error()); header('location:News.php'); } print '<script type="text/javascript">'; print 'alert("Successfully added!")'; print '</script>'; ?> Link to comment Share on other sites More sharing options...
haku Posted January 11, 2013 Share Posted January 11, 2013 Are you showing us working code for reference, or asking for more help? If you are showing us working code, saying so would be nice, and you should mark the topic 'solved'. If you are asking for more help, then showing us a bunch of code without any errors or comments isn't going to get you any help. Link to comment Share on other sites More sharing options...
xanie Posted January 11, 2013 Author Share Posted January 11, 2013 Are you showing us working code for reference, or asking for more help? If you are showing us working code, saying so would be nice, and you should mark the topic 'solved'. If you are asking for more help, then showing us a bunch of code without any errors or comments isn't going to get you any help. i'm asking for help. Someone told me to post the whole code and i forgot to put some comment on it. Link to comment Share on other sites More sharing options...
Christian F. Posted January 11, 2013 Share Posted January 11, 2013 Don't start two thread on the same problem: http://forums.phpfreaks.com/topic/272934-parse-errorsyntax-errorunexpected-if-t-if/#entry1404836 Link to comment Share on other sites More sharing options...
Recommended Posts