Jump to content

supertrucker

Members
  • Content Count

    171
  • Joined

  • Last visited

Community Reputation

0 Neutral

About supertrucker

  • Rank
    Member
  • Birthday 07/24/1978

Previous Fields

  • Languages
    Learning, forgetting, and learning again: Java,PHP, HTML/XHTML, SQL, Pascal

Profile Information

  • Location
    The sticks, Michigan!
  • Interests
    Gadgets that beep and make noise, my children, my bike, and getting lost on the internet.
  1. Wow, I feel a little dumb now! I was calling the method with '::' instead of '->', thanks!
  2. Hello,I have written a custom class that is going to handle all of my CRUD operations for my "user" table. Below is the class: <?php class UserDb { const TABLE = "users"; const KEY_ID = "Id"; const KEY_EMAIL = "email"; const KEY_JOIN_DATE = "joinDate"; const KEY_VERIFIED = "verified"; const KEY_LAST_LOGIN = "lastLogin"; const KEY_FIRST_NAME = "firstName"; const KEY_LAST_NAME = "lastName"; const KEY_PASSPHRASE = "passphrase"; private $db = null; public function __construct() { $this->db = new PDO( 'mysql:host=' . HOST_NAME . ';dbname=' . DATABASE_NAME . ';charset=utf8', DATABASE_USER, DATABASE_PASS ); $this->db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } public function userExists($email) { $sql = $this->db->prepare("SELECT * FROM " . self::TABLE . " WHERE " . self::KEY_EMAIL . " = :email"); $sql->execute(array(':email' => $email)); $row_count = $sql->rowCount(); if ($row_count > 0) { return true; } else { return false; } } public function insertUser($user = null) { if (is_null($user)) { $user = new User(); } } } ?> When I run this, I get: Can anyone tell me what I've done wrong? I've never worked with classes in php before.Thank you in advance!
  3. supertrucker

    Rss Feed Order

    I'm trying to add an RSS feed engine to my site. I have the meat and potatoes portion completed, now I need the engine that syndicates them. Here's the example from the W3Schools site: <?xml version="1.0" encoding="ISO-8859-1" ?><rss version="2.0"><channel> <title>W3Schools Home Page</title> <link>http://www.w3schools.com</link> <description>Free web building tutorials</description> <item> <title>RSS Tutorial</title> <link>http://www.w3schools.com/rss</link> <description>New RSS tutorial on W3Schools</description> </item> <item> <title>XML Tutorial</title> <link>http://www.w3schools.com/xml</link> <description>New XML tutorial on W3Schools</description> </item></channel></rss> My question is this: As you add new items to your RSS XML, do the new ones go at the beginning, or the end of it? Does it not matter? How many items should you have in your XML before you start removing them from the XML? Do you need to remove them from the XML, or should this thing just be allowed to grow as big as Jupiter? Should the XML show the MOST recent item only?I've been searching online for a good part of the afternoon and can't seem to find the answer, perhaps a bad choice of keywords . I appreciate any feedback, and yes, I'm aware this is not a PHP specific question, but the engine will be written in PHP and there isn't a forum here for RSS Edit:Ok, found this on a website: I suppose this pretty much answers my questions, but I still wonder if there is an unspoken rule of no more than 15 items. I wouldn't want specific aggregators blocking my syndicate because I have more than 15 items. Also, do the new items go at the top or bottom of the XML? What do you think?Once again, to answer yet another of my own questions, the newer items go at the beginning of the example, here's a sample!<?xml version="1.0"?><rss version="2.0"> <channel> <title>Liftoff News</title> <link>http://liftoff.msfc.nasa.gov/</link> <description>Liftoff to Space Exploration.</description> <language>en-us</language> <pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate> <lastBuildDate>Tue, 10 Jun 2003 09:41:01 GMT</lastBuildDate> <docs>http://blogs.law.harvard.edu/tech/rss</docs> <generator>Weblog Editor 2.0</generator> <managingEditor>editor@example.com</managingEditor> <webMaster>webmaster@example.com</webMaster> <item> <title>Star City</title> <link>http://liftoff.msfc.nasa.gov/news/2003/news-starcity.asp</link> <description>How do Americans get ready to work with Russians aboard the International Space Station? They take a crash course in culture, language and protocol at Russia's <a href="http://howe.iki.rssi.ru/GCTC/gctc_e.htm">Star City</a>.</description> <pubDate>Tue, 03 Jun 2003 09:39:21 GMT</pubDate> <guid>http://liftoff.msfc.nasa.gov/2003/06/03.html#item573</guid> </item> <item> <description>Sky watchers in Europe, Asia, and parts of Alaska and Canada will experience a <a href="http://science.nasa.gov/headlines/y2003/40may_solareclipse.htm">partial eclipse of the Sun</a> on Saturday, May 31st.</description> <pubDate>Fri, 30 May 2003 11:06:42 GMT</pubDate> <guid>http://liftoff.msfc.nasa.gov/2003/05/30.html#item572</guid> </item> <item> <title>The Engine That Does More</title> <link>http://liftoff.msfc.nasa.gov/news/2003/news-VASIMR.asp</link> <description>Before man travels to Mars, NASA hopes to design new engines that will let us fly through the Solar System more quickly. The proposed VASIMR engine would do that.</description> <pubDate>Tue, 27 May 2003 08:37:32 GMT</pubDate> <guid>http://liftoff.msfc.nasa.gov/2003/05/27.html#item571</guid> </item> <item> <title>Astronauts' Dirty Laundry</title> <link>http://liftoff.msfc.nasa.gov/news/2003/news-laundry.asp</link> <description>Compared to earlier spacecraft, the International Space Station has many luxuries, but laundry facilities are not one of them. Instead, astronauts have other options.</description> <pubDate>Tue, 20 May 2003 08:56:02 GMT</pubDate> <guid>http://liftoff.msfc.nasa.gov/2003/05/20.html#item570</guid> </item> </channel></rss> So one more question to go!
  4. Any ideas on how to back up a db on a hosted platform? It has phpadmin for the user interface, but I'm at a loss for the best method of backing this up, short of exporting each table manually...
  5. In theory you are correct, but there, unfortunately, are scenarios where developers don't follow the typical rules. Here's a standard favicon declaration: <link rel="shortcut icon" href="favicon.ico" /> Sometimes, I've seen people do this: <link rel="shortcut icon" href="/images/favicon.ico" /> Or even this: <link rel="shortcut icon" href="myicon.ico" /> So, best practice would probably, I'm assuming, be to do a preg_match for the "myicon.ico". My problem is just that I seem to be struggling with reg exps.Tips?
  6. Thanks guys, Teng84 hit it on the nail, never ran across those functions before, very handy!I run a very large mobile internet directory, and some of the links are in the formats listed above. That's why I needed to be able to break each link down, so I can display their pretty icons. I have it working now, but I'm not entirely happy with my quick fix. I need to write a preg_match statement. Anyone decent at writing reg exp's? I tried and butchered it.
  7. supertrucker

    Url Function

    Perhaps I'm over thinking this, but here is the scenario:Link 1: http://www.example.comLink 2: http://www.example.com/Link 3: http://www.example.com/index.phpLink 4: http://www.example.com/index.php?var=123Link 5: http://www.example.com?var=123All of these links are pointing to the exact same location, but they are all different. I need a method to break down any version to just the http://www.example.com so I can append the address to http://www.example.com/favicon.ico.Things get even more confusing with addresses like:1: http://www.example.com.au/2: http://www.example.com.au/dir/index.php?var=123...where all I need is the http://www.example.com.au part.Any tips on how to achieve this? I'm clunking my head against a wall right now in frustration :)Thanks!
  8. I guess I need to do a little reading up on Javascript. When it comes to mobile applications, using Javascript isn't practical since not all mobile browsers support it. However, that's beginning to change as the newer phones sport more advanced browsers. Even most of the dumb phones I've had included a simple subset of Javascript, but I've never read anywhere when it's okay to use it for mobiles, just always do what you can for the user server side.For personal use, however, I will have to play around with it and see what cool stuff I can do client side.Thanks for the support!
  9. The solution is solved, but if you're curious, the intent was the following:1. A bookmarklet uses Javscript to forward the current page address to extract.php.2. Extract.php uses cUrl to extract the pages meta data.3. Extract.php forwards this new information to a link submission form, submitlink.php.4. Submitlink.php receives the data and prefills out a form with the data collected. User reviews data and submits the data.Works great now that I'm using $_sessions like I should have from the get go! Of course, now that I think about it, couldn't javascript have been used to extract all the metadata in the first place?What's a bookmarklet? Little piece of javascript that you save as a bookmark. Works wonderfully for forwarding web pages, saving bookmarks for social bookmarking sites, etc.
  10. The solution is solved, but if you're curious, the intent was the following:1. A bookmarklet uses Javscript to forward the current page address to extract.php.2. Extract.php uses cUrl to extract the pages meta data.3. Extract.php forwards this new information to a link submission form, submitlink.php.4. Submitlink.php receives the data and prefills out a form with the data collected. User reviews data and submits the data.Works great now that I'm using $_sessions like I should have from the get go! Of course, now that I think about it, couldn't javascript have been used to extract all the metadata in the first place?What's a bookmarklet? Little piece of javascript that you save as a bookmark. Works wonderfully for forwarding web pages, saving bookmarks for social bookmarking sites, etc.
  11. Thanks for the reply, I was thinking about this one way too hard! Used Sessions, problem solved, hate it when that happens!
  12. That's just it, how do you preserve post data with a redirect?
  13. Is there a way to send POST data with the header function? I.e., right now, I'm doing this:header("Location: http://blah.com?reallylongdatahere");...which is breaking, I'm assuming because the GET method I'm using has a 100 character limit. Any ideas?
  14. Thank you, that second link has a very well put together explanation!
  15. I'm having trouble understanding how the preg_match function works, furthermore, the code examples I read further confuse me! I use this code below as part of a "bookmarklet" for my site, but the code was essentially copy and pasted (it's utilizing cUrl functions). I basically understand what the preg_match function does, it parses text. What I don't understand is how get it to do what you want. The code below works for getting the "<title>" tag from a remote web page. Could somebody please explain the different parts of the preg_match function below? For instance, what are all the slashes "\/" for? What's with the (.+)? Why does the closing title tag have two slashes? What does the "/siU" mean? include("get_web_page.php"); $url=$_REQUEST['URL']; $header=get_web_page($url); $content=$header['content']; $url=$header['url']; $cerror=$header['errno']; /* get page's title */ preg_match("/<title>(.+)<\/title>/siU", $content, $matches); $title = $matches[1]; Thanks for any help!
×
×
  • Create New...