Jump to content

Johntron

Members
  • Posts

    25
  • Joined

  • Last visited

    Never

About Johntron

  • Birthday 02/12/1985

Contact Methods

  • AIM
    j0hn7r0n
  • Website URL
    http://www.johntron.com/
  • Yahoo
    j0hn7r0n

Profile Information

  • Gender
    Male
  • Location
    Dallas, TX

Johntron's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. basename( $url ); Example: $url = 'http://www.johntron.com/index.php'; echo basename( $url ); // Output: index.php
  2. I'm not sure if this is the only solution, but this is how I always see it done . . . in you .htaccess put: RewriteEngine on RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php This will redirect requests to everything other than media files (files with extensions: js, ico, gif, jpg, png, and css) to index.php, internally. In index.php, you would then parse the $_SERVER['REQUEST_URI'] variable and run the appropriate code. A sample request: 1. User opens browser to http://www.domain.com/posts/how-to-use-modrewrite/ 2. Apache (specifically, mod_rewrite) notices that this is not a media request, so it runs index.php. This does _not_ perform an HTTP redirect. 3. index.php parses $_SERVER['REQUEST_URI'] and runs some code to generate some output, which is then sent back to the user. This process of parsing an HTTP request, and deciding which code to run is commonly called the Router design pattern. The index.php file could be said to use the Front Controller design pattern. Here's a very simplistic example of what your index.php file might look like: <?php // Assume the user requested: http://www.domain.com/posts/how-to-use-modrewrite/ if ( 0 === strpos( $_SERVER['REQUEST_URI'], '/posts/' ) ) { // User wants to do something with blog posts, so instantiate the Blog class $blog = new Blog(); $title = substr( $_SERVER['REQUEST_URI'], 7 ); // Strip out the title; 7 is the position in the string that the title starts $content = $blog->getContentByTitle( $title ); include 'postTemplate.phtml'; // This file would consist of mostly HTML, but would also echo $title and $content at some point // closing php tag is not necessary here and should be left out, but that's a whole other topic This is untested code, but you should get the basic idea.
  3. It looks like the following line isn't working as expected: $db = NewADOConnection("mysql://$user:$pwd@$server/$db?persist"); $db is probably false after that point, because the NewADOConnection() is obviously not returning an object. Be sure to add some exception handling there
  4. I think you may be asking about Search Engine Friendly (SEF) URLs in Wordpress (which the folks at Wordpress call "permalinks"). I'm not sure when the feature appeared, but you can specify the permalinks for each article (see attachment) [attachment deleted by admin]
  5. Use CSS clipping (similar to sprites) for the rounded corners to reduce page weight. There's a few web services to analyze the content of your website to give you an estimate of which keywords will appear most relevant from a spider's perspective. If you really want to build traffic, and not just rank for specific keywords, you should try out a keyword analysis tool. Take a look at textalyser.net and seobook.com. Oh, and I'm not sure what your intentions are, but this may save you a headache. If you want to use Flash, be sure to offer an HTML version of the relevant content (text containing keywords and any links). Use progressive enhancement to replace the bland HTML with Flash, just make sure both versions of the content contain the same information (unless you like being wiped off the map by the likes of Google).
  6. I would trying improving the semantics on your page. Start using <h1> through <h6> tags for titles of articles. Search engines will give the text inside of these tags more relevance (put the keywords you're trying to target in there). Make your <title> more relevant (again, keywords) Titles are the most relevant piece of text. Make your banner more relevant as well. Try putting some text in a <h1> and maybe a subheading in a <h2>. You can use CSS to move these off screen so people don't see the text, and then put a background image in the parent element. Just make sure the text in the image matches the text in the heading tags; otherwise, Google might blacklist you for misleading HTML. See reviewanalyst.com as an example of this. Also, try removing irrelevant content, if possible. Ideally, you'd have only relevant text, but obviously this isn't possible (navigation, attributions, etc). Be clean about it too. Search engines are very good about picking up on hacks. Page weight. Search engines don't like waisting time. They're more apt to crawl your site if you reduce page weight. You have a lot of external files (CSS and Javascript). Combine these into one to cut down on load time. Get Firebug and Yslow to help improve here. Enable Gzip compression if you can (this has the added benefit of reducing bandwidth usage). Sign up for Google Analytics, or something similar to help you track your traffic. Optimize pages to help users find the information they want, so when they do find your page, they're more likely to come back. You could also use mod_rewrite and PHP to make your URLs themselves more relevant (use article titles in the urls). Make your URLs descriptive. If anything, users may see the raw URL lying around somewhere on the internet and click on it because they like what the URL says. Other than that, keep creating relevant content, but most importantly, get external links that point to it. Hope this helps!
  7. preg_match_all('/href=["\'](/download/[^"\']+)["\']/', $line, $matches);
  8. You're not escaping the quotes. Paste your preg_match() code.
  9. I've been doing a lot of this lately /href=["'](/download/[^"']+)["']/ The parentheses capture the URL.
  10. If the name attributes in your form matches up with your DB's field name, you could do something like this . . . unset( $_POST[ 'submit'], $_POST[ 'agree'] ); // Just for demonstration. Be sure you remove any fields not going in the DB $q = 'insert into `table` set '; while ( list( $field, $value ) = each( $_POST ) ) { $q .= $field . ' = "' . mysql_real_escape_string( $value ) . '", '; } $q = rtrim( ', '); mysql_query( $q ); Of course, you could wrap all of this in a function, and then just do something like: saveCleanedForm( $_POST );
  11. At the very least, use mysql_real_escape_string on any user input before inserting it into the database. http://us.php.net/manual/en/function.mysql-real-escape-string.php hackthissite.org is a good place to learn about SQL injections and more. Hands on hacking tutorials, woohoo!
  12. I like the first one, because it's clear what fields you're updating. I doubt you need to include 'id' in your query. It probably auto increments itself. There's one other way to do inserts: INSERT INTO db_name set name = '$name', email = '$email', time = '$time'; Also, I'd be sure you use the date/time datatypes that MySQL offers, because they make searching by date easier later on.
  13. Looks good, but you still have to pass the resulting $query to mysql_query(). Your code still has a serious security vulnerability too though. It'd be really easy for someone to see things they shouldn't with a simple SQL injection.
  14. I bet mysql_error() has something for you to read http://www.php.net/manual/en/function.mysql-error.php Also, don't insert data from the user without sanitizing it first. The way you've written your code makes it pretty easy to view your users table using a very simple SQL injection.
×
×
  • 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.