Jump to content

bltesar

Members
  • Posts

    109
  • Joined

  • Last visited

    Never

Everything posted by bltesar

  1. when using imagecreatefromjpeg() I sometimes get the following error mesage: Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 6400 bytes) in... The unusual thing about this is that it does not appear related to the image size.  It has worked for a 642K image while failing for a 610K image.  Any ideas why?
  2. your form can look like this- [code] <form enctype="multipart/form-data" method="post"> <input type="hidden" name="click" value=""></form> [/code] and then in the HTML of your page, the image will look like this: [code] <img src="pictobeclicked.jpg" onClick="document.forms[0].click.value=1;document.forms[0].submit();"> [/code]
  3. to your first onClick event handler         onClick="window.location.href='<?php echo $cart_url; ?>';" add ?c=300. Then set up your cart.php page to direct to the index.php?c=whatever page
  4. PHP can't do anything with onCLick unless there is a javascript function that sets the value of a form input that is then submitted to the server. e.g. [code] <a href="javascript:document.forms[0].some_click_flag.value=1;">your picture</a> [/code] then only when forms[0] is submitted will the server get some_click_flag and know that the picture was clicked. Perhaps you want the user to click and send stuff to the server without having to reload your page.  To do that, you can set upa hidden frame that holds forms with hidden inputs that are sumitted when the user clicks photos in the visible frame.
  5. thank you.  Are you sure echo $output will actually produce an image onscreen?  I believe in a previous post someone said that it wouldn't, that the data read from the file must somehow be processed into an image.  Also, do you think this method offers any advantages over the .htaccess approach?
  6. That doesn't make sense.  I've not had such behavior with refreshes.  Perhaps it is due to the settings on your browser.
  7. it seems we're not speaking the same language?! ??? what exactly do you mean by template?  If you mean a page with basic structure that is shared among many pages, but with some places for page-specific data within, it'll be something like this top of page shared by all pages a bit of data unique to page middle of page shared by all pages more data unique to page bottom of page shared by all pages what you do actually, instead of creating one template page, is create separate template pages for the parts that are shared by all pages, e.g. top.htm, middle.htm, and bottom.htm.  then each page in your site will be a .php page that looks something like this: [code] <?PHP         include(top.htm);         //code to generate output unique to this page         include(middle.htm);         //code to generate more output unique to this page         include(bottom.htm); ?> [/code]
  8. that should work.  perhaps you didn't show it, but for the first block of code, you don't have session_start(); The session variables really don't help you.  Anyone can go to the page once, without submitting the form, and the session variables will be set.  They can then navigate to another domain and from there submit data to your index2.php page.  The session variables will be preserved across navigation outside your domain.  I know because I have tested it.  By the way, that also means that testing for the $_GET and $_POST does not ensure data is submited only from your form.  One way to protect from this sort of hacking is to use HTTP_REFERRER.  This is not set on a lot of sites, and I do not even know how to make sure it gets set on my site.  What I do know is that if it is set, you can then make sure whoever submits data is coming from your site by checking that HTTP_REFERRER is set to your domain. Another way is to use .htaccess  Put all your receiving pages, such as index2.php, into a directory with a .htaccess file that blocks access from outside your domain.
  9. yes, it will still work with two arrays, but you only need to pass the $points array to the arsort function.  both arrays share the same key, so you sort $points by its values(not keys) and then go through $points and use the keys to reference back to the $names array.
  10. from what you wrote, it seems your form is using the GET method, so try what I wrote earlier, replacing $_POST with $_GET.
  11. doesn't arsort preserve the key=>value relationships, and so the assocaition between names and points should be preserved? another approach is to set up your array as follows: [code] $data=array('John'=>7, 'Peter'=>8, 'Jeff'=>2); arsort($data); [/code]
  12. What I originally wrote should work fine, except that these things are case sensitive.  The query should be SELECT COUNT(*)... Using that with totalrows=$row['COUNT(*)'] is preferred over just doing a SELECT *... because the latter approach will take up more resources because it actually gets all the contents of all the rows.
  13. did this code once work and then suddenly stop working correctly? this seems unusual- [code] if (mysql_num_rows($query)) { echo "NO ROWS"; $errorhandler .= "There is no such info in the database<br />"; $errorhandler .= "Please try again or contact us for questions<br />"; }[/code] because it should have a '!', or at least it seems it should, this code block won't be executed if the query failed for some reason.  How is the server's error display set?
  14. try [code] arsort($points);  //sorts array by values highest to lowest, preserving key=>value relationship. foreach($points as $key=>$value) {     echo $name[$key].'-'.$value.'<br>'; } [/code] of course, you could achieve your objective in many differnet ways.
  15. is it possible that your conditional if (isset($_POST['submitresetpass']))  is returning false? if after submitting the form, you're getting the form back, then that is probably the trouble. what are you getting after your submit?  Is the update query working?
  16. If you're using the POST method for your form, do this- [code] if(!isset($_POST)) {       //print your error message, or redirect, or whatever } else {       //process the inputs } [/code] for the GET method, replace $_POST with $_GET
  17. here's the trouble [code]     $limit          = 25;                    $query_count    = "SELECT count(*) FROM gallery";        $result_count  = mysql_query($query_count);        $totalrows      = mysql_num_rows($result_count); [/code] because you are selecting COUNT(*), the result of this query will only have one row. do this- [code] $row=mysql_fetch_array($result_count, MYSQL_ASSOC); $totalrows=$row['COUNT(*)']; [/code]
  18. $prevpage=$page--; is equivalent to $prevpage=$page; $page=$page-1; which is why you need to use: $prevpage=$page-1;
  19. Are you sure the NEXT button doesn't work?  I found a typo for the PREV button: [code] echo("<a href=\"$PHP_SELF&page=$pageprev\">PREV".$limit."</a> ");  [/code] should be: [code] echo("<a href=\"$PHP_SELF?page=$pageprev\">PREV".$limit."</a> ");  [/code] notice the & has changed to a ?
  20. This is a JavaScript issue.  Instead of having your <a href='link1.php'  you'll need to have a JavaScript function determine if a link has already been clicked. here's the function: [code] var linkclicked=false function checkclick(url){ if (linkclicked) {     return void; } else {     linkchecked=true;     window.location.href=url;     return void; } [/code] now your links should look like this: [code] <a href="javascript:checkclick(URL_for_this_link)"> [/code] there are other ways of doing it, and there might be some details that need to be worked out (I'm not sure how the return void will affect the behavior of the links), but that's the basic idea.
  21. the problem is that your second and third queries are using the same variables, $num_rows, $row, to go through the results.  Use $num_rows3, $row3, etc. and it should work.
  22. try this: [code] try {   $error='';   if (!filled_out($_POST))   {       $error.='You have not filled out all the required fields - please try again.<br>';   }   if (!valid_email($mail))   {       $error.='This email address ius not valid - it must be, as this is used to send an activation email.<br>';   }   if ($password != $passcheck)   {       $error.='The passwords you entered do not match.<br>';   }   if (strlen($password)<8)   {       $error.='Your password must be greater than seven characters.<br>';   }   if($error)   {         throw new Exception($error);     }   echo 'Your registration was successful'; } [/code]
  23. thanks very much for that link.  I did not know anything about .htaccess files.  Quite useful.
  24. I've never used it before, but I tested it out and it seems to work. try this [code] $params=session_get_cookie_params(); print_r($params); [/code] to see if the operation is actually working.
×
×
  • 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.