Jump to content

Matpatnik

Members
  • Posts

    227
  • Joined

  • Last visited

Posts posted by Matpatnik

  1. Hi guys I got this error now:

    Warning: move_uploaded_file(../images/6) [function.move-uploaded-file]: failed to open stream: Is a directory in /usr/local/1/2/3/4/5/6/age.php on line 40Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phprgnmcn' to '../images/6' in /usr/local/1/2/3/4/5/6/age.php on line 40
    I think I know where the error come from, it's the (../) which it doesn't like. How do you set the path to go out of the folder?Like when you are in mysite.com/images/something/here.php and want to go back to mysite.com/.In html it's easy it's just ../ to go back to the root folder but how is it done with php (if it's the error)
  2. I do the same but I only do that for variable and function that might be reused in other page. All other variable and function stay in there own page.I'm still looking on how to set the structure of the site and I'm getting closer every time :)

  3. true it's define just after the validation, is there a way to bypass this or I will have to write the function that define the $a_maxsize in every page? because in that function $a_maxsize is a global variable.edited: I changed where the function was called and it seems to be ok now.Thank you

  4. You probably mean this: :)

    echo "<pre>";echo $i_size . "\n";var_dump($i_size);echo "\n" . $a_maxsize . "\n";var_dump($a_maxsize);echo "</pre>";

    I figured that you did it very quickly :)there is the result

    82float(82)NULLWater lilies.jpg
    Why $a_maxsize doesn't appear in the if statement and appear few line after?
  5. here this is from the server:

    $i_temp = $_FILES['image_filename']['name'];$i_size = round($_FILES['image_filename']['size'] / 1024);	// make sure no one upload over the maximum sizeif (floatval($i_size) > floatval($a_maxsize)) {	include "include/header.php";	echo "The " . $i_temp . " size is " . $i_size . " kb but the maximum upload size is " . $a_maxsize ." kb.<br>" .		 "Your image is too big by " . ($i_size - $a_maxsize) . " kb. Please reduce the size of that image and try again.";	getfooter($connect);} else {

    It's the first statement after the users validation

  6. It doesn't do anthing special only the same message:

    The Water lilies.jpg size is 82 kb but the maximum upload size is 100 kb.Your image is too big by -18 kb. Please reduce the size of that image and try again.
  7. now that's weird with this code:

    // make sure no one upload over the maximum sizeif ($i_size > $a_maxsize) {	include "include/header.php";	echo "The " . $i_temp . " size is " . $i_size . " kb but the maximum upload size is " . $a_maxsize ." kb.<br>" .		 "Your image is too big by " . ($i_size - $a_maxsize) . " kb. Please reduce the size of that image and try again.";	getfooter($ect);

    I got this output!

    The Water lilies.jpg size is 82 kb but the maximum upload size is 100 kb.Your image is too big by -18 kb. Please reduce the size of that image and try again.
    I don't know what to think about this because it does the calculation now but doesn't respect the if statement!Both variable in the if statement are fine and work properly as it show in the output but it's not supose to echo that because it's smaller so it should skip that part. I don't know if the fact that $a_maxsize is comming from the database change something?Out of subject I got this error very often went going on your site
     The server closed the connection while reading the response. Contact your system administrator.
  8. I use this to redirect user

    header("Refresh: 5; URL=your_url");	echo "You are being redirected to the page...!<br>";	echo "(If your browser doesn't support this, " .		 "<a href=\"your_url\">click here</a>)";	die();

  9. Hi guys,I have this little variable that doesn't show up:

    $i_size = round($_FILES['image_filename']['size'] / 1024);

    I'm trying to echo the $i_size it doesn't work, I tried to echo $i_size without the round() nothing show up and when I echo $_FILES['image_filename']['size'] alone it work!it used to work to control the file size uploadedthank you

  10. I just realized something, I can't call a variable if the variable isn't define before being include so I change the way the files where include and it work perfectly now.Now mainpage.php include page2.php and page2.php include page1.php (page2.php and page3.php are now in the same page: page2.php)I'm shearing my discovery :)edited:

    If I am understanding you correctly, add session_start() at the beginning.
    the sesion_start() is there I just didn't show it in there.I find the solution thank you
  11. Hi guys,I got this code which is working fine in one part of the page on the other part it doesn't recognize me!in that page it can look like that:page1.php

    function adminRestriction() {	global $a_maxsize, $a_master;	$admin_sql = "SELECT * FROM administration";	$admin_result = mysql_query($admin_sql)		or die("Invalid query: " . mysql_error());	$row = mysql_fetch_array($admin_result);	$a_maxsize =  $row['admin_maxupload'];	$a_master = $row['admin_master'];}// this is where I allow the $a_masterinclude "page2.php";

    page2.php

    // only html code except the includeinclude "page3.php";

    page3.php

    // only html code except this <?phpadminRestriction();if ($_SESSION['user_logged'] == $a_master) {	echo $admin_master;} else {	echo "<td>" . $a_master . "<td>";}// $a_master doesn't work?>

    And the page1.php get include in the mainpage.php everything called from the adminReatriction function in the mainpage.php work fine except in the page3.php it can't find it!I know that I include a lot of page, can it be the problem?Thank you for your helpMat

  12. A more portable way around this is to use & instead of & as the separator. You don't need to change PHP's arg_separator for this. Leave it as &, but simply encode your URLs using htmlentities() or htmlspecialchars().
    Wow, I didnt know that you can use & in the url but probably every commune browser support & in the url.I have EI, Netscape, FF and Opera and never had problem with that. Maybe it's a good thing to start considering the & in the urlThank you justsomeguy
  13. Exactly. I can't remember the specifics, but the reason has something to do with XML, the ampersand is a control character or something along those lines, I can't remember specifically. But yeah, even when you encode it, there's still an ampersand there. But for whatever reason if the string "amp;" follows the ampersand, now all of a sudden it's valid. Like I said, I don't really understand the logic, but that's what the spec says.
    Yup & open a special character in xhtml like $ open a variable for phpbut I think we are getting out of the subject here.what's the difference about & and ; in the urldo they do the exact same thing?can I use either one?
  14. I have a question that start bugging me, maybe it's a stupid question but hey! I'll survive :) What is the difference between "elseif" and "else if"?To me it does the same thing but I'm sure there is a difference between both of them. In few book of php they write "else if" and some other book (and in w3schools) they write "elseif"!Is one is newer or deprecated?What is the best one to stick with it?

  15. ok good :) thxedited: I moved the chmod() after the creation of the picture like you said and now it work perfectly :)

    				imagejpeg($image_jpg, $newfilename);				imagedestroy($image_old);				imagedestroy($image_jpg);			}			chmod($newfilename, 0644);

  16. I'm gonna turn off the safe mode and see if the chmod() work* by the way did I insert the chmod() at the right place?I wont need your code right now but I will surely use it later on in my project :) Thank you

  17. Hi.. First see the folder's owner or file's owner which you have create is same as other.. and if yes then that owner has given permission to change the file mode.. If yes then and then we can go for chmod().. otherwise we have to hosting server people to give permission that owner to write and execute..Reagards,Vijay
    I'm not sure to understand about the folder permission. I rent the server (well I payed for few years), the folder test/images/ permission is set to 777, the test is set to 775 and the thumbs is set to 755. Is it what you've ask? :)
  18. I've insert the chmod($newfilename, 0644); in between the imagejpeg($image_jpg, $newfilename); and imagedestroy($image_old); and it doesn't work. Do I have to call the function before?edited: Do you think, because I rename the file it change the permission because my thumbnails are auto generated lower in this code and there permission are fine they are set to 644 like they are suppose to be. I'm trying to understand why it does this.

  19. Hi guys,I have this issue now: With my testing server it was fine but it's an other thing with the website server. When a file is uploaded into the images/ folder it write the 600 permission automatically. What is the best way to set the permission to 644 within this code?

    	// upload image and check for image type	if (move_uploaded_file($_FILES['image_filename']['tmp_name'], $ImageName)) {		// get info about the image being uploaded		list($width, $height, $type, $attr) = getimagesize($ImageName);				if ($type > 3) {			echo "Sorry, but the file you uploaded was not a GIF, JPG, or PNG file.<br>";			echo "Please hit your browser's 'back' button and try again.";		} else {			// image is acceptable; ok proceed					// insert info into image table			$insert = "INSERT INTO images				   (images_caption, images_username, images_date)				   VALUES				   ('$image_caption', '$image_username', '$today')";			$insertresult = mysql_query($insert)				or die(mysql_error());					// get the last mysql insert id			$lastpicid = mysql_insert_id();					$newfilename = $ImageDir . $lastpicid . ".jpg";						if ($type == 2) {				rename($ImageName, $newfilename);			} else {				if ($type == 1) {					$image_old = imagecreatefromgif($ImageName);				} elseif ($type == 3) {					$image_old = imagecreatefrompng($ImageName);				}								// "convert" the image to .jpg				$image_jpg = imagecreatetruecolor($width, $height);				imagecopyresampled($image_jpg, $image_old, 0, 0, 0, 0, $width, $height, $width, $height);				imagejpeg($image_jpg, $newfilename);				chmod($newfilename, 0644);				imagedestroy($image_old);				imagedestroy($image_jpg);			}

    Thank you for your helpmatpatnik

  20. Hi guys,Is there a way to do something like this or maybe I did a mistake:

    if ($action == "edit") {		$actionsql = "WHERE type_id=" . $_GET['id'];	} else {		$actionsql = "ORDER BY type_id";	}	$sql = "SELECT type_id, type_name " .		   "FROM type '" . $actionsql . "'";	$result = mysql_query($sql) or die("<font color=\"#FF0000\">Query Error</font>" . mysql_error());	while ($row = mysql_fetch_array($result)) {		$type_name = $row['type_name'];?>

    It was just a test and it failed :) it give me this error message

    Query Error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''WHERE type_id=3'' at line 1
    Thank you for your help
  21. Cool thx andersmoen,Do I have to write only the <?php session_start(); ?> at the beginning of each page or I have to write all the way to the if statement?

×
×
  • Create New...