Jump to content

Lefteris

Members
  • Posts

    32
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling
  • Location
    Greece - Thessaloniki

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Lefteris's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. A yeah session start! Now I remember. And you gotta put it before everything in the page, even the <head> tag, I think. Thanks for the help wayne. I will get on to it right away
  2. Thanks for your reply, what I actually meant is not exactly that but we can start from there. Looking at your example $button_pressed is true now. True for how long? If I refresh the page with a meta http-equiv a little later down in the code , will it still be set? That's what I meant to ask. From the things I tried it seems it will not be set. I have totally forgotten how php works, there must have been some kind of global variable type for that purpose.
  3. Oh so that if returns true if the form exists! Now all is clear to me at least as far as the form problem is concerned. I already solved it taking into account the actual usage of that if. Thanks wayne. About the other thing I said do you have any idea :
  4. Hello all, It has been a long time since I last touched php and I notice that many things are not as I thought them to be. Just so I can remember I set out to make a simple news script which will communicate with a mysql Database which will keep my site's news. This should be simple but here are the questions. So, I have a .php file to use as news addition file. This outputs a form like that: <FORM ACTION="<?php echo(recentURL(true) ); ?>" METHOD=POST> <p>Type the authors name here:<BR> <input size="25" NAME="author"> <p>Type news title here:<BR> <input size="25" NAME="newsTitle"> <P>Type your news here:<BR> <TEXTAREA NAME="newsText" ROWS=10 COLS=40 WRAP> </TEXTAREA><BR> <INPUT TYPE=SUBMIT NAME="submitNews" VALUE="SUBMIT"> </FORM> Right below the form from what little php I remembered I opened an if statement like that : if (isset($_POST['submitNews'])) { Inside the statement is the sql db connection code. The problem is that from the very start this if returns true. As a result whenever I load the page, or refresh it I have additions to the database. Any idea what could be wrong? Or do you need more code? Another question I would like to ask is about variables. Let's say I have a variable which is not set. But I set it right after I click a button, and that button refreshes the page. When the page refreshes that variable should be set, right? In the code I am trying out it refreshes and the variable is not set. Thanks in advance for the answers people
  5. Hello and thanks for the reply. I did what you said and just used the constructor it inherited from its parent class but I still get an error at the same line, only this time it is a very different one. Call to a member function do() on a non-object in ... blah blah Still Following the example code I put it this topic. Any idea why I get this?
  6. Hello all. I have had several problems with php inheritance. I am used to the way c++ deals with inheritance so I thought I could inherit constructors somehow. Seems I can't. But my newest problem is this. I will show you an example of it with the following code: class parent { private $other; public function __construct() { $this->other = new Other(); } public function doSomething() { $this->other->do(); } } class child extends parent { public function __construct() { $this->other = new Other(); } public function newFunction() { parent::doSomething(); } } When I make a new child ... and call the newFunction() I get a: Fatal error: Cannot access empty property in the line where the parent's doSomething has the other object. Which means it is empty. But why is it empty? Isn't that the same object I am instantiating at the child's constructor? I wanted to make my code a little more neat ... a little more OOP and now I think I just killed my code
  7. Hey I am sorry to bump my own topic but it seems it got lost under many new topics and got left with no answer.
  8. Hello all. I have a problem. Up to now the call to $_SERVER['PHP_SELF'] call worked like a charm in any form in my website. Now I made something like ... a dynamic form generation. I am making the various forms by use of Javascript. LAter the javascript function is called inside a php script. Example of code : function fillSetArt(div) { //we load the XML file into xmlAudioObj xmlArtObj = loadXML(xmlArtObj,'artsoft.xml'); //this will be the function which will read the file and extract the data we need! xmlArtObj.onreadystatechange = function() { var text = '<form name="userSkills" id="userSkills" action="<?php echo $_SERVER[\'PHP_SELF\']; ?>" method="POST">'; I added the form's declaration and well .. everything inside a javascript script which edits the inner html attribute of the DIV which I want to contain the various forms. The problem is that when I do it this way I get : Access forbidden! You don't have permission to access the requested object. It is either read-protected or not readable by the server. If you think this is a server error, please contact the webmaster. Error 403 localhost 06/18/08 11:23:07 Apache/2.2.8 (Win32) DAV/2 mod_ssl/2.2.8 OpenSSL/0.9.8g mod_autoindex_color PHP/5.2.5 And in the browser I can see that the error is thrown due to the PHPSELF call. Any idea how to get around this error?
  9. Aha I see. Thanks a lot, makes sense that I would have to save it somewhere. Sounds like a lot of trouble but I feel really organized by having user images in the db instead of in a file. I will try to implement it and post back when I do. Thanks again.
  10. Thanks a lot friend, but I still have a problem. Turned out I had errors in the above code so it never went to the imagecopyresampled part. In particular I never checked the width and height of the image correctly. I tried to do it as I had done but it did not accept $_FILES['userpic']['tmp_name'] as either a destination image or a source image for the image copy resampled. So I then tried it your way, like in the script you linked but a lot simpler since I just want to resize everything to 150x150. The problem is ... how do you store this image in the database? I used to store images in the database by doing something like that : $fcontents = file_get_contents($img_dst); and then adding it with mysql_real_escape_string($fcontents) But now img_dst is not a filename somewhere in the server, it is an image resource. How do you store it in the database? Moreover I can't check to see if the resizing took place if I don't store it in the DB since I already have headers on the top of the page and can't see the image with a simple imagejpeg($img_dst). Here is the code : //get its dimensions $dimensions = getimagesize($_FILES['userpic']['tmp_name']); $imgwidth = $dimensions[0]; $imgheight = $dimensions[1]; //if the dimensions don't fit then resize it! if($imgwidth != 150 || $imgheight != 150) { $img_dst=imagecreatetruecolor(150,150); $img_src = imagecreatefrompng($_FILES['userpic']['tmp_name']); //resize using this ultra cool function! Really cool! imagecopyresampled($img_dst,$img_src,0,0,0,0,150,150,$imgwidth,$imgheight); }
  11. This is not php code. This is a shell script. Jonsjava just gave you the phpcode to run the script. It searches the public_html directory of your website and finds all the files, then inside those files it erases all the functions which contain : var .* return( parseInt(.*') In regular expressions .* means any zero or more characters, so this effectively deletes all the function which contain this. Maybe this is the malware code your webhosting company detected so they made this shell script for you to run. But ofcourse since I am no expert I might be wrong
  12. Sorry for bumping my own topic but since it got only 4 views I assume it got buried due to lots of new topics and none got a change to see it. So ... anyone got any idea how to properly resize an image with php? Why is my way wrong?
  13. Hello all, I have a problem. I can't resize images with imagecopyresampled. Here is my code : .... .... //if the size of the image is greater than 200 kbs if($_FILES['userpic']['size'] > 204800) die("Please upload an image with size lower than 200 Kbs"); //get its dimensions $dimensions = getimagesize($_FILES['userpic']['tmp_name']); //if the dimensions don't fit then resize it! if($dimensions['width'] > 150 || $dimensions['height'] > 150) { imagecopyresampled($_FILES['userpic']['tmp_name'],$_FILES['userpic']['tmp_name'],0,0,0,0,150,150,$dimensions['width'],$dimensions['height']); } $fcontents = file_get_contents($_FILES['userpic']['tmp_name']); //store the image in the db $sql->updatetable("users","userImage","'".mysql_real_escape_string($fcontents)."'","username","'".$username."'"); //and its type $sql->updatetable("users","userImageType","'".$extension."'","username","'".$username."'"); ... ... Shouldn't this work? It is not working. Actually ... it worked a little ... but the resizing was completely out of proportion. It should get resized to 150x150 but it got resized to 280x212 pixels. Any idea why? Also what is the appropriate way to resize an image? Thank in advance.
  14. well you could use a switch statement if you got too many checks to make: switch($var) { case condition1: case condition2: case condition3: case condition4: ..................... case conditionn: echo"fubar"; break; default: echo"not fubar "; break; }
  15. Hey mate. I am no expert but in the first statement I think you are telling php to check : if($var == condition1) or if condition2 is true. It is not comparing var to condition 2. And I guess condition 2 will always be true since it is not getting compared to something , so the whole expression will always be true so .. it will always echo"fubar"; Ofcourse I might misunderstand something but I hope I helped.
×
×
  • 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.