Jump to content

Going crazy with stupid php/sql


aeroswat

Recommended Posts

For some reason both admin and home return home's contents but everything else returns it's own contents...

 

	
<?php	if(!isset($_GET['p'])) {
	$result = mysql_query("SELECT * FROM body WHERE name='home'");
?>
<script type="text/javascript">alert("home");</script>
<?php
} else{
	$result = mysql_query("SELECT * FROM body WHERE name='" . $_GET['p'] . "'");
?>
<script type="text/javascript">alert("SELECT * FROM body WHERE name='<?php echo $_GET['p']; ?>'");</script>
<?php
}

$row = mysql_fetch_array($result);

function changeStuff($str) {
	$str = str_replace("[link=","<a href='",$str);
	$str = str_replace("[/link]","</a>",$str);

	$str = str_replace("[img]http://","<img src='",$str);
	$str = str_replace("[/img]","' />",$str);

	$str = str_replace("[b]","<b>",$str);
	$str = str_replace("[/b]","</b>",$str);

	return $str;
}
?>
	if(!isset($_GET['p'])) {
		include("home.php");
	} else{
		include($_GET['p'] . ".php");
	}
	echo changeStuff($row['content']);
?>

 

There are three rows in my body table. They are as follows

1) (name) = home

    (content) = this is home page

2) (name) = admin

    (content) = this is admin page

3) (name) = eq

    (content) = this is equipment page

 

When $_GET['p'] = home

It displays this is home page

 

When $_GET['p'] = admin

It displays this is home page

 

When $_GET['p'] = eq

It displays this is equipment page

 

The javascript alerts are all displaying the correct information so i don't understand what is fudging it up...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.