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
https://forums.phpfreaks.com/topic/210253-going-crazy-with-stupid-phpsql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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