1. mySQL, BLOBs and image streams

    Date: 02/09/07     Keywords: browser, html, database, java

    I was wondering if anyone had thought of a useful way to get images out of BLOB fields in a database table and send them to a rendered HTML page inline. This whole calling another script via a URI that fetches the picture as a served "page" via a second request seems very redundant.

    I've seen the client side encoded binary tricks through javascript, and they are clever but rely on the client's browser settings too much to be comfortable. The fact that IE refuses to implement the data: URI is a pain in the royal parts. An idea I had was to save the results as temp files and serve them that way, but again, terribly redundant - not to mention hard on the server.

    So have any bright sparks come up an elegant and W3C friendly way to pull an image binary from a BLOB and include it in an tag?

    (I'm aware of the database overhead with many BLOBs - this is just an exercise in extreme cleverness)

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

  2. Totally perplexed..

    Date: 02/07/07     Keywords: php

    Has anyone else ever had this happen when calling an object dynamically (meaning you get $var as a string then do new $var()

    The parent completely and totally ignores calls from the child?!?!?!

    Child snippet:

    function getProductList($attributes) {
    		//var_dump(get_parent_class($this));exit;
    		return parent::getProductList($attributes);
    	}


    Parent snippet:
    function getProductList($attributes = false) {
    		echo "break here";exit;
    		global $dbs;
    
    		//var_dump($...


    I can get anything I want from the child function, nothing from the parent. The commented line above giving me the parent class shows the correct value. I mean, if the parent wasn't loaded, I'd get an error right? It extends the parent class, etc. So why can I not get anything from the parent object????

    I've never had this happen and am totally perplexed. Or going insane. Perhaps I broke PHP's already weak OO structure??? Anyone ever had this happen before?


    I'm an ultra goober. Had an extra bracket at the end of a function (and missing one later) that basically ended the class before that method. Duh.

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

  3. Faster tableExists function

    Date: 02/07/07     Keywords: mysql, sql

    Pre-question: what's a good method for displaying a script in livejournal?

    Real question:
    Below the cut is a very quick function I wrote up to query for the existence of a table in MySQL. I want to cut it down even further and I was thinking the logic :

    start table exists
    query `SHOW TABLES LIKE 'myTable';
    if result && result num_rows > 0 then table exists?
    return true
    else
    return false
    end table exists

    would be faster because it wouldn't loop. My thought is, the only way the query could return true(1+ results) is if it matched that table exactly (lack of %'s in the query expression). Anyone disagree?


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

  4. Software licenses

    Date: 02/06/07     Keywords: no keywords

    I'm not sure if this is the place to discuss this, but I don't know where to ask. If not, please feel free to redirect me to the appropriate place.

    I'm almost ready to release my program to the public, but I'm not comfortable with the GPL license. I'll like to use some "free for non-commercial use" license that also allows people to modify the code for their own use and distribute the modified code (but only the modified part, not everything, something like "mods") as long as is non-commercial. Commercial users will be required to pay a fee.

    I searched, but the closer I found to something like this are the Creative Commons licenses.

    Do you know of any license that may cover this? Thanks!

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

  5. Parsing Includes to Single File

    Date: 02/06/07     Keywords: php

    I've been searching around trying to find a util or script that will take a php script, parse all the include, include_once, require, and require_once statements, then create a new file with all the code joined together.

    This:

    include('foo.php');
    include('bar.php');
    echo "Hello World."
    ?>


    To This:

    echo "This is foo.php";
    echo "This is bar.php";
    echo "Hello World.";
    ?>


    Any ideas?

    Thanks.

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

  6. Set status script. Help please

    Date: 02/05/07     Keywords: php, database

    I have the script which allows to register new users (field 'nick' in data base) and set their default status as "simpleuser" (field 'stat' in data base). And I want a page where all new users with status "simpleuser" will be listed one after another in table. And near each nick will be form where I could select a user's new status ('moderator' or 'administrator'). And after this table will be a button for subnision which updated database with new values.

    I've wtitten code. But it doesn't work :(

    So, it consists of two files [B]sending.php[/B] and [B]user_submit.php[/B].

    sending.php

    include('connection.php');

    $query = "SELECT id, nick, email FROM test WHERE stat = 'newuser'";
    $result = mysql_query($query) or die("ERROR: $query.".mysql_error());

    // if records are present
    if (mysql_num_rows($result) > 0) {
        $row = mysql_fetch_assoc($result);
        $id = $row->id;

        echo ""; 
            echo "";
            echo "";  
            echo "
    ".$row[nick]."".$row[email]."</a>
    ";
        echo "";
       
            echo "
        echo "";
        echo "";
        echo "";
     }

    else {
        echo 'No new users';
    }

    // close connection
    mysql_close($connection);

    ?>

    Problem here:
    There is only one user shown in the table, but in the db there're many of them. Why does it show only one?

    user_submit.php

    if (isset($_POST['submit'])) {

        include('connection.php');
       
        $result = mysql_query("UPDATE test SET stat = '{$_POST['newstat']}'  WHERE id = '{$_POST['id']}'");
        // close connection
        mysql_close($connection);


        // print success message   
        echo 'Done';
    }
    else {
        die('ERROR: Data not correctly submitted');
    }

    ?>

    The problem here is:
    It doesn't set new status to users. But I'm not sure that mistake which causes this problem in user_submit.php, it might be in sending.php

    Help me please.

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

  7. Probably off-topic but...

    Date: 02/05/07     Keywords: php, programming, css, html, xml, asp, sql, java, web, google

    As I look for alternative employment I see a lot of wanted ads asking for a web designer who are proficient in several web-programming languages (they usually specify PHP/ASP/CGI-Perl), the use of several different databasing formats (Access, SQL of some sort, Oracle) - proficient in several different forms of design (Photoshop, Flash, Illustrator, FreeHand, Quark, etc) as well as being a master of JavaScript, XHTML, XML, DHTML, CSS and any other acronym they seem to have found on google.

    To me this sounds like they are asking for a web-design team wrapped into one person. Am I crazy; or are they?

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

  8. Logging package/systems

    Date: 02/05/07     Keywords: php, tracker

    Originally I was looking to incorporate phpOpenTracker into our project( enteprise level +15k daily users) to record impressions, hits, and then modify the schema to add on system/application auditing. But before I start ripping into the code, is there any other open source packages that can handle some sort of weekly merge table schema along with doing internal logging of user actions (guest and authenticated users). I started writing my own logging engine, and that is most likely the best way to go, but I am running short on time.

    Another package I found was TraceWatch, but it's pretty useless (non-GPL, obfuscuated code, and no suggestion of being able to purchase a license == dead end). My requirements is that we can modify/edit the entire system to our needs, it needs to be as flexible as possible (lots of lookup tables to reduce information replication), and of course GPL'd/open source or available for licensing.

    Any suggestions?

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

  9. Awesome PHP Career Opporutnities @ Yahoo

    Date: 02/05/07     Keywords: php, yahoo

    We are currently seeking highly talented PHP professionals to join our team. All positions are full time, direct hire positions and relocation assistance is provided.

    If you would like to learn more about the many opportunities we have within Yahoo, please forward a copy of your resume to me at carlal@yahoo-inc.com and the best number and time to reach you. I’ll review your information upon receipt and if your experiences/goals are aligned with our current needs, I’ll contact you to gather some more information about your background and interests.
    Yahoo! Inc is an equal opportunity employer.I look forward to hearing from you soon.

    Carla

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

  10. best php practice?

    Date: 02/04/07     Keywords: php, html

     I have a question about the the 'best' (most efficient? cleanest? elegant?) way to process form data for a page. I don't know if I should process the data, update the DB, etc at the top of the page I'm displaying, or if I should handle it in a PHP file that then redirects to a page that displays HTML.

    Should I:


    index.php
    // Some code here
    include 'formProcessingStuff.php';
    // Lots of code
    include 'showBody.php';
    // Lots more code
    ?>

    or

    formsubmit.php
    //Page that processes the form

    // Tons of code that processes and validates info and updates DB

    // Now we want to give the user a page to see what he just did
    header('Location: displayContentPage.php');

    ?>


    displayContentPage.php
    // Code that shows the body of the page
    ?>


    The latter seems much cleaner and easier to see and understand and code. More encapulation to make updates easier down the line. But is this a Good Practice? Is it acceptable? What problems/drawbacks might I run into?

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

  11. write some code for meeeeee?

    Date: 02/04/07     Keywords: database

    what im looking for is a script to find out who in my database is available/online and put their ad on the main page. sort of like at the bottom of forums where its says who is active, but with a photo and link. super simple. let me know how much. edanya at edanya dotcom :o)

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

  12. phpdoc for php5

    Date: 02/01/07     Keywords: php

    I've never had the chance to use the phpdoc project for my code, so I was wondering how difficult it is to install and use with a php5 environment?

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

  13. uploading file error

    Date: 01/31/07     Keywords: php

    I'm at a loss for what is causing this error and not moving an uploaded file, if someone could take a look at the code and see what I might be missing would be appreciated,
    here is the output:
    Upload: 617.txt
    Type: text/plain
    Size: 8.900390625 Kb
    Stored in: /tmp/phpMhLXr8
    Warning: move_uploaded_file(1/617.txt): failed to open stream: No such file or directory in /mnt/w0701/d15/s12/b0287a72/www/media-n.org/playlist/upload_file2.php on line 18

    Warning: move_uploaded_file(): Unable to move '/tmp/phpMhLXr8' to '1/617.txt' in /mnt/w0701/d15/s12/b0287a72/www/media-n.org/playlist/upload_file2.php on line 18
    Stored in: 1/617.txt1

    and the code block:


    {
    if ($_FILES["file"]["error"] > 0)
    {
    echo "Error: " . $_FILES["file"]["error"] . "
    ";
    }
    else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "
    ";
    echo "Type: " . $_FILES["file"]["type"] . "
    ";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb
    ";
    echo "Stored in: " . $_FILES["file"]["tmp_name"];

    $path = mkdir ("./" . date("YMDHis"), 0777);
    move_uploaded_file($_FILES["file"]["tmp_name"], $path . "/" . $_FILES["file"]["name"]);
    echo "Stored in: " . $path . "/" . $_FILES["file"]["name"];
    echo $path;
    }
    }

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

  14. database results not posting?

    Date: 01/30/07     Keywords: no keywords

    Hi

    This post has been heavily edited because I realized my problem and now have another question so sorry for any confusion

    My original question was about the data from 3 tables not being displayed properly and I realized that my query was not actually returning results simply because the other two tables did not have data in them yet. (This is going to be added later) This brings me to my next question.

    Is there some way that I can have it check for data in the other table (I now only have two data tables instead of 3 - Company and CallDetail) and if there is data there, append the query to the regular query. I have an idea how to do this but I'm not sure if it makes logistical sense. I need to be able to check if there have been any additions to the second table (CallDetail) for each Company and include the data when the page is loaded (if there is data to be loaded). I hope this makes sense. :\ Thanks again for your help.

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

  15. thanks!

    Date: 01/30/07     Keywords: no keywords

    I just wanted to thank everyone in the community for being so helpful. I've never been let down when posting here... you all are awesome!

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

  16. A (semi-?)challenging MySQL query for y'all

    Date: 01/30/07     Keywords: php, mysql, sql


    I know this isn't a MySQL community, but I figured since PHP goes hand-in-hand with it, someone here could help me :)

    I'm creating a tracking system for our labs that's recording login and computer information every time a user logs in. The schema is:

    | tID         | int(10) unsigned
    | tUsername   | varchar(32)      
    | tHostname   | varchar(16)      
    | tAgree      | tinyint(1)       
    |tIp         | varchar(16)      
    | tLoginTime  | datetime         
    | tLogoutTime | datetime         
    


    And some example data:
    tid	tuser	thost	tagree	tip			tlogintime			tlogouttime		
    256  	user1  	host79 	1  	123.213.289.244  		2007-01-25 06:44:11  	2007-01-25 10:11:09  
    257 	user5 	host87 	1 	123.213.289.101 		2007-01-25 09:14:12 	2007-01-25 09:39:28 
    258 	user3 	host59 	1 	123.213.289.180 		2007-01-25 09:27:37 	2007-01-25 10:11:37 
    259 	user4 	host41 	1 	123.213.289.39 		2007-01-25 09:41:21 	2007-01-25 10:25:57 
    260 	user2 	host65 	1 	123.213.289.55 		2007-01-25 10:05:45 	2007-01-25 10:21:36 
    


    I want to find a list of hostnames that were logged in between a given time period (say, one hour). In this example, I want the 4 hostnames that were being used on 2007-01-25 between 09:00:00 and 09:59:59. What query would I use to pull out those four hostnames? I'm being thrown off by the hostname with tid=256, which was being used between 9 and 10 but it wasn't logged in or out during those times. Can I even capture the data I need with the current schema? If I need to change something, that's not a problem.

    If y'all could help me out I'd appreciate it. Thanks!

    Edit: A friend and I got it figured out:

    select thostname from login where time(tlogintime) < time('09:59:59') AND time(tlogouttime) > time('09:00:00') AND date(tlogintime) = date('2007-01-25');

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

  17. Roundcubemail email package

    Date: 01/30/07     Keywords: php, programming, web, hosting

    Hello everybody,

    I am still new at PHP programming and have already picked up some tips by watching this community. This is my first time posting and I hope to solve my problem this way. Thanks in advance!

    Ok, here is what I'm trying to do. I have installed the email package 'Roundcubemail' on the hosting server and website and am trying to modify the code so that I can add a fixed message to each email that will be sent out. Something like a disclaimer at the bottom of business emails.

    File 1 -------->
    In the following directory, I found this file...

    /mysite/roundcubemail/config/main.inc.php

    and this code....
    171> // path to a text file which will be added to each sent message
    172> // paths are relative to the RoundCube root folder
    173> $rcmail_config['generic_message_footer'] = '';


    File 2 ------->
    Then, I found this file in directory...
    /mysite/roundcubemail/program/steps/mail/sendmail.inc

    and this code...
    163> // append generic footer to all messages
    164> if (!empty($CONFIG['generic_message_footer']))
    165>   {
    166>   $file = realpath($CONFIG['generic_message_footer']);
    167>   if($fp = fopen($file, 'r'))
    168>     {
    169>     $content = fread($fp, filesize($file));
    170>     fclose($fp);
    171>     $message_body .= "\r\n" . rcube_charset_convert($content, 'UTF-8', $message_charset);
    172>     }
    173>   }


    File 3 ------->
    Ok, I have created a text file 'footer.txt' and added a new directory '/mysite/roundcubemail/footer/' that now contains my footer-file.

    The contents of this file is for now...
    _____________________________________
    email footer
    _____________________________________

    I have changed line 173 in file main.inc.php to this ...
    173> $rcmail_config['generic_message_footer'] = '../footer/footer.txt';

    But alas, the message in the text-file is not added to the email sent. Any advice? Thanks!

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

  18. URL, Current Page

    Date: 01/29/07     Keywords: php

    I want to write a php program that involves recognizing the URL of the page the user is currently on, but I'm not sure exactly how to do this.

    What I want from the program is basically this:
    If Current URL is ____ then on link click go to this _____ URL.
    else if current URL is _____ then on link click go to this ____ URL.
    .
    .
    .
    etc.

    Is there a way to call the current URL and do this?

    Thank in advance!

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

  19. drop down help

    Date: 01/29/07     Keywords: php, mysql, rss, sql

    It's been a while since i posted in here, but last time i got a great response and was sorted out quickly, so fingers crossed someone can spot the mischievous bit of code that is causing me problems and help me out :)


    I am populating a drop down menu from a DB. I have sub categories and articles within those Subcats. I want the drop down to list the sub categories, then if there is only ONE article attached to that Subcat then it ges to a paage to display that article. If there are more than one, then it goes to a page that lists the articles for the user to choose.

    I had the code working fine to display when just one article is assigned to each subcat. It even works when there is more than one.

    HOWEVER, the problem is that if there is more than one article per subcat, it repeats the subcat name in the drop down. So if there are two articles, it lists the subcat twice, three articles shows three subcats, etc.

    anyone able to look through the code and see where i am going wrong? :) pretty please? :)

    many thanks in advance!



    ---lots of other php stuff up here, including an if statement just before the cut off point---

    $catid = $rowCat['cat_id'];
    } // end if isset

    $subcatSQL = "SELECT DISTINCT c.cat_id, c.cat_title, c.cat_parentid, c.cat_type, c.cat_visible";
    $subcatSQL .= " FROM tbl_cats c";
    $subcatSQL .= " WHERE c.cat_visible=1 AND c.cat_parentid = '$catid'";
    $subcatSQL .= " AND c.cat_type LIKE 'articles%'";
    $subcatSQL .= " ORDER BY c.cat_id ASC";
    $rsSubCat = mysql_query($subcatSQL, $conn) or die("Query failed : " . mysql_error());
    while($rowSubCat = mysql_fetch_array($rsSubCat)){

    $subcatid = $rowSubCat['cat_id'];

    $artSQL = "SELECT a.art_id, a.art_title, a.art_visible, ac.artcat_artid, ac.artcat_catid";
    $artSQL .= " FROM tbl_articles a, tbl_art_cats ac";
    $artSQL .= " WHERE ac.artcat_catid = '$subcatid' AND ac.artcat_artid = a.art_id";
    $artSQL .= " ORDER BY a.art_id ASC";
    $rsArt = mysql_query($artSQL, $conn) or die("Query failed : " . mysql_error());
    $num_rows = mysql_num_rows($rsArt);

    while($rowArt = mysql_fetch_array($rsArt)){

    if ($num_rows > 1) {
    ?>

    } elseif ($num_rows = 1) {
    ?>

    } //end of elseif

    } // end rowart while
    } //end rowsubcat while
    } // end of rowcat while
    ?>

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

  20. Two entries in a row!

    Date: 01/28/07     Keywords: php

    Okay, well. Whatever. I'm really novice at all this and I'm not absorbing any of this information in the least. I'm using w3schools.com and it's like a maze to actually find something. Anyways, I'd like to know if I can find out what all of this means. It's just a request your password page, but I don't know how to change the body (I believe it's the "invite:password:request") How do I find what document has that? That's the first question. how to locate those.

    Second question: I keep getting " require_once(dirname(dirname(__FILE__))."/includes.php"); ". I don't understand why it keeps using that. Well, again, just ask for whatever you want to find out things that aren't clear yet. It's a pre-written script that I'm trying to take apart. One of the main things I want to do is take off this drop down menu at the top of every page that lets you select a language since I only want English.

    'contentholder',
    'title' => $title,
    'body' => $body
    )
    );

    echo templates_page_draw( array(
    $title, $body, ' '
    )
    );

    ?>

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

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