Jump to content

Jerzxu

Members
  • Posts

    53
  • Joined

  • Last visited

Contact Methods

  • Website URL
    http://www.sotrg.com

Profile Information

  • Gender
    Not Telling

Jerzxu's Achievements

Member

Member (2/5)

0

Reputation

  1. I find it kind of weird that spl_autoload uses this functionality for namespaces. Numerous places online I've read mentioned that spl will look at the namespace and attempt to load it based on the namespace as if it were a directory structure. http://www.dreamincode.net/forums/topic/148935-php-53-namespacing-and-autoloading/ Example of autoloading with namespaces. Though this is done on windows though, not linux. Guess I will just specify a function to load it. Thanks.
  2. Forgot to post that. Class file looks like this: namespace Test\Systems { class User { #Class functions etc. } }
  3. I did a search on the forums before posting this So I have been attempting to use spl_autoload_extensions('.php') to autoload my classes based off namespaces but it continually says that the namespace does not exist. Code I am using: spl_autoload_extensions('.php'); spl_autoload_register(); use Test\Systems\User as User; $usr = new User(); The error I get is this: Class Test\Systems\User could not be loaded in.. My files are exactly as named in the namespace. So Test > Systems > User.php I have also tried variations of that like: spl_autoload_extensions('.php'); spl_autoload_register(); use Test\Systems as Test; $usr = new Test\User(); And so on. Nothing appears to be working. I looked around online and seen that at one point *nix systems couldn't use autoloading but apparently php 5.3.3 fixed this functionality. The server currently is running on 5.3.13 so I am not sure why this isn't working. Any insight would be appreciated.
  4. Update: So I resolved the issues. I actually went into the source code of the page I was getting and replaced all the random html characters like to regular spaces. This resolved the issue with everything and now my original RegEx works.
  5. http://ekoverse.com/tests/test.php Doesn't seem to. Code for that page: <?php $page = file_get_contents('http://www.skinakiska.com/conditions/snow-report.aspx'); $content = strip_tags($page); preg_match('/24(?:h| h)\s+\d+°(?:C|F)\s+\d+\s+cm/i', $content, $matches); $pattern = '/24(?:h| h)\s+\d+°(?:C|F)\s+\d+\s+cm/i'; print "Matches: <br/>"; print_r($matches); print "<br/><br/>"; print "Pattern: <br/>"; print $pattern; print "<br/><br/>"; print "Content: <br/>"; print $content; ?> Guessing it doesn't work due to the degrees symbol issue. I almost got what I needed by doing this RegEx: /((24 Hr|24 Hrs|24 Hour|24 Hours|24H|24 H).*?(\d+)?(cm| cm))/si Except the value I need, the 0, isn't appearing. Possibly due to a conflict of digits? The reason I need the RegEx to be like that is because there is numerous other websites that I will be looping through to get the same sort of data so the expression can't be just for this site.
  6. The website it's coming from is here: http://www.skinakiska.com/conditions/snow-report.aspx If that helps. Basically file_get_contents from that url put it into a var, then strip_tags, then do the preg_match. Some PHP Code: $page = file_get_contents(http://www.skinakiska.com/conditions/snow-report.aspx); $content = strip_tags($page); preg_match('/(24H|24 H).*?(\d+?)(cm| cm)/si', $content, $matches); print_r($matches); Should actually say that my expected output should be the number next to the cm, rather than what I said before. This RegEx is used for a bunch of different locations, so its put into a loop, but for now I just need this one to work. The difference between some of the other resorts is that they use 24 Hours, etc. which would just mean the first grouping would have 24 Hours|24H etc.
  7. Well basically I am just trying to get the number value before the centimeters (in this case 0) that appears directly after 24 h. The reasoning: We are getting snow reports for the last 24 hours and generally they are 24 h some characters, then 0 cm etc. So essentially I need the first occurrence of some number cm that appears after 24h or 24 h. Which is true, that's what I should expect, but I actually get no matches at all. I'm using preg_match to match and file_get_contents and strip_tags to alter the text before it hits preg_match, but I can't see those modifying the output to result in nothing when a test case on the same text, with 10 cm instead, results in proper matching.
  8. So I have a problem in which I have to get a webpage using file_get_contents, strip out the HTML then parse it with Regular Expressions to get the current snow conditions for that area. With my test cases, which are just copies of the text but with modified values of the amount of snow, it works. But when it goes to get the actual live value, which is currently 0 cm (hasn't changed so I don't know if it works on a different value), it returns a empty array. I have been looking across the web for the what could be causing this, and have try many different cases but nothing seems to work. The regex is: /(24H|24 H).*?(\d+?)(cm| cm)/si The text is: My expected output: 24 h 5°C 0 cm Any help would be appreciated.
  9. Sure just want my email or something??? For contact? Or post it on here??? (prob not best idea)
  10. That is true. Actually I was trying to debate whether or not to use ID (int 255, auto-inc.) as a primary key in the Actions table as I am going to set up a cronjob to delete 2 day old actions. So the auto-incrementing ID would be used up eventually except it would take ALONG time I would imagine. But I couldn't think of a way around, any thoughts?
  11. That sir is a good question. Well, helps me remember what its doing, BUT now that I think about it I could probably just put comments to remind me what I am doing.
  12. That seems to have worked. Thank you! Never have, I will look into that though. THANKS
  13. Good Morning/Afternoon (whichever applies) Okay, I am making a area on my website which users let each other know what they did. (Kinda like facebook's recent friend actions) Anyways, I ran into some problems. You see with the code I have to grab the friends that you have from one table, use them for another tables query to get the actions. So basically: Query Friends -> Use Friends to Query Actions -> Output Recent Actions The code I have is below $friends = mysql_query(sprintf("SELECT `Friend` FROM `Friends` WHERE `Username`='%s' AND `Blocked`='No' AND `Mutual`='Yes'", mysql_real_escape_string($username))); while ($friends = mysql_fetch_array($friends)){ foreach ($friends as $fri){ $actions = mysql_query("SELECT * FROM `Actions` WHERE `Username`='$fri'"); $actionrows = mysql_num_rows($actions); for ($i=0;$i=$actionrows;$i++){ while ($recs = mysql_fetch_array($actions)){ echo $recs['Username']; } } } } The code just gives me a timeout error, but does output the $recs['Username']; It just takes forever to load it. I probably can achieve this some other way, I just don't know exactly where to turn. If you could show me a sign it would help~ Regards, Jerzxu
  14. Update: (Just some tidbits of info.) I was looking at a tutorial on how to insert images into a database and got it successfully running. Except I ran into some problems resizing it etc. I got frustrated and was about to go back to normal way just uploading etc. and realized this line of code when displaying an image from the database: header("content-type: text/jpeg"); After some messing around with changing the file extensions etc. around I actually got my way of viewing to work. So now it will display a file with no file extension, or with a .somemadeupextension regardless. And the way I did it makes it quite difficult to copy without using printscreen. And that's all she wrote.
×
×
  • 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.