I noticed that PHP 5 has a lot of nice new features: SPL, SimpleXML, exceptions, PDO, etc. It does not seem to be widely deployed, however (from my limited knowledge). Does anyone have any opinions on whether it would be better to author for PHP 4 or 5?
Note: OpenSuSE comes with PHP 4.4, so I would have to compile PHP 5.1.
I have this upload script which works perfectly. However, I was wondering if there was a way to edit this script so that it can handle multiple file uploads instead of one.
For those familiar with ASP's global.asa file... does PHP have an equivalent, or am I best served by using one include file to contain common site variables?
I was just wondering if anyone had an idea on how to go about this...
I'm running an iTunes plugin that automatically puts the ID3 info from my currently playing song into an XML file on my website, which I then parse and display using PHP. That's fine.
It also uploads a thumbnail of that song to a specific directory. Now, playing iTunes for several hours on end leaves me with a folder full of thumbnails. I'd like to write a cron job that deletes all but the currently playing or x most recent thumbnails.
I can't just wipe out all but the newest x files from the directory, as the XML file is saved there as well (the plugin is non-configurable in this respect), and the plugin uploads artwork for songs that only play for a split second, even if the XML file won't list them. So I can't delete just the x most recent files with a specific naming scheme, I've got to delete all image files except the ones listed in the XML file.
The problem with that is that the XML file does not list a file extension for the album artwork, and just lists a hash as an ID (which is only a part of the filename used to save the image when uploading). As is, I use a number of if/else statements to determine if a file exists and what file type it is.
I'm *thinking* that the best way is to collect those album artwork IDs, and unlink() all images that DON'T contain those hash IDs. I'm not sure the best way to go about this though, as while I've got plenty of experience with PHP in certain respects, it's filesystem commands are something I've neglected.
So, essentially, I'm just wondering if there's an easy PHP file command for collecting files that fall under certain criteria. Any ideas?
I need help with an updating script - it first selects the table which to update and selects the data (that part works fine), then it's supposed to update the data in the table when send, but there is the problem: it doesn't do anything when I hit "Send", it just gives me a success message but nothing has been updated in the database. See the script here: http://pastebin.com/550950
I just noticed there is now an extended version of the compiled help module that can be integrated into windows based IDEs.
For example, I use Zeus and I can place the cursor on a PHP function, press ctrl-F1 and get the manual page for that function, complete with user supplied notes from the website.
Hi all, I recently landed a new job. The people that work there use Eclipse. I have been playing around with it to try and get a feel for it before I start next week and I am running into a couple of problems. I was hoping one of you would not mind giving me some pointers.
I have:
Eclipse Version: 3.1.2 XAMPP very 2.1
I installed Eclipse into the XAMPP directory as instructed.
To my understanding XAMPP will run Apache, MySql, PHP and PERL when the computer starts as I think I set them up as services.
I wrote a little test program using a set of functions that I have been using for a while now. The test program includes a config file that has the full include list in it. For some reason none of my files are being included. I do a require instead of an include, it does not fail but the functions are still not available. I can see the files are the in Eclipse's browser so I am not sure why they are not being found.
There are buttons in Eclipse for starting and stopping XAMPP. These seem to have no effect on XAMPP at all.
Any clues suggestions would be helpful. I have looked on the net all day but have not found anything I can really seem to understand. I have read the help files for Eclipse but they only pertain to Eclipse itself and not the add ons.
and converts the swirly brackets to lists, however it works perfectly on my localhost and on my test site, but on server for the production site, it refuses to work. any suggestions?
I currently have a script to upload PDF files to my server. It works fantastic, except when I get to files which are > 2ish megabytes.
My current script is as such:
Upload File:
(I figured setting the value of MAX_FILE_SIZE to 10 megs would solve this problem, but apparently not.)
Then the script on the following page is: $name=$_FILES['link']['name']; $tmp_name=$_FILES['link']['tmp_name'];
if ($name) { $uploadfile = "docs/" . $name;
if (move_uploaded_file($tmp_name, $uploadfile)) { print "The file was valid and was successfully uploaded."; $link=$name; } else { $error=$_FILES['link']['error']; echo "$error"; print "Error during upload. Your file was not uploaded. Please try again"; }
The error screen always comes up for large-ish files. However, the variable $error never prints (why?).
Also, for some files I upload, even though they are about 300kb, only the first page will upload. This has actually only happened with 2 files. Every other file uploads just fine, even for multiple pages (up to dozens of pages).
example that isn't valid html img tag: $_POST['body'] = preg_replace('/asdf/', '<1.gif>', $_POST['body']); This returns a blank result.
I have other preg_replaces working just fine, so I'm assuming I just don't know what I am doing in regards to regular expressions (and I don't). So is this just not valid, or do I need to try to figure out other causes for this not working?
I am trying to make a short script that will generate an XSPF/XML file based upon the names of mp3 files that are in a particular directory. It will be a dynamic playlist that automatically updates. I am using it with the XSPF Web Music Player, an open source flash-based mp3 player.
Anyway, I am pretty sure that I need to use the fopen() function. When I use it in my script a warning is generated:
Warning: fopen(playlist2.xspf): failed to open stream: Permission denied in /var/www/......./playlist_generator.php on line 43
now, I think I can fix this with the CHMOD command, but my question is what is the exact command ie which code should i use? I need to do this through the FTP program in the windows console.
Ok, I have the following function that until the other day worked fine. It has now stopped and i have no idea why. The only think i know of that has been done on my web server recently is MYSQL have been upgraded.
Now this code is meant to take an image (full path including filename as $path) and make it the size set when called and then save it to the name and path set as $save.
When it makes this file, it is a copy, so nothing is done to the original. Now this function is part of the admin section to my gallery which is there just to make and store the thumbnails. I have no idea why this isn’t working, but I have tried a few of the scripts in the php docs with no luck. Php is working, so it isn’t that, so does anyone know how I could do this function in the most compataible way possible? Bear in mind I’m still a bit of a n00b, well with image manipulation at least.
my old browser sniffer that's worked so well for me for years, cobbled together from various sources, doesn't work when i upload it. funny thing is, no matter what i change, it always says the error is on line 1, which is of course the sniffer.php function inAgent($agent) { if (eregi($agent,$_SERVER['HTTP_USER_AGENT'])){ $br = true; } else { $br = false; } return $br; } if (!isset($browser)) { $browser = ""; } switch (inAgent("MSIE")) { case true: if (inAgent("Mac")) {$browser = inAgent("MSIE 5") ? "ie5mac" : "ie4mac";} elseif (inAgent("Win")) {$browser = "iewin";} break;
it works perfectly locally, as it should. i'm on Apache 2.2.0 and PHP 4.4.1 (Win), whereas my host is using PHP 4.4.1 on Apache 1.3.34 (Unix).
the error i'm getting is either Parse error: parse error, unexpected T_STRING in /real/path/to/html/sniffer.php on line 1 or ...unexpected T_FUNCTION..., depending on what i've tried to do to fix it.
This might incorporate some javascript too, but I'm not really sure so I'm going to ask it here anyway as I'd rather do the whole job with php if possible.
I'm trying to make an HTML converting assistant for someone on our staff - something where she could just press one of a few buttons above a comment box on a page and insert a br tag or font tag etc into the comment box where the cursor is.
How can I do this? I have a sneaking suspicion it's more js than php... either way, I can't figure it out.
Suppose I want a way to easily backup a SQL table. (I use MySQL but that shouldn't matter.) I would like to be able to have a link on my website that, when I click on it, lets me download a TXT file with all of the data in tab separated values, so I can easily load it into excel.
FIXED. Thanks to hipmaestro -- I downloaded PHP 4.3.11 and upgraded my installation, and it's fixed. :)
I've been working at this since last night -- and I'm quite clueless about what's happening. I was thinking that it could possibly be that my system has been working too long and there are weird memory leaks (yes, I have no more good ideas) so I thought I'd just go back in the morning... but now it's morning and the error is still there. The error is-- at some point of the script, a certain variable gets overwritten with the text of the next variable.
This is how the script is set up: there is a config file that's included all over the place -- in all the visible pages and in each function (I'm toying with the idea of using constants instead, but for now this is what I'm using). The config file has the database variables, and along the top I define the connection stuff:
So I include it in almost everywhere. The script's functions is included in a mod_modulename.php file, such as get_this_stuff(); and add_something(); and so on and so forth. For the script I'm using, some user settings are stored in the database, and I have a mod_settings.php file with the following functions:
get_setting( $settingshortname );
get_setting_title( $settingshortname );
get_setting_desc( $settingshortname );
update_setting( $settingshortname, $newvalue );
...
There are a few other functions but those are the ones needed to, er, get the gist of the way they're set up.
So now I'm working pretty well, until I come to one page and at the bottom of the page, I get a MySQL error about not being able to connect to the test database. See this (before?) screenshot. I fiddle around, check config, etc etc. Nothing. I look for where the database connect is failing, and it's in get_setting( ... ); so I go there and take a look. I add a few echoes in there, to check my config values and look what happens to the page: whatthehell?
I've searched the whole script directory and the ONLY place where I assign a value to $db_user is in config.php; nowhere else. I don't have register_globals turned on, and I don't plan to ever turn it on; and I've checked the $_* arrays, and there is no index of that name. I ended up going to config.php and doing a series of echoes, and did this:
Notice: Undefined variable: db_user in D:\Site\devt\Enth3\enth3\config.php on line 11 $db_user is now:
$db_user is now: password
*tears hair out!* It's right before the line and it assigns $db_password. I have no idea what's going on. I commented out the $db_server line and the $db_user line got 'username' as its value. I repeated $db_user twice consecutively, still 'password'. I repeated $db_user twice, the next one after $db_password, and it works. Here's another: I switched the $db_password and $db_database variables, which means $db_database now goes before $db_password. The value of $db_user? It's 'database'. NOT 'databasename', but 'database'. WHAT THE HELL IS GOING ON.
I suppose I could make a fix where $db_user goes after $db_password or something, but just the fact that this is happening means that there's just plain something wrong with what's happening, either with the interpreter or my code or... whatever. I don't see what's wrong, and I've exhausted all possible ideas in my head as to what's wrong... can anyone help me?
If it might be useful -- the PHP interpreter died on me twice yesterday. I'm not sure why. It just did. Windows XP (SP2) just told me that the PHP interpreter got some errors or something (I forgot what it said) and needs to close. I let it close, I rebooted the computer, and went on. I'm working with Apache 2.0 and PHP 4.3.0 and MySQL 4.0.15 on this machine, which is on Pentium4 2.4 GHz and 480MB memory (512, but the rest is being eaten up by the video card).