Jump to content


Photo

almost making directories, but turns out other error


  • Please log in to reply
4 replies to this topic

#1 begeiste

begeiste
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 04 August 2006 - 10:12 PM

Hi
It took me ages to making directories which contain photos, user can click on the specific name of directory link to view their photos.Basically there is a table called 'category' which has id,name, thumb,dir four field. I have put the dir in the page as hidden element.  But it almost makes that worked, it turns out the error which don't know how to fix, can someone in this forum help me out, thanks so much.

Parse error: parse error in c:\program files\easyphp1-8\www\gardenclub\admin\newdir.php on line 81

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<ul>
<?php if(isset($_POST['name'])){

//database name
$db="gardenclub";
//connect to the database server
$dbcnx =@mysql_connect('localhost', 'root', '');
if(!$dbcnx){
exit('<p>Unable to connect to the database'.'server at the time.</p>');
}
//select the gallery database
if(!@mysql_select_db('gardenclub')){
exit('<p>Unable to locate the gardenclub'.'database at the time.</p>');
}

//adding record 
if($_FILES['thumb']['name']!="")
$_POST[thumb]=$_FILES['thumb']['name'];

//choose wether to update or create new row
if(mysql_query("SELECT id, name FROM category WHERE id='$id'", $dbcnx))
{
 $remove=array('id','save','dir');
 update("$db.category","id='$id'");
 $dir=$_POST[dir]; 
}
else
{

//image directory name
$dir=$name.rand(1,100);
$dir=str_replace("","_",$dir);
    $_POST[dir]=$dir;

//creates artist directory
mkdir("../media/".$dir,0777);
$_POST[dir]=$dir;
//selecting all added directories, querying the statement
$directory = @mysql_query("SELECT id, name FROM category WHERE id='$id'");
if (!$directory){
exit('<p>Error performing query:'. mysql_error(). '</p>');
}
//displaying the name of directories in the list
while($dir = mysql_fetch_array($directory)){
$id = $dir['id'];
$name = htmlspecialchars($dir['name']);
echo"<li><a href='detail_directory.php?id=$id'>$name</a></li>";
}
//uploads thumbail
if($_FILES['thumb']['name']!="")
{
//check is image is uploaded and move it to the images folder
if(!move_uploaded_file($_FILES['thumb']['tmp_name'],"../media/$dir/Thumb.jpg"))
$message="Couldn't upload image";

//choose the image height
$scale="-geometry '118x135>'";

//image save path
$newThum="../media/$dir/Thumb.jpg  ../media/$dir/Thumb.jpg";

//imagemagick command format
$command = "/usr/local/bin/convert $scale $newThum";

//execute command
'$command';
}
}
}
?>
</ul>
<p><a href="<?php echo $_SERVER['../PHP_SELF']; ?>">Add anthor directory</a></p>
<p><a href="../directory.php">Return to directory list</a></p>
<?php else:// allow the user to enter a new directory ?>

<form method="post" name="form1">
<input type="hidden" name="dir" value="<?php echo $directory[dir]; ?>">
  <table align="center">
    <tr valign="baseline">
      <td nowrap align="right">Name:</td>
      <td><input type="text" name="name" value="" size="32"></td>
    </tr>
    <tr>
<td>Thumb:</td>
<td><input type="file" name="thumb" value="" size="9" /></td>
</tr>
    <tr valign="baseline">
      <td nowrap align="right">&nbsp;</td>
      <td><input type="submit" value="save"></td>
    </tr>
  </table>
  <input type="hidden" name="MM_insert" value="form1">
</form>
<?php endif;?>
</body>
</html>


#2 ronverdonk

ronverdonk
  • Members
  • PipPipPip
  • Advanced Member
  • 277 posts
  • LocationNetherlands

Posted 04 August 2006 - 10:14 PM

Do I have to count up to line 81, or are you going to tell me?

RTFM is an almost extinct art form, it should be subsidized.

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 04 August 2006 - 10:15 PM

show line 81 please cheers.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 04 August 2006 - 10:25 PM

Theres a open { brace missing on one of your if statement ok.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 begeiste

begeiste
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 05 August 2006 - 12:47 AM

I have fixed the error on Line 81, it runs but it is still not working. Please would you help me.

Notice: Undefined index: thumb in c:\program files\easyphp1-8\www\gardenclub\admin\newdir.php on line 24

Notice: Undefined variable: id in c:\program files\easyphp1-8\www\gardenclub\admin\newdir.php on line 28

Notice: Use of undefined constant dir - assumed 'dir' in c:\program files\easyphp1-8\www\gardenclub\admin\newdir.php on line 31



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<ul>
<?php if(isset($_POST['name'])):

	//database name
	$db="gardenclub";
	//connect to the database server
	$dbcnx =@mysql_connect('localhost', 'root', '');
	if(!$dbcnx){
		exit('<p>Unable to connect to the database'.'server at the time.</p>');
		}
	//select the gallery database
	if(!@mysql_select_db('gardenclub')){
		exit('<p>Unable to locate the gardenclub'.'database at the time.</p>');
		}
	
	//adding record 
	if($_FILES['thumb']['name']!="")
			$_POST[thumb]=$_FILES['thumb']['name'];
			
	//choose wether to update or create new row	
	if(mysql_query("SELECT id, name, thumb FROM category WHERE id='$id'", $dbcnx))
		{
		
		 $dir=$_POST[dir]; 
		}
	else
	{
		
	//image directory name
		$dir=$name.rand(1,100);
		$dir=str_replace("","_",$dir);
	    $_POST[dir]=$dir;

	//creates artist directory
		mkdir("../media/".$dir,0777);
		$_POST[dir]=$dir;	
	//selecting all added directories, querying the statement
		$directory = @mysql_query("SELECT id, name, thumb FROM category WHERE id='$id'");
		if (!$directory){
			exit('<p>Error performing query:'. mysql_error(). '</p>');
			}
	//displaying the name of directories in the list
		while($dir = mysql_fetch_array($directory)){
			$id = $dir['id'];
			$name = htmlspecialchars($dir['name']);
			echo"<li><a href='detail_directory.php?id=$id'>$name</a></li>";
			}
	//uploads thumbail
	if($_FILES['thumb']['name']!="")
		{
		//check is image is uploaded and move it to the images folder
		if(!move_uploaded_file($_FILES['thumb']['tmp_name'],"../media/$dir/Thumb.jpg"))
			$message="Couldn't upload image";
			
		//choose the image height
		$scale="-geometry '118x135>'";
		
		//image save path
		$newThum="../media/$dir/Thumb.jpg  ../media/$dir/Thumb.jpg";
		
		//imagemagick command format
		$command = "/usr/local/bin/convert $scale $newThum";
		
		//execute command
		'$command';
		}
	}
	
		?>
	</ul>
	<p><a href="<?php echo $_SERVER['../PHP_SELF']; ?>">Add anthor directory</a></p>
	<p><a href="../directory.php">Return to directory list</a></p>
<?php else:// allow the user to enter a new directory ?>
	
<form method="post" name="form1">
<input type="hidden" name="dir" value="<?php echo $directory[dir]; ?>">
  <table align="center">
    <tr valign="baseline">
      <td nowrap align="right">Name:</td>
      <td><input type="text" name="name" value="" size="32"></td>
    </tr>
    <tr>
			<td>Thumb:</td>
			<td><input type="file" name="thumb" value="" size="9" /></td>
		</tr>
    <tr valign="baseline">
      <td nowrap align="right">&nbsp;</td>
      <td><input type="submit" value="save"></td>
    </tr>
  </table>
  <input type="hidden" name="MM_insert" value="form1">
</form>
<?php endif;?>
</body>
</html>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users