moffo Posted July 3, 2008 Share Posted July 3, 2008 hello, i have some bad problems in the script. please have a look articles.php: <?php include 'settings.php'; function loadContent($articleNumber){ global $a; $contentName=$a[$articleNumber].".php"; $f=@file_get_contents("./articles/".$contentName); if($f)echo $f; else echo "Loading failed"; } ?> articles_mysql.php: <?php function loadContent($articleNumber){ $conn = mysql_connect("localhost", "root", "Vulkan"); mysql_select_db("labs",$conn); $sql="select * from articles where id='".$articleNumber."'"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $articleName=$row['articleName'].".php"; mysql_close($conn); $f=@file_get_contents("./articles/".$articleName); if($f)echo $f; else echo "Loading failed"; } ?> index.php: <?php include "articles.php"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Loading contents</title> </head> <body> Here we will load an article that get its contents depending on the ID we send using GET method through the URL string<br> so add an ID in the URL like localhost/contents/?ID=2<br> or localhost/contents/index.php?ID=2<br> <div style="border:1px red dashed;width:400px;height=200;overflow:auto;padding:3px"> <?php loadContent($_GET['ID']); ?> </div> <p>Here we will load a specific article not related to what user sends through the URL, but using known article number</p> <?php loadContent(1); ?> </body> </html> settings.php: <?php $a=array( "article0", "article1", "article2", "article3", "article4", "article5", "article6", "article7", "article8" ); ?> and here we open a folder called articles and in this folder we upload article1.php : <?php include("anything-you-want.php"); ?> the include doesnt work, why? can someone help me to make this done? thanks Link to comment https://forums.phpfreaks.com/topic/113136-include-doesnt-work/ Share on other sites More sharing options...
moffo Posted July 3, 2008 Author Share Posted July 3, 2008 someone? Link to comment https://forums.phpfreaks.com/topic/113136-include-doesnt-work/#findComment-581320 Share on other sites More sharing options...
trq Posted July 3, 2008 Share Posted July 3, 2008 Your question makes little sense. Which include call are you talking about? And please, use tags when posting code. Link to comment https://forums.phpfreaks.com/topic/113136-include-doesnt-work/#findComment-581326 Share on other sites More sharing options...
lemmin Posted July 3, 2008 Share Posted July 3, 2008 Can you post the generated html and the source code of the file you are including? Link to comment https://forums.phpfreaks.com/topic/113136-include-doesnt-work/#findComment-581328 Share on other sites More sharing options...
teynon Posted July 3, 2008 Share Posted July 3, 2008 If you're trying to include / execute an uploaded PHP file.... dont. Its a bad idea and you should never do it. Not only that but it wont let you do it unless you mess with a bunch of settings. Link to comment https://forums.phpfreaks.com/topic/113136-include-doesnt-work/#findComment-581329 Share on other sites More sharing options...
moffo Posted July 3, 2008 Author Share Posted July 3, 2008 but i have done an article1.php with include in it and it does not work, someone know why that happens? Link to comment https://forums.phpfreaks.com/topic/113136-include-doesnt-work/#findComment-581334 Share on other sites More sharing options...
moffo Posted July 3, 2008 Author Share Posted July 3, 2008 someone? :'( Link to comment https://forums.phpfreaks.com/topic/113136-include-doesnt-work/#findComment-581371 Share on other sites More sharing options...
TransmogriBenno Posted July 3, 2008 Share Posted July 3, 2008 Your question makes little sense. Which include call are you talking about? And please, use tags when posting code. If you don't answer questions like this, it's unlikely that you'll get help. Link to comment https://forums.phpfreaks.com/topic/113136-include-doesnt-work/#findComment-581380 Share on other sites More sharing options...
moffo Posted July 3, 2008 Author Share Posted July 3, 2008 and here we open a folder called articles and in this folder we upload article1.php : <?php include("anything-you-want.php"); ?> the include doesnt work, why? can someone help me to make this done? also why dont you try the script i gave above ? Link to comment https://forums.phpfreaks.com/topic/113136-include-doesnt-work/#findComment-581382 Share on other sites More sharing options...
maxudaskin Posted July 3, 2008 Share Posted July 3, 2008 It may be disabled on your server. Link to comment https://forums.phpfreaks.com/topic/113136-include-doesnt-work/#findComment-581387 Share on other sites More sharing options...
moffo Posted July 4, 2008 Author Share Posted July 4, 2008 It may be disabled on your server. no man see this links: http://halimaboland.awardspace.com/index.php and http://halimaboland.awardspace.com/anything-you-want.php the problem is with the script above, go and look more carefully if you are a real PHP master. Link to comment https://forums.phpfreaks.com/topic/113136-include-doesnt-work/#findComment-581405 Share on other sites More sharing options...
Bendude14 Posted July 4, 2008 Share Posted July 4, 2008 comments like that aint gonna get you help of anyone... Post the code in the code tags like already mentioned Your question makes little sense. Which include call are you talking about? And please, use tags when posting code. and be more specific what error messages are you getting etc Link to comment https://forums.phpfreaks.com/topic/113136-include-doesnt-work/#findComment-581457 Share on other sites More sharing options...
moffo Posted July 4, 2008 Author Share Posted July 4, 2008 it doesnt display any error it just dont show anythng man man man Link to comment https://forums.phpfreaks.com/topic/113136-include-doesnt-work/#findComment-581472 Share on other sites More sharing options...
Juan Dela Cruz Posted July 4, 2008 Share Posted July 4, 2008 put this on top of your code before php tags maybe error_reporting(E_ALL); to display error.. and sorry i don't understand the real problem Link to comment https://forums.phpfreaks.com/topic/113136-include-doesnt-work/#findComment-581476 Share on other sites More sharing options...
trq Posted July 4, 2008 Share Posted July 4, 2008 I'll ask again. Which include call are you talking about? Link to comment https://forums.phpfreaks.com/topic/113136-include-doesnt-work/#findComment-581477 Share on other sites More sharing options...
moffo Posted July 4, 2008 Author Share Posted July 4, 2008 read my first post and you will see what i talk about Link to comment https://forums.phpfreaks.com/topic/113136-include-doesnt-work/#findComment-581487 Share on other sites More sharing options...
trq Posted July 4, 2008 Share Posted July 4, 2008 Read the link in my signiture about how to ask a question, this is going nowhere. Link to comment https://forums.phpfreaks.com/topic/113136-include-doesnt-work/#findComment-581488 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.