Jump to content

almost making directories, but turns out other error


begeiste

Recommended Posts

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 [b]table called 'category' [/b] which has [b]id,name, thumb,dir [/b] 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.

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

[code]<!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>[/code]
Link to comment
Share on other sites

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

[B]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
[/B]


[code]<!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>[/code]
Link to comment
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.