PDA

View Full Version : Need help with mysql and php please :)



iJoe
06-09-2008, 02:43 PM
Hey,

I have started making nexdana so that it runs from a mysql database. All is going well except pages with php in arn't working.

I don't really know how this works, I only know how to add / edit pages within the database as Calon set it up for me :)

An example of a page not working is this... http://www.nexdana.com/v3/index_new.php?pageId=7

As you can see the php bits at the top and bottom arn't working

If anyone can help it would be much appreciated :)

Thanks

Joe

Excellent1
06-09-2008, 02:45 PM
Your code isn't being properly closed off somewhere. Post it?

Fehm
06-09-2008, 03:12 PM
Nice bubble shift game, glad youve got it sorted =]

Decode
06-09-2008, 03:21 PM
You need to post the code or no one will know what's wrong with it :P

Dentafrice
06-09-2008, 03:26 PM
Your code isn't being properly closed off somewhere. Post it?

That's not what is wrong.

Are you echoing it all out, or doing sort of a "template system"?

If not.. it looks like it doesn't have PHP installed on your server.. as it's being executed as HTML and not PHP.

Calon
06-09-2008, 03:30 PM
Since when could you execute PHP from MySQL Rows? :S

iJoe
06-09-2008, 05:10 PM
Since when could you execute PHP from MySQL Rows? :S

I don't know..... if I had known you can't, i would have stuck with iframes................................ :(

Dentafrice
06-09-2008, 05:11 PM
You can exec it, using eval(). Just wouldn't recommend it.

iJoe
06-09-2008, 05:12 PM
I'll have to stick with iframes then :P

Decode
06-09-2008, 09:40 PM
I'll have to stick with iframes then :P

Iframes are tacky, this code should act like an Iframe.

INDEX.PHP


The top of your layout code will go here
<?php
$p = addslashes( $_GET['page'] );
if( isset ( $p ) ) {
$p = "/content/" . $p . ".php";
if( file_exists ( $p ) {
include( $p );
}
else {
include( "404.php" );
}
}
else {
$p = "/content/indexpage.html";
include( $p );
}
?>
The bottom of your layout code will go here


To use it you just go to index.php?p=pagename and it would include yoursite.com/content/pagename.php

iJoe
06-09-2008, 10:13 PM
Thanks :) I'll try that out tomorrow +rep

edit: will that code just work with php pages?

Decode
07-09-2008, 09:12 AM
Yeah it will, I will modify the code a bit so it can do html as well.



<?php
$p = addslashes( $_GET['page'] );
if( isset ( $p ) ) {
if ( isset ( $_GET['html'] ) ) {
$p = "/content/" . $p . ".html";
}
else {
$p = "/content/" . $p . ".php";
}
if( file_exists ( $p ) {
include( $p );
}
else {
include( "404.php" ); //Page that is displayed if the file doesnt exist
}
}
else {
$p = "/content/indexpage.php"; //Put the URL to your old homepage that was in the iframe here
include( $p );
}
?>


If a page is .php you do yoursite.com/index.php?page=games and it will include yoursite.com/content/games.php. If its a HTML page you want to include you do yoursite.com/index.php?page=games&html= and it would include yoursite.com/content/games.html.

So all links around your site would need to be done like <a href="http://yoursite.com/index.php?page=a"></a>.

iJoe
07-09-2008, 02:12 PM
Getting an error for some reason :S


Parse error: syntax error, unexpected '{' in /home/nexdana/public_html/v3/erm.php on line 10

Using your code above

Decode
07-09-2008, 04:23 PM
<?php
$p = addslashes( $_GET['page'] );
if( isset ( $p ) ) {
if ( isset ( $_GET['html'] ) ) {
$p = "/content/" . $p . ".html";
}
else {
$p = "/content/" . $p . ".php";
}
if( file_exists ( $p ) ) {
include( $p );
}
else {
include( "404.php" ); //Page that is displayed if the file doesnt exist
}
}
else {
$p = "/content/indexpage.php"; //Put the URL to your old homepage that was in the iframe here
include( $p );
}
?>

iJoe
07-09-2008, 04:48 PM
Hmm, now it is saying no pages exist :( http://www.nexdana.com/v3/erm.php


<?php
$p = addslashes( $_GET['page'] );
if( isset ( $p ) ) {
if ( isset ( $_GET['html'] ) ) {
$p = "http://www.nexdana.com/v3/" . $p . ".html";
}
else {
$p = "http://www.nexdana.com/v3/" . $p . ".php";
}
if( file_exists ( $p ) ) {
include( $p );
}
else {
include( "404.php" ); //Page that is displayed if the file doesnt exist
}
}
else {
$p = "http://www.nexdana.com/v3/home.html"; //Put the URL to your old homepage that was in the iframe here
include( $p );
}
?>

I can't see whats wrong :S

Decode
07-09-2008, 04:56 PM
<?php
$p = addslashes( $_GET['page'] );
if( $p != "" ) {
if ( isset ( $_GET['html'] ) ) {
$p = "http://www.nexdana.com/v3/" . $p . ".html";
}
else {
$p = "http://www.nexdana.com/v3/" . $p . ".php";
}
if( file_exists ( $p ) ) {
include( $p );
}
else {
include( "404.php" ); //Page that is displayed if the file doesnt exist
}
}
else {
$p = "http://www.nexdana.com/v3/home.html"; //Put the URL to your old homepage that was in the iframe here
include( $p );
}
?>


Sorry :P I was tired yesterday when I wrote this.

iJoe
07-09-2008, 05:51 PM
I think it might be me now, still not working :S

Am I right in thinking that http://www.nexdana.com/v3/contact.php should show if I use the url http://www.nexdana.com/v3/erm.php?page=contact ?

It's still saying the pages don't exist

Thanks for your patience by the way :)

Want to hide these adverts? Register an account for free!