Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Posts posted by PFMaBiSmAd

  1. If you have a list of sequentially named variables, it is a sure bet that you should be using an array.

     

    A list of sequentially named variables will require you to carry around another variable that says how many of them there are. With an array, you don't need to waste time and code doing that.

  2. You would need to give an example of a link that works and one that does not work. It is likely you are writing it incorrectly.

     

    Are you trying relative file system paths or URL's? A file system path is relative to the current working directly of the main script that is running. Using a URL in php function that normally operates on file system paths, requires a fully qualified URL (http://domain/path/file)

  3. Because PHP is a parsed/interpreted language, function definitions can occur in the code any place.

     

    I recommend checking your web server log for errors.

     

    Is nothing displayed, not even the red-x where the photo should be? What do you get in your browser's "view source" of the page the images are on?

     

    Post the code with the <img src="...." tag that is using the two php files you posted.

  4. I played with that script and it contains a bug that triggers a php error when it references an array element that does not exist without first testing if it exists. The php error output "breaks" the image header, in the same way that outputting content to a browser breaks things like cookie/session/redirect headers.

     

    It may very well be that if you call the script and provide values instead of using defaults, that it works without error. The offending line (there could be more) is line 98 in the class_PieChart.php file -

     

    Change this -

     

    if ($item["color"]) {

     

    to this -

     

    if (isset($item["color"])) {

     

    Note: If you have previously browsed to a url where the image appears as a broken image (red-x), and you correct the problem so that the image actually works, you will need to hit your browsers refresh button to get the actual image to be fetched (or clear you browser's cache.)

     

     

  5. SemiApocalyptic is correct. The ONLY way to put an image (a static one or one dynamically produced by php) on a web page (without browsing directly to the url of the image) is using a proper HTML <img scr="..." tag.

     

    If you got a red-x, you will need to troubleshoot why.

     

    Was the URL in the src="..." parameter the php file that you can browse to and get the chart to display?

     

    The garbage you are getting means that a proper mime type header for the image is not being output. The class function you are using should have a way of outputting the header.

     

    Edit: Actually, I found the script you are using and it does output a PNG header. That would mean the grabage output is due to you outputting the image directly in the HTML on the page instead of using an <img src="..." tag.

  6. It works, if your array is structured correctly (tested) -

     

    <?php
    session_start();
    
       $_SESSION['recent_items']['ItemNumber'][0] = 1;
       $_SESSION['recent_items']['ItemNumber'][1] = 2;
       $_SESSION['recent_items']['ItemNumber'][2] = 3;
    
    $item_num = 2;
    if(in_array($item_num,$_SESSION['recent_items']['ItemNumber'])){
    echo "yes";
    }

  7. Put the following in a .htaccess file in the folder that you want to prevent web access to -

     

    order deny,allow
    deny from all

     

    The session.gc_probability and session.gc_divisor randomly determine when GC runs, so you might need to execute a number of session_start() statements before it would run and clean out files that are older than the session.gc_maxlifetime. You actually need to create more than one session to see any effect, because when you access a session, it updates the time information on the file and that would keep the file's age less than the session.gc_maxlifetime.

  8. The only thing apparent from the information provided in the post is the global $database; line of code has absolutely no effect because the global keyword only has meaning when used inside of a function.

     

    Without specific information as to what it is or is not doing, no one in a forum can possibly answer your question.

  9. Using not equal != tests OR'ed together will always be true, unless you can make the variable be all the values at exactly the same time, which is impossible.

     

    You can correct the logic by using an equal test == and OR'in the values to give you a TRUE when one of them matches, or you can use the not equal != test and AND them together, but it is much cleaner to make an array of the possible values and use in_array() or !in_array() to test if a variable is present or not present in the array.

  10. It sounds like the session is ending due to the deletion of the session data file on the server, when garbage collection runs.

     

    On shared hosts, the script from all the accounts on that server with the shortest session.gc_maxlifetime will win and any session data files older than that shortest setting will be deleted when GC runs.

     

    You should create your own session save folder (preferably below your doc root folder) and set session.save_path (in a .htaccess file or in your scripts before each session_start()) to point to that folder. Then the garbage collection routine will only operate on your files using your session.gc_maxlifetime setting. If you cannot place the folder below your doc root and you can only put it above your doc root, make sure you put a .htaccess file in it that denys all http/https web requests to files in it.

  11. php 5.2.4 has a bug when php terminates due to a fatal runtime error that the output buffer is not flushed as part of the shut down logic.

     

    What version of php are you using?

     

    What exactly is the error message from your web server log?

     

    It would probably be a good idea to correct the logic to prevent referencing array keys that don't exist. Code should not normally triggers any notice/warning/fatal errors.

×
×
  • 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.