Getting data from MySQL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Getting data from MySQL

Post by Celauran »

You've redirected all traffic to your controller page via .htaccess?
someguyhere
Forum Contributor
Posts: 181
Joined: Sun Jul 27, 2008 3:24 pm

Re: Getting data from MySQL

Post by someguyhere »

I've tried, but I isn't working as it should. I'm assuming I need to set it up differently than a normal 301?

How would I set up the .htaccess file in this case?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Getting data from MySQL

Post by Celauran »

Try something like this

Code: Select all

# Turn on URL rewriting
RewriteEngine On

# Protect hidden files from being viewed
<Files .*>
	Order Deny,Allow
	Deny From All
</Files>

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]
someguyhere
Forum Contributor
Posts: 181
Joined: Sun Jul 27, 2008 3:24 pm

Re: Getting data from MySQL

Post by someguyhere »

Works like a charm! Thanks again!
someguyhere
Forum Contributor
Posts: 181
Joined: Sun Jul 27, 2008 3:24 pm

Re: Getting data from MySQL

Post by someguyhere »

By the way Celauran, is there a simple way to modify the existing code to load the contents of the entire row (the data for the page contents) into another array so that I don't have to make 2 DB calls?

If it helps, my db is set up as such:

Image
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Getting data from MySQL

Post by Celauran »

someguyhere wrote:By the way Celauran, is there a simple way to modify the existing code to load the contents of the entire row (the data for the page contents) into another array so that I don't have to make 2 DB calls?
Just change the query to "SELECT * FROM ag_pages WHERE page_url = '{$_SERVER['REQUEST_URI']}'". If the page isn't there, the query will return false. You won't need your in_array check anymore, either.
Post Reply