|
|
|
|
![]() ![]() |
Dec 12 2007, 07:23 AM
Post
#11
|
|
|
Premium Member Group: [HOSTED] Posts: 415 Joined: 16-February 06 From: Kolkata, India Member No.: 11,322 myCENTs:67.18 |
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"); |
|
|
|
Dec 13 2007, 11:42 AM
Post
#12
|
|
|
Newbie [ Level 2 ] 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); ?> |
|
|
|
Dec 13 2007, 01:56 PM
Post
#13
|
|
|
Premium Member 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).
|
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 5th December 2008 - 02:01 AM |