Page 1 of 3
Shout Box help
Posted: Tue Apr 19, 2005 2:33 pm
by Smackie
alright i finally made a shout box with a uploader so the admin can add new smilies alright and i keep getting this error when i try adding a smiley faces and stuff
Warning: move_uploaded_file(smilies/wink.png): failed to open stream: Permission denied in /home/smackie/public_html/Chat/admin.php on line 81
Warning: move_uploaded_file(): Unable to move '/tmp/php05o5wy' to 'smilies/wink.png' in /home/smackie/public_html/Chat/admin.php on line 81
ErrorArray
(
[image] => Array
(
[name] => wink.png
[type] => application/octet-stream
[tmp_name] => /tmp/php05o5wy
[error] => 0
[size] => 0
)
)
Can someone tell me what is going wrong?
Thank you
Smackie
Posted: Tue Apr 19, 2005 2:35 pm
by feyd
size: zero bytes. There's no file to create.
Sounds like you aren't allowed to write to smilies either.. which is a permissions thing. 0757 is used often, if I remember correctly.
Posted: Tue Apr 19, 2005 2:39 pm
by Smackie
still giving me the same thing

i had the permissions at 777 and at 757 and still it doesnt work

Posted: Tue Apr 19, 2005 2:53 pm
by Smackie
Never mind i finally fixed it

thank you for your help anyways

Posted: Tue Apr 19, 2005 2:53 pm
by feyd
size still zero?
Posted: Tue Apr 19, 2005 3:07 pm
by Smackie
no i had to make a subdirectory named smilies and make the permissions 777 but i got a new problem i add the smilies and all i get is like a img but with the x in it and i dont know what the problem is...
Posted: Tue Apr 19, 2005 3:32 pm
by feyd
kinda hard to help if we can't see your code...
Posted: Tue Apr 19, 2005 3:41 pm
by Smackie
here is the codes for adding and deleting the smilies and on deleting them is where it shows the pictuers to see if its there and it shows like a img but not working right with the x in it..
Code: Select all
<?php
// calling session_start() the function which starts our authentication session
session_start();
// connecting to mysql server
$l = mysql_connect ( "localhost" , "smackie" , "****" ) or die("Error connecting:<BR><BR>".mysql_error());
mysql_select_db( "smackie_Chat" ) or die("Error getting db:<BR><BR>".mysql_error());
// setting user login credentials
$username = "Smackie";
$password = "********";
// log the user in
if ( isset ( $_POST['login'] ) )
{
if (( $_POST['username'] === $username ) && ( $_POST['password'] === $password ))
{
$_SESSION['admin_logged_in'] = 'true';
}
}
// selecting the action to perform
function selectAction ( $mode )
{
switch ($mode)
{
case '':
echo 'Welcome to the administration panel, make the selection above.';
break;
case 'add':
echo '
<form action="admin.php?mode=posting" method="post" name="addSmilie" enctype="multipart/form-data">
<input name="symbol" type="text" value="=)" size="25" maxlength="4"><br>
<input name="image" type="file"><br>
<input name="addsmilie" type="submit" value="Add Smilie!"><br><br>
Check your symbol and filename, I couldnt be bothered writing an "edit smilie" function. Please note, as this is not a gdlib tutorial, there are no file dimensions protections. Please only upload 30x30 pixel smilies, if they are not this size, they will be skewed when they are resized when displayed.
</form>
';
break;
case 'delete':
$query = mysql_query("SELECT * FROM smilies") or die(mysql_error());
while($row = mysql_fetch_array($query)){
echo '<a href="admin.php?mode=posting&smilie='.$row['id'].'">
<img src="smilies/'.$row['URL'].'" border="0" width="50" height="50" alt="'.$row['Alt'].'">
</a><br><br>
';
}
break;
case 'clear':
mysql_query("TRUNCATE TABLE shouts") or die(mysql_error());
echo 'Shoutbox cleared successfully!';
break;
case 'logout':
$_SESSION['admin_logged_in'] = '';
header("Location: admin.php");
break;
case 'posting':
if(isset($_POST['addsmilie'])){
$uploaddir = 'smilies/';
$uploadfile = $uploaddir . $_FILES['image']['name'];
//echo '<br><br>'.$uploaddir.'<br>'.$uploadfile.'<br><br>';
$upload = move_uploaded_file($_FILES['image']['tmp_name'], $uploadfile);
echo '<pre>';
if( $upload == TRUE ) {
echo 'Success';
} else {
echo 'Error';
print_r($_FILES);
exit;
}
print "</pre>";
$alt = $_FILES['image']['name'];
$symbol = $_POST['symbol'];
$url = $_FILES['image']['name'];
mysql_query("INSERT INTO smilies(Symbol, URL, Alt) VALUES('$symbol','$url','$alt')") or die(mysql_error());
echo '<br><br>Successfully inserted smilie!<br><br><a href="admin.php">Admin</a> | <a href="shout.php">Shouts</a>';
exit;
}
if(isset($_GET['smilie'])){
$smilie = $_GET['smilie'];
mysql_query("DELETE FROM smilies WHERE id = '$smilie' LIMIT 1") or die(mysql_error());
echo 'Successfully deleted smilie!<br><br><a href="admin.php">Admin</a> | <a href="shout.php">Shouts</a>';
}
break;
default:
} // end switch
} // end if
// checking login status
if ( $_SESSION['admin_logged_in'] === 'true' )
{
?>
<html>
<head>
<title>Shoutbox Administration</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p>Smilie administration: <a href="admin.php?mode=add">add smilie</a> | <a href="admin.php?mode=delete">delete smilie</a></p>
<p>Shoutbox administration: <a href="admin.php?mode=clear">clear shoutbox</a> | <a href="admin.php?mode=logout">logout</a></p>
<table width="600" border="1" cellpadding="5" bordercolor="#CCCCCC">
<tr>
<td><?php selectAction($_GET['mode']); ?></td>
</tr>
</table>
</body>
</html>
<?php
// showing login form
} else {
echo '
<form action="admin.php" method="post" name="login">
<input name="username" type="text" value="username" size="25" maxlength="32"><br>
<input name="password" type="password" value="password" size="25" maxlength="32"><br>
<input name="login" type="submit" value="login">
</form>
';
}
mysql_close($l);
?>
Posted: Tue Apr 19, 2005 3:50 pm
by feyd
are you positive that the url's being used are correct?
Posted: Tue Apr 19, 2005 3:55 pm
by Smackie
yeah it uploads and everything and i can go to the sub-directory and see the image but it doesnt show in the delete page or when i put it in the shout box..
Posted: Tue Apr 19, 2005 4:01 pm
by feyd
I'm talking about the final img tags.. are you sure the URL they are using for source (src) is correct?
Posted: Tue Apr 19, 2005 4:06 pm
by Smackie
you mean this part?
$uploaddir = 'smilies/';
Posted: Tue Apr 19, 2005 4:09 pm
by feyd
Monday, huh?
the output from line 53 through 55. Verify those are the correct URLs.
Posted: Tue Apr 19, 2005 4:17 pm
by Smackie
yeah they are as i can see

Posted: Tue Apr 19, 2005 7:32 pm
by hongco
right click on the area that suppose to show the image --> select property, and see if the img's url is correct.