herghost Posted April 27, 2009 Share Posted April 27, 2009 Can any one spot my parse error?? <?php session_start(); $errmsg_arr = array(); $errflag = false; function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } $userid = $_SESSION['SESS_USERID']; $albumname = clean($_POST['albumname']); $tracks = clean($_POST['tracks']); { $qry = "INSERT INTO banddisco (userid, albumno, albumname, tracks) VALUES ('$userid', '', '$albumname', '$tracks')"; } $result = mysql_query($qry) or die(mysql_error()); $fields = array('albumname'); foreach($fields as $var) { if(isset($_POST[$var])) $_SESSION[$var] = $_POST[$var]; } $userid = $_SESSION['SESS_USERID']; $albumname = $_SESSION['albumname']; if(isset($_POST['submit'])){ if (isset ($_FILES['new_image'])){ $file_name = $_FILES['new_image']['name']; $getExt = explode ('.', $file_name); $file_ext = $getExt[count($getExt)-1]; $allowed_ext = "|jpg|png|gif|jpeg|svg|bmp|"; if (strpos($allowed_ext, "|".strtolower($file_ext)."|")===false) die("Extension: $file_ext is not allowed!"); $imagename = "$albumname"; $source = $_FILES['new_image']['tmp_name']; $target = "C:/wamp/www/fanjunky/users/$userid/$imagename"; move_uploaded_file($source, $target); $imagepath = $imagename; $save = "C:/wamp/www/fanjunky/users/$userid/$imagepath"; $file = "C:/wamp/www/fanjunky/temp/$userid"; if($result) { header("location: ../member_home.php?disco=1"); exit(); }else { die(mysql_error()); } ?> Showing on line 76 which is the last line. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/155766-help-my-tired-eyes/ Share on other sites More sharing options...
premiso Posted April 27, 2009 Share Posted April 27, 2009 It would help posting the actual error message. Quote Link to comment https://forums.phpfreaks.com/topic/155766-help-my-tired-eyes/#findComment-819940 Share on other sites More sharing options...
herghost Posted April 27, 2009 Author Share Posted April 27, 2009 Parse error: parse error in C:\wamp\www\fanjunky\do\banddiscodo.php on line 76 Sorry, thought I had explained that Quote Link to comment https://forums.phpfreaks.com/topic/155766-help-my-tired-eyes/#findComment-819943 Share on other sites More sharing options...
premiso Posted April 27, 2009 Share Posted April 27, 2009 I am not sure what program you are using to write this code, but if there is an option to convert spaces to tab, I would do it. As that code is a mess. I properly indented the code and commented where the errors were. <?php session_start(); $errmsg_arr = array(); $errflag = false; function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } $userid = $_SESSION['SESS_USERID']; $albumname = clean($_POST['albumname']); $tracks = clean($_POST['tracks']); // { This is an error is it suppose to be an if statement? $qry = "INSERT INTO banddisco (userid, albumno, albumname, tracks) VALUES ('$userid', '', '$albumname', '$tracks')"; // } This is also an error $result = mysql_query($qry) or die(mysql_error()); $fields = array('albumname'); foreach($fields as $var) { if (isset($_POST[$var])) $_SESSION[$var] = $_POST[$var]; } $userid = $_SESSION['SESS_USERID']; $albumname = $_SESSION['albumname']; if (isset($_POST['submit'])) { if (isset($_FILES['new_image'])) { $file_name = $_FILES['new_image']['name']; $getExt = explode ('.', $file_name); $file_ext = $getExt[count($getExt)-1]; $allowed_ext = "|jpg|png|gif|jpeg|svg|bmp|"; if (strpos($allowed_ext, "|".strtolower($file_ext)."|")===false) die("Extension: $file_ext is not allowed!"); $imagename = "$albumname"; $source = $_FILES['new_image']['tmp_name']; $target = "C:/wamp/www/fanjunky/users/$userid/$imagename"; move_uploaded_file($source, $target); $imagepath = $imagename; $save = "C:/wamp/www/fanjunky/users/$userid/$imagepath"; $file = "C:/wamp/www/fanjunky/temp/$userid"; if($result) { header("location: ../member_home.php?disco=1"); exit(); }else { die(mysql_error()); } } // added to end the new_image if } // added to end the submit if ?> Quote Link to comment https://forums.phpfreaks.com/topic/155766-help-my-tired-eyes/#findComment-819945 Share on other sites More sharing options...
herghost Posted April 27, 2009 Author Share Posted April 27, 2009 Thanks, I am using dreamweaver and notepad++ guess having it open in both is messing with it slightly! Quote Link to comment https://forums.phpfreaks.com/topic/155766-help-my-tired-eyes/#findComment-819949 Share on other sites More sharing options...
herghost Posted April 27, 2009 Author Share Posted April 27, 2009 I know have this: <?php session_start(); include('../include/auth.php'); include('../include/database.php'); $errmsg_arr = array(); $errflag = false; function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } $userid = $_SESSION['SESS_USERID']; $albumname = clean($_POST['albumname']); $tracks = clean($_POST['tracks']); $qry = ("INSERT INTO banddisco (userid, albumno, albumname, tracks) VALUES ('$userid', '', '$albumname', '$tracks') "); $result = mysql_query($qry) or die(mysql_error()); $fields = array('albumname'); foreach($fields as $var) { if (isset($_POST[$var])) $_SESSION[$var] = $_POST[$var]; } $userid = $_SESSION['SESS_USERID']; $albumname = $_SESSION['albumname']; if (isset($_POST['submit'])) { if (isset($_FILES['new_image'])) { $file_name = $_FILES['new_image']['name']; $getExt = explode ('.', $file_name); $file_ext = $getExt[count($getExt)-1]; $allowed_ext = "|jpg|png|gif|jpeg|svg|bmp|"; if (strpos($allowed_ext, "|".strtolower($file_ext)."|")===false) die("Extension: $file_ext is not allowed!"); $imagename = "$albumname"; $source = $_FILES['new_image']['tmp_name']; $target = "C:/wamp/www/fanjunky/users/$userid/$imagename"; move_uploaded_file($source, $target); $imagepath = $imagename; $save = "C:/wamp/www/fanjunky/users/$userid/$imagepath"; $file = "C:/wamp/www/fanjunky/temp/$userid"; if($result) { header("location: ../member_home.php?disco=1"); exit(); }else { die(mysql_error()); } } } ?> Which inserts into the database but does not save the picture? I am just faced with a blank page, no error message Quote Link to comment https://forums.phpfreaks.com/topic/155766-help-my-tired-eyes/#findComment-819966 Share on other sites More sharing options...
premiso Posted April 27, 2009 Share Posted April 27, 2009 If the $userid directory does not exist, it cannot be moved to that directory. You need to check that it is a is_dir first if not you need to create the directory mkdir. Quote Link to comment https://forums.phpfreaks.com/topic/155766-help-my-tired-eyes/#findComment-819968 Share on other sites More sharing options...
herghost Posted April 27, 2009 Author Share Posted April 27, 2009 Hi mate, I now have this: <?php session_start(); include('../include/auth.php'); include('../include/database.php'); $errmsg_arr = array(); $errflag = false; function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } $userid = $_SESSION['SESS_USERID']; $albumname = clean($_POST['albumname']); $tracks = clean($_POST['tracks']); $qry = ("INSERT INTO banddisco (userid, albumno, albumname, tracks) VALUES ('$userid', '', '$albumname', '$tracks') "); $result = mysql_query($qry) or die(mysql_error()); $fields = array('albumname'); foreach($fields as $var) { if (isset($_POST[$var])) $_SESSION[$var] = $_POST[$var]; } $sql = "SELECT * FROM user WHERE userid = $userid"; $result = mysql_query($sql) or die(mysql_error()); if ($result) { while ($row = mysql_fetch_array($result)) { $userid = $row["userid"]; if (is_dir('users/'.$userid) == FALSE) { mkdir('../users/'.$userid); mkdir('../temp/'.$userid); } } } if (isset($_POST['submit'])) { if (isset($_FILES['new_image'])) { $file_name = $_FILES['new_image']['name']; $getExt = explode ('.', $file_name); $file_ext = $getExt[count($getExt)-1]; $allowed_ext = "|jpg|png|gif|jpeg|svg|bmp|"; if (strpos($allowed_ext, "|".strtolower($file_ext)."|")===false) die("Extension: $file_ext is not allowed!"); $imagename = "$albumname"; $source = $_FILES['new_image']['tmp_name']; $target = "C:/wamp/www/fanjunky/users/$userid/$imagename"; move_uploaded_file($source, $target); $imagepath = $imagename; $save = "C:/wamp/www/fanjunky/users/$userid/$imagepath"; $file = "C:/wamp/www/fanjunky/temp/$userid"; if($result) { header("location: ../member_home.php?disco=1"); exit(); }else { die(mysql_error()); } } } ?> However gives the error: Warning: mkdir() [function.mkdir]: File exists in C:\wamp\www\fanjunky\do\banddiscodo.php on line 40 Warning: mkdir() [function.mkdir]: File exists in C:\wamp\www\fanjunky\do\banddiscodo.php on line 41 Which is: mkdir('../users/'.$userid); mkdir('../temp/'.$userid); I am guessing I need an else statement but not sure what to put in it! Quote Link to comment https://forums.phpfreaks.com/topic/155766-help-my-tired-eyes/#findComment-820463 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.