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