Jump to content

Won't go through function


kyles0623

Recommended Posts

 

I have an index page. The PHP for it is:

 

<?php
$obj->display_article();
?>

 

The first function code is:

 

function display_article(){
echo "asdf....";
if(isset($_GET['id'])):
echo "sadf....";
	get_content($_GET['id']);
else:
echo "asdf....";
	$obj->get_content();
endif;
}

 

and then the other function is:

 

function get_content($id = ''){
echo "asdfjkl;";
if($id!=""):
	$id=mysql_real_escape_string($id);
	$sql = "SELECT * FROM cms_content WHERE id = '$id'";
else:
	$sql = "SELECT * FROM cms_content ORDER BY id DESC";
endif;

$res = mysql_query($sql) or die(mysql_error());

if(mysql_num_rows($res) != 0):
	while($row = mysql_fetch_assoc($res)){
	echo '<h1><a href="index.php?id='. $row['id']. '">' . $row['title'] . "</a></h1>";
	echo "<p>" . $row['body'] . "</p>";
	}
else:
	echo "<p>UH OH! THAT DON'T EXIST BUDDDD!</p>";
endif;

}

 

My result code when I look at the source code for the page is:

<html>
<head>
<title>Testing Site</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>


<body>
<div id="page-wrap">
asdf....asdf....

 

It goes through the first function but not the second function because it doesn't echo the text i tell it to at the beginning of the function and then kills the rest of the code on the page. Can anyone help?

Link to comment
https://forums.phpfreaks.com/topic/206143-wont-go-through-function/
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.