Newbie/PHP Page won't load

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

Newbie/PHP Page won't load

Postby freedomsks » 08. July 2007 07:08

Thanks for provding this forum to answer questions and learm more about xampp!

Any help would be appreciated with my below described issue.

I just installed XAMPP on win xp. Everything is working and I can view the default pages in http://localhost

I have copied a php script file into the htdocs/xampp directory and then browsed to it at http://localhost/xampp/csv2xml.php.

I just get a blank white page that tries to load but never does. This script converts a csv file into a specially formatted XML file and also generates md5 checksums for mp3 files referenced in the csv data. This is done through an upload form in the php file.

This page and script load fine on my proffessionaly hosted web account I have. Just not loading on xampp. Here's my script. I didn't code it, I've paid somebody to do it. I know very little or next to nothing about scripting.

[<?php
//Check if the file has been submitted for processing
if($_POST['submit']){
$target_path = "./";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded<br>\n";
} else{
echo "There was an error uploading the file, please try again!";
}

$parse_file = "./" . $_FILES['uploadedfile']['name'];
$static_fields = 24;
$row = 1;
$info_array = array();
$track_array = array();
$array_list = array();
$handle = fopen($parse_file, "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$info_array = array();
$num = count($data);
for ($c=0; $c < $num; $c++) {
//echo $c . " " . $data[$c] . "<br />\n";
if($row > 1){
array_push($info_array, $data[$c]);
}
}
array_push($array_list, $info_array);
$row++;
}

$array_temp = array_shift($array_list);
foreach($array_list as $info_array){
//Build the string to get written to the xml output files
$outstring = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$outstring .= "<package version=\"music2.2\">\n";
$outstring .="<language>en</language>\n";
$outstring .="<provider>Horizon Music</provider>\n";
$outstring .="<album>\n";
$outstring .="<album_vendor_id>$info_array[0]</album_vendor_id>\n";
$outstring .="<album_upc>$info_array[15]</album_upc>\n";
$outstring .="<album_title>$info_array[2]</album_title>\n";
$outstring .="<album_release_date>$info_array[10]</album_release_date>\n";
$outstring .="<album_original_release_year>$info_array[5]</album_original_release_year>\n";
$outstring .="<album_label_name>$info_array[7]</album_label_name>\n";
$outstring .="<album_genres>\n";
$outstring .="<genre>$info_array[4]</genre>\n";
$outstring .="</album_genres>\n";
$outstring .="<album_explicit_lyrics>\n";
$outstring .="$info_array[16]";
$outstring .="</album_explicit_lyrics>\n";
$outstring .="<album_copyright_cline>$info_array[6] $info_array[7]</album_copyright_cline>\n";
$outstring .="<album_copyright_pline>$info_array[8] $info_array[9]</album_copyright_pline>\n";
$outstring .="<album_artwork_files>\n";
$outstring .="<file>\n";
$outstring .="<file_name>" . escape_xml($info_array[0]) . ".jpg</file_name>\n";
$image_filename = "albums/$info_array[0]/" . escape_xml($info_array[0]) . ".jpg";
//Check if the image file is there and calculate the md5 checksum or output an error
if(file_exists($image_filename)){
$outstring .="<checksum type=\"md5\">" . md5_file("$image_filename") . "</checksum>\n";
} else {
$outstring .="<checksum type=\"md5\">ERROR: File Does Not Exist!</checksum>\n";
}
$outstring .="</file>\n";
$outstring .="</album_artwork_files>\n";
$outstring .="<album_products>\n";
$outstring .="<product>\n";
$outstring .="<territory>$info_array[13]</territory>\n";
$outstring .="<sales_start_date>$info_array[11]</sales_start_date>\n";
$outstring .="<wholesale_price_tier>$info_array[14]</wholesale_price_tier>\n";
$outstring .="</product>\n";
$outstring .="</album_products>\n";
$outstring .="<album_artists>\n";
$outstring .="<artist>\n";
$outstring .="<name>" . escape_xml($info_array[1]) . "</name>\n";
$outstring .="<roles>\n";
$outstring .="<role>Primary</role>\n";
$outstring .="</roles>\n";
$outstring .="</artist>\n";
$outstring .="</album_artists>\n";
$outstring .="<album_tracks>\n";
$flag = 1;
$track_number = 1;
$loop_count = 0;
$total_num_tracks = return_track_count($info_array);
//Loop through the array from the 17th index to the last index - 7 for formatting
for($x=17; $x < sizeof($info_array) - 7; $x = $x+0){
if($info_array[$x] > ''){
$track_isc_index = $x + 2;
$track_title_index = $x;
$track_filename = $x + 1;
$outstring .="<track>\n";
$outstring .="<track_volume_number>1</track_volume_number>\n";
$outstring .="<track_volume_count>1</track_volume_count>\n";
$outstring .="<track_track_number>$track_number</track_track_number>\n";
$outstring .="<track_track_count>$total_num_tracks</track_track_count>\n";

$outstring .="<track_title>" . escape_xml($info_array[$track_title_index]) . "</track_title>\n";
$x++;
$outstring .="<track_isrc>$info_array[$track_isc_index]</track_isrc>\n";
$x++;
$outstring .="<track_audio_file>\n";
$outstring .="<file_name>" . escape_xml($info_array[$track_filename]) . "</file_name>\n";
//Check if the audio file is there and calculate the md5 checksum or output an error
if(file_exists("albums/$info_array[0]/$info_array[$track_filename]")){
$outstring .="<checksum type=\"md5\">" . md5_file("albums/$info_array[0]/" . escape_xml($info_array[$track_filename])) . "</checksum>\n";
} else {
$outstring .="<checksum type=\"md5\">ERROR: File Does Not Exist!</checksum>\n";
}
$outstring .="</track_audio_file>\n";
$outstring .="<track_cleared_for_sale>" . $info_array[sizeof($info_array) - 4] . "</track_cleared_for_sale>\n";
$outstring .="<track_gapless_play>" . $info_array[sizeof($info_array) - 3] . "</track_gapless_play>\n";
$outstring .=" <track_explicit_lyrics>" . $info_array[sizeof($info_array) - 5] . "</track_explicit_lyrics>\n";
$outstring .="<track_preview_start_index>" . $info_array[sizeof($info_array) - 2] . "</track_preview_start_index>\n";
$outstring .="<track_products>\n";
$outstring .="<product>\n";
$outstring .="<territory>" . $info_array[sizeof($info_array) - 1] . "</territory>\n";
$outstring .="</product>\n";
$outstring .="</track_products>\n";
$x++;
$outstring .="</track>\n";
$track_number++;
} else {
$x = $x + 3;
}
}
$outstring .="</album_tracks>\n";


$outstring .="</album>\n";

$outstring .="</package>\n";
$filename = $info_array[0];
if($filename){
$myPath = "albums/$filename/";
$myFile = "$myPath" . "metadata.xml";
if(is_writable($myPath)){
$fh = fopen($myFile, "w") or die("Couldn't open file for writing");
fwrite($fh, $outstring) or die("Couldn't open $filename for writing");
fclose($fh);
echo "$myFile has been created, renaming folder from " . $myPath . " to albums/" . $info_array[15] . ".itmsp ... ";

// Rename folder to UPC name
rename($myPath, "albums/" . $info_array[15] . ".itmsp");
echo "done<br>\n";

} else {
//Directory doesn't exist or is not writable
echo "asfdasdfasdfasdf";
echo "<b>FAILED $myFile has not been created. Directory doesn't exist or is not writable<br></b>\n";
}
}
}
fclose($handle);
} else {
//Nothing submitted. Output the entry form.
?>


<head>
<title>SongCast Admin Panel</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="http://www.songcastmusic.com/admin/css/api.css" rel="stylesheet" type="text/css">
</head>


<body topmargin="0" leftmargin="0" bottommargin="0" rightmargin="0">
<table width="100%" height="100%" border="1" cellpadding="0" cellspacing="0">
<tr>
<td valign="top"><table width="100%" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td height="53" bgcolor="#006699"><div align="center"><strong>
<font color="#FFFFFF">CSV 2 XML SCRIPT</font></strong></div></td>
</tr>
<tr>
<td align="right"><b>Welcome</b> <font color="#3399FF">
<?=$_SESSION['logged_in_admin']?>
! </font><a href="http://www.songcastmusic.com/admin/index.php?act=logout"><b>Logout</b></a> </td>
</tr>
<tr>
<td> <div align="center"> <a href="http://www.songcastmusic.com/admin/admin.php">
[ Back to Admin
Panel ]</font></a></div><br>
<div align="center"><font size="1" color="red"><b><? echo $log; ?></b></font></div><br> <br>

<table width="50%" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="25" align="center" bgcolor="#006699"><strong>
<font color="#FFFFFF">Upload CSV File</font></strong></td>
</tr>
<tr>
<td width="21%" height="29" bgcolor="#CCCCCC">


<form enctype="multipart/form-data" action="<?=$PHP_SELF?>" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
<p align="center"><br>
Choose a csv file to upload: <input name="uploadedfile" type="file" size="20" /><br>
<br />
<input type="submit" name='submit' value="Upload File" /> </p>
</form>







</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="40" valign="top" bgcolor="#006699">&nbsp;</td>
</tr>
</table>
</body>


<?php
}
//Function to return the amount of tracks per line entry
function return_track_count($arr){
$track_count = 0;
for($x=17; $x < sizeof($arr) - 7; $x = $x+0){
if($arr[$x] > ''){
$track_count++;
$x = $x + 3;
} else {
$x = $x + 3;
}
}
return $track_count;
}
//function to fixup and remove illegal xml characters
function escape_xml($input){
$input = str_replace("&", "&amp;", $input);
$input = str_replace("<","&lt;", $input);
$input = str_replace(">","&gt;", $input);
return $input;
}
?>
][/code]
freedomsks
 
Posts: 1
Joined: 08. July 2007 06:53

Postby SlisheR » 08. July 2007 22:42

Try this and check if PHP is installed:
<? phpinfo(): ?>


If it is, the error might be in your PHP script (the script you placed in the xampp dir).
SlisheR
Correct me if I'm wrong!
SlisheR
 
Posts: 18
Joined: 06. July 2007 19:27
Location: The Netherlands


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 210 guests