Jump to content

Zephni

Members
  • Posts

    109
  • Joined

  • Last visited

Everything posted by Zephni

  1. Yep, and it should always be the first thing at the top of the page. This is because you are trying to change the $_SESSION values which won't be associated with any particular session if you don't session_start(); first. Then on the next page it will be like the session was never set. So just try adding: session_start(); Underneath your opening <?php tag
  2. Just checking before looking into it further. But are you running session_start(); at the top of that page? I know it's on the "protected pages" but you can't manipulate the session variables if you haven't started it which you are trying to do on the login page by the looks of things.
  3. Did you see the second part of my message?
  4. You are binding the delete statement twice. First you are binding the parameter ":boxingid" to $PostIdThing and then executing it with a forced ID of 1 in the next line. Then you are executing within the if statement without any parameters. You would be better off deleting this line: $Startoff->execute(array(':boxingid' => 1)); Then the bindTo line would sort out the parameter binding and the execute statement can still be tested by the if statement. Also you don't want to be putting ' quotes inside the statement when using parameter bindings, remove them in this line: $delete = "DELETE FROM BoxingResults WHERE id = :boxingid LIMIT 1"; Hope this helps
  5. I have been working on a frame work type thing: (http://zephni.com/phpzevelop/howto and GitHub https://github.com/Zephni/PHPZevelop) it needs to check for files (pages) before producing them, if the page does not exist and the page isn't set to receive parameters through the URL then it needs to set the default 404 page instead of the page that does exist. It's hard to explain but I have changed the way it works now so it uses try catch statements to check if the files exist instead of using file_exists methods.
  6. In my situation I need to check that a php file exists, but I do not want to run any code in that script yet. I have tried the PHP is_file: http://php.net/manual/en/function.is-file.php and the file_exists function: http://php.net/manual/en/function.file-exists.php But both actually run the file. I can tell because of using sessions to test it in the file itself. Is there any way around this? Thanks in advance.
  7. The reason is, is because I need to tell whether the array was defined with keys and values by the programmer, rather than a single dimensional array. It will be hard to explain exactly why, but it is necessary because what I'm building needs to be able to tell the difference between an array that looks like this: array("item1", "item2"); And this: array("0" => "item1", "1" => "item2"); Because if the key is defined by the user (programmer) the foreach loop needs to perform an extra task. The more I look into this. I should probably do what I'm doing a completely different way.. but I guess the answer is clear... PHP does whatever it wants with types and we have no control over it
  8. This sounds simple in the title, but let me explain... If I did the below: $array = array("1" => "value"); foreach($array as $key => $value) if(is_string($key)) echo "true"; else echo "false"; The result would be false, even though the "1" passed as a key is a string prior to the foreach loop. Is there a way to check the ACTUAL type of the $key in this situation without just determining whether it "can" be a int or "can" be a string. If I did: $array = array("1" => "value"); foreach($array as $key => $value) echo gettype($key); The result would be "integer" so It looks to be that if the foreach loop determines if the string "can" be an integer then it regards it as such. Is there anyway around this? Thanks in advance for any help (Please note I tried to change the title of this post because I realized it wasn't quite specific enough regarding arrays but it won't let me change the title)
×
×
  • 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.