![](https://forums.phpfreaks.com/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
Alex
Staff Alumni-
Posts
2,467 -
Joined
-
Last visited
Everything posted by Alex
-
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.
-
Grab the remote xml file using cURL as a string and then pass it into simplexml_load_string().
-
How can i use [] tags instead of <> tags for profiles??
Alex replied to DarrenReeder's topic in PHP Coding Help
Ex: $text = '[b]Test[/b]'; $text = preg_replace('~\[b\](.*?)\[\/b\]~i', "<b>$1</b>", $text); echo $text; // <b>Test</b> -
How can i use [] tags instead of <> tags for profiles??
Alex replied to DarrenReeder's topic in PHP Coding Help
When pulling the data from the database to display you would parse the BBcode. -
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.
-
Is this what you're doing?: $myXML = 'http://www.site.com/xml.php?p=' .$title. '&z='.$video; $sxml = simplexml_load_file($myXML);
-
How can i use [] tags instead of <> tags for profiles??
Alex replied to DarrenReeder's topic in PHP Coding Help
Look into BBcode parsing. -
You should include http:// in the URL.
-
use simplexml_load_file, not simplexml_load_string().
-
What do you think of the new look of these forums?
Alex replied to smerny's topic in PHPFreaks.com Website Feedback
I really like how the new solved topics look. -
Surely posting a reply in your original topic would have been a much better alternative to posting another separate topic.
-
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.
-
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"); } ?>
-
Is that the entire code? The error says line 48 but there's only 37 lines of code there.
-
You shouldn't have a semicolon at the end of this line: if ($username <> "administrator");
-
You're the one writing this code and you don't know? You need to put a closing bracket..
-
$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'])) {
-
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); } ?>
-
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));
-
$str = ''; foreach(glob("*", GLOB_ONLYDIR) as $dir) $str .= "$dir<br />\n"; echo $str;
-
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()
-
One of the ;'s should be a comma: for ($i = 0, $l = sizeof($array); $i < $l; ++$i) {
-
If $course->finish_date and $today[0] are both unix timestamps just compare those.
-
Help - Simple question, echoing database, is too long on page
Alex replied to chrisis11's topic in PHP Coding Help
I'd take a look at this tutorial: http://www.phpfreaks.com/tutorial/basic-pagination -
They also have Thanksgiving in Canada, but theres is earlier in the year.