jmif96
-
Posts
6 -
Joined
-
Last visited
Never
Posts posted by jmif96
-
-
I've created a small php script that writes info for a podcast to a database, then, when a differen't is pressed, it creates an XML file for that. I do this by opening an SML file with the w attribute. However, I always the error statement in my if/else test when I run it. I cant seem to figure out why. I've give the file 777 permissions also.
Heres the part that writes the XML:
[code]
function compilePodcastXML() {
mysqlConnect();
// open file
$xmlfile = fopen ('podcasts/podcast.xml', "w");
// select SQL records
$sql = "SELECT * FROM podcasts";
$result = mysql_query($sql);
$num = mysql_num_rows($result);
$podcast = mysql_fetch_array($result);
// Write first, static part of XML File
$date = date("D, M d Y H:i:s O");
$xml = "<?xml version="1.0\" encoding=\"UTF-8\"?>
<rss xmlns:itunes=\"http://www.itunes.com/dtds/podcast-1.0.dtd\" version=\"2.0\">
<channel>
<title>xxx</title>
<description>xxxdescription>
<link>xxx</link>
<language>en-us</language>
<copyright>xxx</copyright>
<lastBuildDate>$date</lastBuildDate>
<pubDate>$date</pubDate>
<docs>xxx</docs>
<webMaster>xxx</webMaster>
<itunes:author>xxx</itunes:author>
<itunes:subtitle>xxxitunes:subtitle>
<itunes:summary>xxx</itunes:summary>
<itunes:owner>
<itunes:name>xxx</itunes:name>
<itunes:email>xxx</itunes:email>
</itunes:owner>
<itunes:category text=\"Transportation\">
<itunes:category text=\"Podcasting\" />
</itunes:category> "; // END STATIC XML
// write item statements
for ($i = 0; $i < $num; $i++) {
$xml .= "
<item>
<title>".$podcast['title'][$i]."</title>
<link>".$podcast['infolink'][$i]."</link>
<guid>".$podcast['mp3url'][$i]."</guid>
<description>".$podcast['description'][$i]."</description>
<enclosure url=\"".$podcast['mp3url'][$i]."\" length=\"".$podcasts['filesize'][$i]."\" type=\"audio/mp3\" />
<category>Podcasts</category>
<pubDate>".date("D, M d Y H:i:s O", $podcast['pubdate'][$i])."</pubDate>
<itunes:author>DVA CRJ Team</itunes:author>
<itunes:subtitle>".$podcast['Isubtitle'][$i]."</itunes:subtitle>
<itunes:summary>".$podcast['Isummary'][$i]."</itunes:summary>
<itunes:duration>".$podcast['Iduration'][$i]."</itunes:duration>
<itunes:keywords>".$podcast['Ikeywords'][$i]."</itunes:keywords>
</item>
";
}
// finish up xml file
$xml .= " </channel>
</rss>";
if (fwrite ($xmlfile, $sml)) {
print ("Podcast XML file created successfully.");
$doneBy = $_SESSION['f_name'].' '.$_SESSION['l_name'];
$date = time();
$query = "INSERT INTO adminLog VALUES ('','Podcast','Publish','$doneBy','$title','$date')";
mysql_query($query);
} else {
print ("Error creating XML file.");
}
?>
[/code]
Any ideas?
Thanks! -
Just to be sure, you turn it off in your php.ini file correct?
-
Actually, I do have a question.
When I submit the form I send it to xxx.php?ID=USER ID (taken from session).
And when I do this and run it the update works but if you just logged in and ran it for the first time during that session, you get this error:
Warning: Unknown(): Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0
However, it still updates the record, and when you run the script again, it dosen't come up. Is there any way to prevent that message? -
Thanks for your help guys, turns out it didn't know here to place the data because I used the $_POST to get the vars. So that messed up the header, thus messing up some session variables which I was using to place the table.
Thanks again! -
Hey guys,
I can't seem to get this script to update a record in my MySQL database for me. It takes input from a form (POST) and assigns them variables. It then connects to the database, assigns the query to $query, and runs the query inside of an if statement to test if it worked. But I keep getting an error and when I check the database it hasn't updated.
Here's part of the code:
$query = "UPDATE Users SET AIM = '$AIM', YIM = '$YIM', MSN = '$MSN', website = '$website', Location = '$location', RW_Expirence = '$RW_Expirence', VATSIM ID = '$VATSIM', Auto = '$auto' WHERE `First` = '$First' AND Last = '$Last'";
if (mysql_query($query)) {
print "Your profile has been updated.";
?>
<form> <input type="button" value="Run Again" onClick="window.location = 'profile.php'"></form>
<?php
}
else {
print ("Uh Oh! There was an error, please try again.");
?>
<form><input type="button" value="Run Again" onClick="window.location = 'profile.php'"></form>
<?php
}
mysql_close();
?>
Any help is appreciated, thanks!
fwrite error
in PHP Coding Help
Posted
[code]
<item>
<title>t</title>
<link>h</link>
<guid>h</guid>
<description>t</description>
<enclosure url="h" length="" type="audio/mp3" />
<category>Podcasts</category>
<pubDate>Wed, Dec 31 1969 17:00:01 -0700</pubDate>
<itunes:author>DVA CRJ Team</itunes:author>
<itunes:subtitle>t</itunes:subtitle>
<itunes:summary>t</itunes:summary>
<itunes:duration>t</itunes:duration>
<itunes:keywords>k</itunes:keywords>
</item>
[/code]
I cannot seem to find why it's only printing that. I've checked the databases and there is no problem there. Any ideas?