kyles0623 Posted June 29, 2010 Share Posted June 29, 2010 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 More sharing options...
trq Posted June 29, 2010 Share Posted June 29, 2010 You haven't really given us much to go on but I would guess.... Within your first method, change.... $obj->get_content(); to $this->get_content(); Link to comment https://forums.phpfreaks.com/topic/206143-wont-go-through-function/#findComment-1078574 Share on other sites More sharing options...
kyles0623 Posted June 29, 2010 Author Share Posted June 29, 2010 that worked. thankyou very much. Im new to classes. lol. Once again thankyou. Link to comment https://forums.phpfreaks.com/topic/206143-wont-go-through-function/#findComment-1078576 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.