Xampp for Windows can't read files? can't post to web server

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Xampp for Windows can't read files? can't post to web server

Postby albatroz » 26. January 2007 23:04

I have this script whose purpose is extract data from the last line of a log file, build an URL and then submit it to a webserver.

However although this script works fine in a Linux installed Apache + PHP (from CentOS) it seems to be not working with the PHP included with the latest version of Xampp (for Windows). It seems that it can open the log file, but can't read anything and also can't post info to the web server.

Are there any limitations on the PHP version installed by Xampp?


<?php
$date = date("Y-m-d");
$ip = "127.0.0.1"; // Server Address
$port = "9638"; // Server Port
$pass = "Password"; // Admin Password
$file = $date . "-playlog.txt"; // Archivo Log

$fp = fopen($file , "r");
while (!feof($fp))
{
$song .= fread($fp, 1024);
}
fclose($fp);
$songs = explode ("\n",$song);
$x = sizeof($songs)-1;
$song = $songs[$x];

$songs = explode (" ",$song);
$song = "";
for ($i=2;$i<sizeof($songs);$i++)
{
$song .= $songs[$i] . " ";
}

$song = urlencode($song);
$song = str_replace("+", "%20", $song);

$fp = @fsockopen($ip,$port,$errno,$errstr,4);
if (!$fp)
{
print "Error: cant get server, please check that server is online";
}
else
{
fputs($fp, "GET /admin.cgi?pass=" . $pass . "&mode=updinfo&song=" . $song . " HTTP/1.0\r\n");
fputs($fp, "User-Agent: Mozilla\r\n\r\n");
fclose($fp);
$song = str_replace("%20", "+", $song);
$song = urldecode($song);
print "Titulo Adicionado: <b>$song</b>";
}
?>


albatroz
 
Posts: 4
Joined: 26. January 2007 22:43

Postby Wiedmann » 26. January 2007 23:11

It seems that it can open the log file,

You have an error message?
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby albatroz » 26. January 2007 23:13

Nope.
No error message, at all...
Actually. It seems that it can open the file, but can't read anything in it.
albatroz
 
Posts: 4
Joined: 26. January 2007 22:43

Postby Wiedmann » 26. January 2007 23:16

No error message, at all...

Well, why did you think PHP can't read the file, if there is no error message in the fopen() / fread() function?
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby albatroz » 26. January 2007 23:34

Because I can run the same exactly file in a Linux box,
without problems...
albatroz
 
Posts: 4
Joined: 26. January 2007 22:43

Postby Wiedmann » 26. January 2007 23:39

Because I can run the same exactly file in a Linux box,
without problems...

This doesn't matter... ;-)

You should do a normal debugging, and find out in which line an error occur (or a not aspected program behaviour).
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 33 guests