Jump to content

midnite

Members
  • Content Count

    179
  • Joined

  • Last visited

Everything posted by midnite

  1. ok, so i assume you will get the max quantity of each item from the database. <?phpecho "<form method=\"post\" action=\"giftlist.php\">";echo "<input type=\"hidden\" name=\"save\" value=\"1\">";echo "<input type=\"hidden\" name=\"modifyid\" value=\"$_POST['giftlist']\">";echo "<table border=\"4\" cellpadding=\"4\" cellspacing=\"4\" id=\"giftlist\" align=\"center\">";echo "<tr class=\"heading\">";echo "<td>Product</td>";echo "<td>Price</td>";echo "<td>Pieces</td></tr>";while ($row=mysql_fetch_array($gift)) {echo "<tr
  2. Currently my server is down. So i cant test it. But i think you need something like this echo "<form method=\"post\" action=\"giftlist.php\">";echo "<input type=\"hidden\" name=\"save\" value=\"1\">";echo "<input type=\"hidden\" name=\"modifyid\" value=\"$_POST['giftlist']\">";echo "<table border=\"4\" cellpadding=\"4\" cellspacing=\"4\" id=\"giftlist\" align=\"center\">";echo "<tr class=\"heading\">";echo "<td>Product</td>";echo "<td>Price</td>";echo "<td>Pieces</td></tr>";while ($rowi=mysql_fetch_array($gift)) {echo "&l
  3. Thanks Synook, Silver and boen_robot!In fact, my PHP script uses file_get_contents() to fetch a page. Analyze it. Then generate some javascripts (setTimeout("location.reload()", rand*1000);) to reload the the page in a few seconds.It runs normally for 99% of the time. Yet if file_get_contents() throw a Fatal error, the page will be halted there and no javascripts will be generated then no more reload :)Currently, i guess it is because the resource cannot be fetched within the HTTP time limit, thus cause the PHP max_execution_time exceeds.Silver, here's my configurations. They are defaults. i d
  4. Thanks for your replies.file_get_contents() do throw Fatal error!! If i come across it again, i will post the error message.So, i would like to ask, can i skip Fatal error and let the rest of my page to execute?Yes, @ will suppress Fatal error, by just not printing it out. The rest of the page will not be executed also
  5. http://hk.php.net/manual/en/language.exceptions.php<?phpecho 'before<BR>';try { undefined_function ();} catch (Exception $e) { echo 'err: ', $e->getMessage(), '<BR>';}echo 'after';?> Isn't Exception $e will catch all errors? i still receive a Fatal error message on the page. And no after is echoed.In fact, i don't care if it can be caught or not. i just want the following of the page to be executed even if that statement fails. What my real code is: <?php// something before$websrc = file_get_contents($SRC);// something after?> i use the above example (undefined_
  6. midnite

    Redirecting

    Hi Ragae,It's good to hear that you have solved your problem. Yes, i think using header () redirect with output buffering is the best choice. A kindly reminder that be aware of infinite recursively redirecting to itself.Another suggestion (that i will use) is using a different page to perform the delete process. Thing likes <a href="delmsg.php?mode=deletemsg&id=<?= $row['MsgId']; ?>">Delete</a> and having header ('Location: messages.php'); at the end of delmsg.php. In this solution, we need not to care about output buffering as delmsg.php wont output anything.cheers
  7. midnite

    Redirecting

    Hi Ragae,i am sorry that i dont really understand what's your situation. You have a page message.php like this? message.php<?phpif (isset ($_GET['mode']) && $_GET['mode'] == 'deletemsg') { // perform delete $_GET['id']}<html>message 03 <a href="messages.php?mode=deletemsg&id=3">delete</a></html> it calls itself for the operation?
  8. midnite

    Redirecting

    Hi there,if you want to TOTALLY save bandwidth (header, though small, is something we still need to send, what we save is only the page contents), TOTALLY dont let your cliients know what is happening (header can be easily captured), or you simply not pleasant with header ();, try replacing header ('location: another.php'); by include 'another.php'; die ();http://hk2.php.net/manual/en/function.include.phpcheers
  9. midnite

    Redirecting

    Hi all,FYI,1) try not to use Windows Notepad to edit unicode pages. it adds 3 bytes of something (forgot the technical term) in front of your <?php that ruins your header() functions. You will always get "header already sent" error with no clue. You may use hex editor so you will have a totally clear picture of it. (but i guess u guys dont have this problem as no one is complaining )2) always add die (); or exit (""); after header (); because the lines following header (); will still be executed after the header is sent. (if we understand the whole networking mechanism, we won't feel it's
  10. midnite

    PHP Random Quotes

    driz,FYI, Math.random() and var quote = Math.ceil (Math.random() * how_many_quotes); http://www.w3schools.com/jsref/jsref_obj_math.asp
  11. midnite

    What is this called?

    but, cant i simply use $page_mode = $_POST['page_mode'];? if $_POST['page_mode'] is empty, $page_mode will be an empty string also
  12. midnite

    PHP Browser detection

    Hi master, i believe that's the key point too
  13. midnite

    PHP Browser detection

    Hey try<?phpfunction browser() { if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) echo '<p>You are using IE</p>'; else if (strstr($_SERVER['HTTP_USER_AGENT'], 'Gecko/')) echo '<p>You are using Firefox</p>'; else if (strstr($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit')) echo '<p>You are using Safari</p>'; } browser();?>
  14. see this: # cat sth.c#include <stdio.h>int main () { int a = 3; if (!a = 0) printf ("in: %d\n", a); printf ("out: %d\n", a); return 0;} it is not valid in c if the parentheses are omitted:
  15. midnite

    fsockopen again

    case 1: exactly with the above code. (80 lines limit)first, it echoed 80 lines of course.then, it echoed another 80 lines from the first request. That means totally 160 lines of the page "/html/default.asp" has been echoed. None from "/js/default.asp".so i guess will the page of "/js/default.asp" was appended after "/html/default.asp". Then i change it to unlimited lines.case 2: change 80 to 80000000 (no line limit)first, it echoed all the codes of page "/html/default.asp".then, it echoed nothing.i don't know "refresh the connection here" or "reset the file pointer" neither. Just some imaginar
  16. Thanks you guys!i understand what you are saying. And also i have been using if (!$var = func()) quite often and it always work as what i wish: if (! ($var = func()) ). Yet when i accidentally came across the precedence table, i was confused.In that table, isn't the assignment operator sits at the fifth last and the NOT operator is high above at the sixth top? According to their precedences, isn't if (!$var = func()) should be interrupted as if ( (!$var) = func())? Although it is not logical and not syntactically correct, it is what the precedence table means.Is it because of the associativity
  17. midnite

    fsockopen again

    As i remember, i could not.Then i have just written a few lines for codes. Take w3schools as an example: <?phpdefine ('debug', true);// w3schools (html)echo '<h1>w3schools (html)</h1>';$out = 'GET /html/default.asp HTTP/1.1'."\r\n";$out .= 'Host: www.w3schools.com'."\r\n";$out .= 'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14'."\r\n";$out .= 'Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5'."\r\n";$out .= 'Accept-Language: en-gb'."\r\n";$out .= 'Accept-Encoding
  18. midnite

    fsockopen again

    If i want to open two resources, different files, but they are at the same host, same domain. Is it the only way to: $fp = fsockopen ('ssl://www.domain.com');$out = 'GET '.$file_one." HTTP/1.1\r\n";fwrite ($fp, $out);// do somethingfclose ($fp);$fp = fsockopen ('ssl://www.domain.com');$out = 'GET '.$file_two." HTTP/1.1\r\n";fwrite ($fp, $out);// do somethingfclose ($fp); open the same socket "ssl://www.domain.com" again?i know even opening it for a thousand times won't cost me a penny, but can i have something like this: $fp = fsockopen ('ssl://www.domain.com');$out = 'GET '.$file_one." HTT
  19. let's see http://us2.php.net/manual/en/language.oper...tors.precedencethe assignment operator (=) is far below the not operator (!). But why we can work like this: function func () { return false;}$var = false;if (!$var = func()) { echo 'it is true';} and it act as if: function func () { return false;}$var = false;if (!($var = func())) { echo 'it is true';}
  20. i am not familiar with HTTPS. i am not sure if pecl-http support SSL. But i found something interesting. When i use http_get ('https://'.$somethingelse), it is alright. Yet an error message saying it doesn't support SSL with i use http_get ('ssl://'.$somethingelse).And thanks all the guys who have helped me =)i am now using another approach - fsockopen(). And it works!! i have successfully logged in and now proceeding form by form =)http://us2.php.net/manual/en/function.fsockopen.php
  21. Nope, i said wrongly. The are the same, of course, as $HEADER is extracted from $websrc. But what is different is $HEADER and $info.i am now fixing my code =)
  22. Thanks, justsomeguy!i have looked into the header. It is funny (or i dont understand why) that the print_r ($HEADER) is different from the first part of echo $websrc. (i post them later)And also, my school's login uses HTTPS. i wonder if these HTTP functions support HTTPS?Thanks again for your help!cheer.
  23. Hi Synook, Thanks for your reply.i think i did not explain my situation clearly. i have an Apache PHP server. And i would like to write a PHP script to login to my school's account. Not building my own login system or forms.And my code is: (i have simplified for some string manipulate functions)$SRC['base'] = 'https://www.myschoolweb.edu.hk/';$SRC['login'] = 'WWWLogin';$SRC['target'] = 'WWWLogin';// login form$websrc = http_get ($SRC['base'].$SRC['login'], array(), $info);$HEADER = http_parse_headers ($websrc);// make POST$SESS = 'something';$IP = 'somethingelse';$POST_DATA = 'p_username=myuse
  24. i would like to use PHP scripts to login to my account and fill a form. But i still cannot login yet :mellow:i have been using HTTP functions like http_post_data()http://hk2.php.net/manual/en/function.http-post-data.phpi have found a tutorial websitehttp://www.oooff.com/php-scripts/basic-cur...ll-tutorial.phpwhich uses curl_exec() functions.which is better? (But if any of them works, it will be fine )i have tried http_post_data(), but i cant see there exist any cookies information in the response. But i see lots of cookies when using Firefox Tamper Data or Firebug. i guess it is the reason
×
×
  • Create New...