newbie web dev trying to run PHP powered site
Posted: Fri Jul 31, 2009 10:24 pm
Hey everybody,
So I've been developing a personal website that utilizes PHP and a MySQL database to generate randomized playlists for users and play the songs (located on my server) in a JW Flash Player. After doing lots of localhost debugging, I got it pretty much working. I decided to reformat an old PC and put Centos on it (even though I've have little Linux Kernel experience) and run that as my webserver. Now that I've moved everything to my server, it doesn't behave like it did when running on a WAMP setup. Essentially what's supposed to happen is the user makes a bunch of selections from a list of available checkboxes, and then when they click submit an xml playlist is supposed to be generated, and then the page with the flash player embedded looks for that playlist and begins playback. For some reason, when I access the site on my laptop @ home, everything works perfectly. When I try it on other computers (say, at a friend's house) it doesn't. After running firebug, I noticed that only when: (1) I step through the buildPlaylist() method or (2) add something like an alert() statement in that method does the playlist actually get built on these other computers. Otherwise, it just fails to build the playlist. I'm thinking that there's something wrong with my code...so that's why I came here. Here is the code of interest.
So here's the html code for the submit button:
(I know it says 'submt.php' instead of 'submit.php', that file simply points the browser to the page with the flash player embedded)
And here's the code for the buildPlaylist() method:
So, I need to call the file 'build.php' with the necessary parameters in a string (build.php uses $_GET instead of $_POST) when the user clicks submit. I wasn't exactly sure how to do this, and then I stumbled upon a post somewhere that said to just make a new Image and set its src field to the php file that you want to be executed. So I guess for starters, is this completely wrong? It worked like a charm until I started branching out to other computers, so I'm left scratching my head (I'm still trying to learn the ins and outs of php web development). Another thing, on computers other than my laptop, when I click the 'Back' button on my browser my init() method on the first page doesn't seem to get called, the checkboxes that were previously selected are still checked! So I also think there's something wrong with how I'm redirecting the browser in my code. Can anybody offer some guidance? Thanks for reading this long-ass post.
-Mark
So I've been developing a personal website that utilizes PHP and a MySQL database to generate randomized playlists for users and play the songs (located on my server) in a JW Flash Player. After doing lots of localhost debugging, I got it pretty much working. I decided to reformat an old PC and put Centos on it (even though I've have little Linux Kernel experience) and run that as my webserver. Now that I've moved everything to my server, it doesn't behave like it did when running on a WAMP setup. Essentially what's supposed to happen is the user makes a bunch of selections from a list of available checkboxes, and then when they click submit an xml playlist is supposed to be generated, and then the page with the flash player embedded looks for that playlist and begins playback. For some reason, when I access the site on my laptop @ home, everything works perfectly. When I try it on other computers (say, at a friend's house) it doesn't. After running firebug, I noticed that only when: (1) I step through the buildPlaylist() method or (2) add something like an alert() statement in that method does the playlist actually get built on these other computers. Otherwise, it just fails to build the playlist. I'm thinking that there's something wrong with my code...so that's why I came here. Here is the code of interest.
So here's the html code for the submit button:
Code: Select all
<form id='myform' action='submt.php' onsubmit='return buildPlaylist();'>
<input type="submit" name="Submit" value="Submit" >
</form>
And here's the code for the buildPlaylist() method:
Code: Select all
function buildPlaylist() {
/* This is going to build the xml file and take you to the next page */
if (songs.length == 0 && favorites.length == 0) {
alert("You haven't selected any songs!");
return false;
}
else {
var phpString = "";
for (var i = 0; i < songs.length; i++) {
phpString = phpString + "&song[]=" + songs[i];
}
for (var i = 0; i < favorites.length; i++) {
phpString = phpString + "&fav[]=" + favorites[i];
}
var dummyimage = new Image();
if (document.getElementById('random').checked == true)
dummyimage.src = "build.php?" + phpString + '&numSongs=' + document.getElementById('numSongs').value;
else
dummyimage.src = "build.php?" + phpString;
return true;
}
}
-Mark