Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/155766-help-my-tired-eyes/
Share on other sites

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
?>

Link to comment
https://forums.phpfreaks.com/topic/155766-help-my-tired-eyes/#findComment-819945
Share on other sites

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

 

Link to comment
https://forums.phpfreaks.com/topic/155766-help-my-tired-eyes/#findComment-819966
Share on other sites

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!

Link to comment
https://forums.phpfreaks.com/topic/155766-help-my-tired-eyes/#findComment-820463
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.