Welcome Guest ( Log In | Register )



2 Pages V  < 1 2  
Reply to this topicStart new topic
> Include() Question
turbopowerdmaxst...
post Dec 12 2007, 07:23 AM
Post #11


Premium Member
Group Icon

Group: [HOSTED]
Posts: 415
Joined: 16-February 06
From: Kolkata, India
Member No.: 11,322
myCENTs:67.18



QUOTE(Supa Comix @ Dec 11 2007, 08:59 PM) *
Thanks but i don't fully understand the code...

Would i be able to use php and mysql to set the Get code?
Where would i put this?
How would i extract the data at the supa comix end?


Remember that in this way, you are not including the file, rather reading it from another site as an HTML.

Say your news is stored in a MySQL table. Create a file http://galx.ulmb.com/news.php that outputs this news. Now, whenever you open this URL, the recent news is echo-ed. All you need to do now is read this from the Super Comix site. The code I wrote before will do just that.

You can also pass parameters to the file news.php to retrieve the news for say a specific date/topic. For example, http://galx.ulmb.com/news.php?topic=sports outputs all the sports news. To read this file, just change the GET header to: fputs($fp, "GET /news.php?topic=sports HTTP/1.1\n");
Go to the top of the page
 
+Quote Post
Supa Comix
post Dec 13 2007, 11:42 AM
Post #12


Newbie [ Level 2 ]
Group Icon

Group: Members
Posts: 24
Joined: 9-August 07
Member No.: 23,954



Right i set up the two pages. One reads the news and then uses an echo function to post it. The other links to the file but on running it just shows a black page with no source.

This is the page its reading: (test.php on Gal x)

CODE
<?php
      $sql = mysql_query("SELECT lastposter, lastposttid, lastpostsubject FROM mybb_forums WHERE fid='4'") or die("Error Line: " . mysql_error());
        while ($row = mysql_fetch_array($sql)){
            $lastposter = $row["lastposter"];
            $lastpostid = $row["lastposttid"];
            $lastpostsubject = $row["lastpostsubject"];
        }
        echo("<font size='2'><a href='/forum/showthread.php?tid=" . $lastposttid . "'>" . $lastpostsubject . "</a></font><BR><font size='-3'>by: " . $lastposter . "</font>");
?>


and this is the code of the page "test2.php on the supa comix website:

CODE
<?php
// Open the Socket
$fp = fsockopen('www.galx.ulmb.com', 80);

// Make the request
fputs($fp, "GET /test.php HTTP/1.1\n");
fputs($fp, "Host: www.galx.ulmb.com\n");
fputs($fp, "Connection: Close\n\n");     // Send two New Lines to Signal Header End

// Read the Output
$readText = "";
while(!feof($fp))
{
$readText .= fgets($fp);
}

// Never forget to end what you started
fclose($fp);
?>
Go to the top of the page
 
+Quote Post
turbopowerdmaxst...
post Dec 13 2007, 01:56 PM
Post #13


Premium Member
Group Icon

Group: [HOSTED]
Posts: 415
Joined: 16-February 06
From: Kolkata, India
Member No.: 11,322
myCENTs:67.18



All the news content is now in the $readText variable. You can do anything with it beyond the while loop (and preferably below the fclose too).
Go to the top of the page
 
+Quote Post

2 Pages V  < 1 2
Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Question About Professional 3d Animating(21)
  2. Mp3 Questions(14)
  3. Question About Asp Now() Function(6)
  4. How To Install Applications In Fedora(12)
  5. MySQL Output Database Question(18)
  6. Web Browser And Taskbar Problems (web Browser Disappears)(7)
  7. VB.NET / MS Access Question(6)
  8. What's The Best CMS(38)
  9. Ipod Hardware And Software Question(9)
  10. Include Function For Javascript(7)
  11. Do Google Search Better Than Yahoo?(15)
  12. Overclocking Core 2 Quad(4)
  13. Concept Of Hijaab In Islaam(2)
  14. Private Servers Question(13)
  15. Dynamic Php Image And Better Php Code Question(10)
  1. Any1 Loves Listening 2 Anime/japanese Songs?(4)
  2. Joomla License Question(1)
  3. Simple Java Question(3)
  4. Php Question, Help Please(5)
  5. Question About Opengl Codes.(0)
  6. Css Minus The <p>(9)
  7. Question: Ssh Tunneling(1)
  8. Pointers(0)
  9. Question Related To Website(5)
  10. Ask An Open Question 404 (and A Confused Noob)(3)
  11. How To Include A File Using Absolute Paths Under A Secure Php Installation(6)
  12. Google Calendar Question(4)
  13. How Do I Get Rid Of Warn: (0%) ----- ?(9)


 



- Lo-Fi Version Time is now: 5th December 2008 - 02:01 AM