Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. It doesn't leave you open to any security risks, and it's done like this often for the exact purpose you stated, to avoid redundantly writing your connection in every file. People can't just include your connection file like that.
  2. Grab the remote xml file using cURL as a string and then pass it into simplexml_load_string().
  3. Ex: $text = '[b]Test[/b]'; $text = preg_replace('~\[b\](.*?)\[\/b\]~i', "<b>$1</b>", $text); echo $text; // <b>Test</b>
  4. When pulling the data from the database to display you would parse the BBcode.
  5. Looks like you can't grab remote files (fopen_wrappers is probably disabled). You might want to try cURL to obtain the remote xml file.
  6. Is this what you're doing?: $myXML = 'http://www.site.com/xml.php?p=' .$title. '&z='.$video; $sxml = simplexml_load_file($myXML);
  7. You should include http:// in the URL.
  8. use simplexml_load_file, not simplexml_load_string().
  9. Surely posting a reply in your original topic would have been a much better alternative to posting another separate topic.
  10. Did you ever consider that the reason that your original post failed to receive any replies is because your question is poorly asked without enough information? Don't assume you didn't any replies because that particular section of the board is inactive, I actually read your topic and didn't reply because your question was asked in an inadequate fashion.
  11. You should really consider intending your code. It makes it much easier to read and find potential errors. <?php //checks cookies to make sure they are logged in if(isset($_COOKIE['ID_my_site'])) { } $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { //if the cookie has the wrong password, they are taken to the login page if ($pass != $info['password']) { header("Location: login.php"); } //if user is administrator then go to admin view if ($username == "administrator") { header("Location: admin.php"); } //otherwise show admin page else { } //if the cookie does not exist, they are taken to the login screen else { header("Location: login.php"); } } ?> Looking at it that way the errors are extremely clear. It seems to me like you mismatched some if statement, I think you want something more like this: <?php //checks cookies to make sure they are logged in if(isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { //if the cookie has the wrong password, they are taken to the login page if ($pass != $info['password']) { header("Location: login.php"); } //if user is administrator then go to admin view if ($username == "administrator") { header("Location: admin.php"); } //otherwise show admin page else { } //if the cookie does not exist, they are taken to the login screen } } else { header("Location: login.php"); } ?>
  12. Is that the entire code? The error says line 48 but there's only 37 lines of code there.
  13. You shouldn't have a semicolon at the end of this line: if ($username <> "administrator");
  14. You're the one writing this code and you don't know? You need to put a closing bracket..
  15. $end errors usually occur when you forget to close a bracket. In this case you're never closing this bracket: if(isset($_COOKIE['ID_my_site'])) {
  16. This can be done using PCRE functions, in particular preg_match, and the \b modifier, however in your case I'd opt for another option. It would be better to just store glob("*", GLOB_ONLYDIR) as a variable, to get a string ($galleryDir) from that you can get $galleryDir by implode(...). You can then use in_array to check if the directory exists. Another option would be to use file_exists, this would be better if you don't actually need the list of directories for any other processing. <?php $dirs = glob("*", GLOB_ONLYDIR); $galleryDir = implode("\n", $dirs); $strArr = explode("?", $_SERVER["REQUEST_URI"]); $thisDirectory = $strArr[sizeof($strArr) - 1]; if (!in_array($thisDirectory, $dirs)) { header('Location: ./index.php'); exit (0); } ?>
  17. file_get_contents will only work in that context if fopen_wrappers is enabled. A better alternative would be cURL Edit: Wait.. I misunderstood your problem.. Your problem might be caused by whitespace returned by $entityURL = fgets($src_handle, 4096);. Try $entityURL = trim(fgets($src_handle, 4096));
  18. $str = ''; foreach(glob("*", GLOB_ONLYDIR) as $dir) $str .= "$dir<br />\n"; echo $str;
  19. Yea, that's what should be expected by that code. Daniel0 was just messing with you. You really didn't specify how you want the string to be constructed. What Daniel0 gave you technically does produce 'a string' from the result of glob()
  20. One of the ;'s should be a comma: for ($i = 0, $l = sizeof($array); $i < $l; ++$i) {
  21. If $course->finish_date and $today[0] are both unix timestamps just compare those.
  22. I'd take a look at this tutorial: http://www.phpfreaks.com/tutorial/basic-pagination
  23. They also have Thanksgiving in Canada, but theres is earlier in the year.
×
×
  • 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.