1. PHP 5

    Date: 02/15/06     Keywords: php, xml

    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.

    Source: http://community.livejournal.com/php/414585.html

  2. Image Upload Script - Convert to Multiple File Upload

    Date: 02/15/06     Keywords: no keywords

    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.

    You can view the script here:
    http://pastebin.com/556334

    Thank you,
    X.

    Source: http://community.livejournal.com/php/414389.html

  3. Send data size

    Date: 02/15/06     Keywords: no keywords

    Hi!

    My scripts uses

    ob_start ("ob_gzhandler", 9); at begin of the script.

    How can I know compressed page size in my script?

    $length = ob_get_length (); show uncompressed size of page (of course).

    Thanks you!

    Source: http://community.livejournal.com/php/413229.html

  4. Quick Question...

    Date: 02/15/06     Keywords: php, asp

    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?

    Source: http://community.livejournal.com/php/413090.html

  5. Flock and fopen () with mode 'a'

    Date: 02/14/06     Keywords: no keywords

    Hello!

    How do you think, need I use flock () for files which opens with mode 'a'.

    For example:

    $fp = fopen ($filename, 'a');
    fwrite ($fp, $string);
    close ($fp);
    


    Need I use flock () there?

    Source: http://community.livejournal.com/php/412735.html

  6. Any suggestions?

    Date: 02/13/06     Keywords: php, xml, web

    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?

    Source: http://community.livejournal.com/php/412289.html

  7. Need help with updating script

    Date: 02/12/06     Keywords: database

    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

    Thnx in advance :)

    Source: http://community.livejournal.com/php/412028.html

  8. Extended PHP help file

    Date: 02/11/06     Keywords: php, web

    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.

    The download is only available in English.

    Source: http://community.livejournal.com/php/411727.html

  9. Eclipse

    Date: 02/09/06     Keywords: php, mysql, browser, sql, apache

    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.

    cross posted*

    Thanks

    Source: http://community.livejournal.com/php/411528.html

  10. Environment Variables for PHP Path

    Date: 02/09/06     Keywords: php, web, apache

    Hi,

    I've got Apache 2, with PHP 5 running on Windows 2003 Server. I've installed websvn to browse our source code repository.

    However, when it attempts to run svn look, it fails as svn is not on the path for the user apache is running as.

    Is there a way I can configure this path into PHP? Or do I have to mess around with the environment variables for the user apache runs as?

    Source: http://community.livejournal.com/php/411325.html

  11. function only working on some servers

    Date: 02/09/06     Keywords: php, mysql, sql

    i've written this function (below), it takes


    {TEXT1}
    dfhdfkldfds;hdsfjsdfsdkfsdjkfhdsfsdjkfhdfjkdsfdsjkhd

    {TEXT2}
    fdkfdhfsldkfhdsfjlkhfdkjlfhdjkfldslkjfhsdhfldsfjhdsf


    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?



    x-posted between '[info]'php and '[info]'php_mysql

    Source: http://community.livejournal.com/php/411031.html

  12. File Upload Woes

    Date: 02/09/06     Keywords: no keywords

    Hello,

    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).

    Thanks for the help.
    -AJP

    Source: http://community.livejournal.com/php/410541.html

  13. ./configure --disable-static

    Date: 02/08/06     Keywords: php

    What does this option do, and where (if anywhere) is it documented? There seems to be nothing searchable on php.net on it.

    Source: http://community.livejournal.com/php/410195.html

  14. Is this not valid?

    Date: 02/08/06     Keywords: html

    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?

    Source: http://community.livejournal.com/php/409921.html

  15. fopen() problems: permission denied

    Date: 02/08/06     Keywords: php, xml, web

    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.

    Any tips would be much appreciated!

    Source: http://community.livejournal.com/php/409678.html

  16. Dead function

    Date: 02/06/06     Keywords: php, mysql, sql, web

    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.

    function img_resize($path,$w,$h,$quality,$save){

    $image_data=@getimagesize($path);

    $image_type=$image_data[2];
    $gd_ext=array('','jpg','gif');
    if($image_type!=1&&$image_type!=2) return false;
    if($save=='') header('Content-type: '.$image_data['mime']); else $save=eregi_replace('%ext',$gd_ext[$image_type],$save);

    if($w!=0){
    $rapporto=$image_data[0]/$w;
    if($h!=0){
    if($image_data[1]/$rapporto>$h) $rapporto=$image_data[1]/$h;
    }
    }elseif($h!=0){
    $tmp_h=$image_data[1]/$h;
    }else{
    return false;
    }

    $thumb_w=$image_data[0]/$rapporto;
    $thumb_h=$image_data[1]/$rapporto;

    if($image_type==1) $img_src=@imagecreatefromgif($path);
    elseif($image_type==2) $img_src=@imagecreatefromjpeg($path);

    $img_thumb=@imagecreatetruecolor($thumb_w,$thumb_h);
    $result=@imagecopyresampled($img_thumb,$img_src,
    0,0,0,0,$thumb_w,$thumb_h,$image_data[0],$image_data[1]);
    if(!$img_src||!$img_thumb||!$result) return false;

    if($image_type==1) $result=@imagegif($img_thumb,$save);
    elseif($image_type==2) $result=@imagejpeg($img_thumb,$save,$quality);

    return $result;
    }

    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.

    Thanks for any help.

    Source: http://community.livejournal.com/php/408971.html

  17. why does my browser sniffer script break all of a sudden?

    Date: 02/06/06     Keywords: browser

    UPDATE: fixed, thanks to '[info]'onah.

    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;

    case false:
    if (inAgent("Firefox")) {$browser = "firefox";}
    elseif (inAgent("iCab")) {$browser = "icab";}
    elseif (inAgent("Mozilla/5")) {$browser = "mozilla";}
    elseif (inAgent("Mozilla/4"))
    {
    if ( inAgent('Mac')) {$browser = "nsmac";}
    else {$browser = (inAgent("Win")) ? "nswin" : "nsunix";}
    }
    elseif (inAgent("Opera")) {$browser = "opera";}
    elseif (inAgent("Safari")) {$browser = "safari";}
    else {$browser = "unknown";}
    break;
    }

    switch ($browser) {
    case "iewin":
    $sniffedcss1 = "absolute";
    $sniffedcss2 = "top:";
    $GLOBALS['brwsrmssg'] = "Safer, faster, better. http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!";
    break;

    case "iemac":
    $sniffedcss1 = "absolute";
    $sniffedcss2 = "top";
    $GLOBALS['brwsrmssg'] = "Safer, faster, better. http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!";
    break;

    case "ie5mac":
    $sniffedcss1 = "absolute";
    $sniffedcss2 = "top";
    $GLOBALS['brwsrmssg'] = "Safer, faster, better. http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!";
    break;

    case "firefox":
    $sniffedcss1 = "fixed";
    $sniffedcss2 = "bottom";
    $GLOBALS['brwsrmssg'] = "thank you for using Firefox!";
    break;

    case "icab":
    $sniffedcss1 = "fixed";
    $sniffedcss2 = "bottom";
    $GLOBALS['brwsrmssg'] = "Safer, faster, better. http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!";
    break;

    case "nswin":
    $sniffedcss1 = "fixed";
    $sniffedcss2 = "bottom";
    $GLOBALS['brwsrmssg'] = "Safer, faster, better. http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!";
    break;

    case "nsunix":
    $sniffedcss1 = "absolute";
    $sniffedcss2 = "top";
    $GLOBALS['brwsrmssg'] = "Safer, faster, better. http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!";
    break;

    case "nsmac":
    $sniffedcss1 = "absolute";
    $sniffedcss2 = "top";
    $GLOBALS['brwsrmssg'] = "Safer, faster, better. http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!";
    break;

    case "mozilla":
    $sniffedcss1 = "fixed";
    $sniffedcss2 = "bottom";
    $GLOBALS['brwsrmssg'] = "Safer, faster, better. http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!";
    break;

    case "opera":
    $sniffedcss1 = "fixed";
    $sniffedcss2 = "bottom";
    $GLOBALS['brwsrmssg'] = "thank you for using Opera!";
    break;

    case "safari":
    $sniffedcss1 = "fixed";
    $sniffedcss2 = "bottom";
    $GLOBALS['brwsrmssg'] = "thank you for using Safari!";
    break;

    default:
    $sniffedcss1 = "fixed";
    $sniffedcss2 = "bottom";
    $GLOBALS['brwsrmssg'] = "Safer, faster, better. http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!!";
    break;
    }

    and i'm calling it like this:
    header.php

    require_once ("sniffer.php");
    ?>

    /* snip */

    wp-content/themes/Ice/images/image.gif" style="position: ; : 0px; right: 0px;" alt="description" />



    footer.php


    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.

    i just don't get it. any ideas? TIA...

    Source: http://community.livejournal.com/php/408599.html

  18. Help with buttons?

    Date: 02/06/06     Keywords: php, html, java

    Hi all,

    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.

    Thanks in advance!

    Source: http://community.livejournal.com/php/408360.html

  19. SQL/PHP question

    Date: 02/06/06     Keywords: mysql, sql, web

    Howdy,

    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.

    Is this possible, and, if so, how do can I do it?

    Thanks much!

    Source: http://community.livejournal.com/php/408180.html

  20. Variable gets overwritten somewhere?

    Date: 02/05/06     Keywords: php, mysql, database, sql, apache

    FIXED. Thanks to '[info]'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:

    $db_server = 'localhost';
    $db_user = 'username';
    $db_password = 'password';
    $db_database = 'databasename';

    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:

    echo '$db_user is now: ' . $db_user . '

    ';
    $db_server = 'localhost';
    $db_user = 'username';
    $db_password = 'password';
    $db_database = 'databasename';
    echo '$db_user is now: ' . $db_user . '

    ';


    And that results to 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).

    Any ideas? Help? Suggestions?

    Source: http://community.livejournal.com/php/407728.html

Previous page  ||  Next page


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home