1. resize images on the fly.

    Date: 03/24/07     Keywords: database

    I've been testing out image uploading and resizing on the fly tonight..
    While I have the page able to pull the image name from the database. It seems like the script I've found can't display the picture, as a variable, the 'imagejpeg' shows the image fine but how do I end the script so that I can have the sized image name in a variable.




            $gvsql = "SELECT * FROM image_gallery WHERE gid = \"$gid\" 
                                 ";
            $gvresult = @mysql_query($gvsql,$conn) or die("Couldn't execute query.");
     
            while ($gvrow = mysql_fetch_array($gvresult)) {
             
                             $img = $gvrow['image_name_resize'];
                                     
                                            }
                                           
            $filename = '/home/benjamin/www/dev/upload/';

            $width = 300;
            $height = 300;

            header('Content-type: image/jpeg');

              $filefile="$filename$img";
            list($width_orig, $height_orig) = getimagesize($filefile);

            $ratio_orig = $width_orig/$height_orig;

            if ($width/$height > $ratio_orig) {
               $width = $height*$ratio_orig;
            } else {
               $height = $width/$ratio_orig;
            }
            $image_p = imagecreatetruecolor($width, $height);
            $image = imagecreatefromjpeg($filefile);
            imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
            imagejpeg($image_p, null, 100);
            imagedestroy($image_p);
    ?>

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

  2. Totally unrelated; but where to turn?

    Date: 03/23/07     Keywords: php, css, html, java

    This isn't exactly PHP-related, and I aplogize but I was wondering if anyone could recommend a good community for questions related to HTML/CSS and JavaScript? I'm guessing someone here knows of one - and asking beats sifting through the 300+ results from LiveJournal's community search.

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

  3. find closest value in array

    Date: 03/23/07     Keywords: no keywords

    I have an array of sizes:
    $standardSizes = array("60x60", "90x60", "120x60", "120x90", "120x120", "150x120", "180x120", "240x120");

    User is allowed to choose the size of the board they want from these standard sizes, or pick a custom size up to 240x120. The price of a custom board is worked out at the size of the next board up - i.e. if User wants an 80x50 board, they'd be charged for a 90x60.

    So, how do I work out what is the next size up? The code I have at the moment is:

    if (!isset($_COOKIE['magi']['size'])) echo $warning; else $dims = explode("x", $_COOKIE['magi']['size']);
    
    if (!in_array($_COOKIE['magi']['size'], $standardSizes)) {
    	foreach($standardSizes as $size) {
    		$size = explode("x", $size);
    		if ($dims[0] <= $size[0]) $compWidth = $size[0];
    		if ($dims[1] <= $size[1]) $compHeight = $size[1];
    	}
    } else {
    	$compWidth = $dims[0];
    	$compHeight = $dims[1];
    }
    echo $compWidth ." x ". $compHeight;
    


    ($dims[0] = custom width, $dims[1] = custom height .. $compWidth needs to be the closest standard width, $compHeight the closest standard height)

    However, this (logically) only gives me the size of the biggest board. Any ideas how I should approach this? I'm stuck.

    Edit: Solved by '[info]'shippo, thank you :)

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

  4. Case of the dumb

    Date: 03/22/07     Keywords: php

    Hi guys!

    I've got a case of the dumb today.

    I've never actually used the http_redirect() command in anything I've written, and PHP.net's page doesn't have any user input regarding this command.

    I need to know if it's reliable, mostly, or if you have any reccomendations as to something better to use, I'm all ears.

    What I'm using it for:
    Mom wants a text field on her photography site that allows her customers to put their last name in a box, and hit submit. The submission will take them to their page, which is basically named: mylastname.php

    The form action is directed at the same page, where an if statement checks to see if the form has been submitted or not. If it has, it redirects to the new page.

    Now, yes, I know that this is highly suspect as far as there being no error checking. Right now I'm trying to get the bare essentials down in a file before I go shooting my mouth off in a snarky manner about all the different ways people could screw up typing their last name. (Fortunately, my mother is a programmer and knows how stupid people are, so it's not a matter of convincing her, just brainstorming.)

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

  5. New to PHP

    Date: 03/22/07     Keywords: php

    Im super new to PHP.
    And we have an assignment that involves using an array and function,
    to list band information.
    I put all the information in an array,
    and I have the date and name of the band being called out in a table.
    I would idealy like to make the names of the bands links,
    and they change the varibles on another table on the left.

    So the question is,
    how would i got about setting up my link,
    so that it would change the varibles?
    Is this possible?
    Am I losing my mind?

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

  6. Variables: References

    Date: 03/21/07     Keywords: no keywords

    I'm having a stupid day.

    I have a class. That class has an array variable. I want to create an instance of another class into an object, cache it in the array and return a reference to that object.

    e.g.


    class Thing1 {
    var $thing2s;

    function Thing1()
    {
    $this->thing2s = array();
    }

    function getThing2($argument)
    {
    if (!array_key_exists($argument, $this->thing2s)) {
    $this->things2[$argument] = new Thing2($argument);
    }
    return $this->things2[$argument];
    }
    }


    Now I'm reasonably sure that the above is putting a Thing2 instance into the $things2 array, and returning a COPY. I want to return a reference. Which I would do with


    return &$this->things2[$argument];


    Right?

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

  7. Listing variables used in a script

    Date: 03/20/07     Keywords: no keywords

    Is there a built-in function for listing all assigned variables used in a script? 

    For instance, if I have:

       $test = 'foo';
       $blah = 'blah';
       $bar = 'bar';
    ?>
    I'd call my mystery function:

         MagicFunctionCall();
    ?>

    Which would display:


    $test = foo
    $blah = blah
    $bar = bar


    Clear as mud?  :o)

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

  8. Cache Library

    Date: 03/20/07     Keywords: php, software

    I'm looking for a caching library for PHP Output.

    I've used Smarty in the past, and I'm looking for something with the flexibility of the Smarty caching. The particular feature is the group id's.

    With Smarty you can, for example, cache article.php for a specific article for a specific user by using a cache id like "article|$articleid|$userid". Then when the article is edited, you can clear the cache for all users by doing clear cache with a cache id of "article|$articleid", it then understands that all the many versions cached per user are the same thing and removes that cache too.

    However, the software this is for does not use, and won't be changed to use Smarty. But I need that kind of control over caching. I've not managed to find a lib that implements this kind of thing. PEAR::Cache and PEAR::Cache_Lite don't for a start.

    Can anyone suggest anything?

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

  9. Parse Error Troubles

    Date: 03/20/07     Keywords: php

    I'm working on transferring my game over to Smarty and have been coming across a multitude of problems (mostly old/deprecated code). This is the latest parse error that I can't figure out.

    Parse error
    : syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /opt/lampp/htdocs/account_options.php on line 68

    Line 68 is the line break after:


        $multipleinstance = "password";
    ?>


    Any help is always appreciated

    $verifylogin = "yes";
    include("header.php");
    include("include/list_arrays.php");

    // Get some information on their account.
    $sql = "SELECT * FROM ".$_MB->db_name.".accounts WHERE id = '".$_SESSION["account_id"]."'";
    $res = mysql_query($sql, $_MB->connection) or die(mysql_error());
    $row = mysql_fetch_assoc($res);
        $account_name = $row["name"];
        $account_email = $row["email"];
        $account_password = $row["password"];
        $account_bday = $row["birth_day"];
        $account_bmonth = $list["month"][$row["birth_month"]];
        $account_byear = $row["birth_year"];
        $user_aim = $row["aim"];
        $user_icq = $row["icq"];
        $user_msn = $row["msn"];
        $user_yahoo = $row["yahoo"];

    if ($_POST["chgpassword"])
    {
        $currentpassword = $_MB->removeoddchars($_POST["currentpassword"]);
        $newpassword = $_MB->removeoddchars($_POST["newpassword"]);
        $retypepassword = $_MB->removeoddchars($_POST["retypepassword"]);
        $newpasslength = strlen($newpassword);
        $md5currentpassword = md5($currentpassword);
        $md5newpassword = md5($newpassword);

        if (!$currentpassword || $currentpassword == '')
            $_MB->redirectuser("account_options.php", "You must enter in a password.");
        if (!$newpassword || $newpassword == '')
            $_MB->redirectuser("account_options.php", "You must enter in a password.");
        if (!$retypepassword || $retypepassword == '')
            $_MB->redirectuser("account_options.php", "You must enter in a password.");
        if ($newpasslength < 5)
            $_MB->redirectuser("account_options.php", "Your new password must be more than five (5) characters.");
        if ($newpassword != $retypepassword)
            $_MB->redirectuser("account_options.php", "Your passwords must match.");
        if ($md5currentpassword != $account_password)
            $_MB->redirectuser("account_options.php", "You did not type in your current password.");

        $sql = "UPDATE ".$_MB->db_name.".accounts SET password = '".$md5newpassword."' WHERE id = '".$_SESSION["account_id"]."'";
        mysql_query($sql, $_MB->connection) or die(mysql_error());

        $_MB->redirectuser("account_options.php", "You have successful changed your password.");
    }

    if ($_POST["chgprotocols"])
    {
        $user_aim = $_MB->removeoddchars($_POST["useraim"]);
        $user_icq = $_MB->removeoddchars($_POST["usericq"]);
        $user_msn = $_MB->removeoddchars($_POST["usermsn"]);
        $user_yahoo = $_MB->removeoddchars($_POST["useryahoo"]);

        $sql = "UPDATE $dbname.accounts SET aim = '".$useraim."', icq = '".$usericq."', msn = '".$userms."', yahoo = '".$useryahoo."' WHERE id = '".$_SESSION["account_id"]."'";
        mysql_query($sql, $_MB->connection) or die(mysql_error());

        $_MB->redirectuser("account_options.php", "You have successful changed your messaging protocols.");
    }

    // Allow for multiple instances of resultmessage().
    if ($_SESSION["msg"] == "You have successful changed your messaging protocols.")
        $multipleinstance = "messaging";
    else
        $multipleinstance = "password";
    ?>



        
            
                
                
                
            
            
                
            
        

                    
                        
                            
                        
                    

                                Change My Password


    // Display result message and kill the msg cookie.
    if ($multipleinstance == "password") echo $_MB->resultmessage();
    ?>
                                
                                    
                                        
                                        
                                        
                                    
                                

                                            
                                                
                                                    
                                                    
                                                
                                                
                                                    
                                                    
                                                
                                                
                                                    
                                                    
                                                
                                                
                                                    
                                                
                                            
    Current Password:
    New Password:
    Retype:

                                        

                            

                

                    
                        
                            
                        
                    

                                Account Details


                                
                                    
                                        
                                    
                                

                                            
                                                
                                                    
                                                    
                                                
                                                
                                                    
                                                    
                                                
                                                
                                                    
                                                    
                                                
                                            
    Account Name:
    E-Mail:
    Birth Date:

                                        

                            

                

                    
                        
                            
                        
                    

                                Messaging Protocols


    // Display result message and kill the msg cookie.
    if ($multipleinstance == "messaging") echo $_MB->resultmessage();
    ?>
                                
                                    
                                        
                                        
                                        
                                    
                                

                                            
                                                
                                                    
                                                    
                                                
                                                
                                                    
                                                    
                                                
                                                
                                                    
                                                    
                                                
                                                
                                                    
                                                    
                                                
                                                
                                                    
                                                
                                            
    AIM:
    ICQ:
    MSN:
    Yahoo:

                                        

                            

                

        
            
                
            
        



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

  10. another host post!

    Date: 03/19/07     Keywords: php, mysql, database, sql, hosting

    regarding my previous problem, i called 1and1 and they said there's no way to get my databases on the same server. whatever process creates your databases through their control panel actually goes out of its way to distribute them on different servers. the only way around this - to exceed the 100mb limit or have multiple db's on the same server - is to rent your own server on a dedicated hosting plan for a minimum of $99/month. no thanks!

    so i'm going to switch hosts. i need a host that doesn't limit database sizes beyond overall storage limits, and allows ssh access even with their cheap accounts. cron jobs would be nice but aren't necessary. php5 and mysql and a few gb's of storage.

    i don't want to use dreamhost because i've heard too many bad things.

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

  11. join between two databases

    Date: 03/18/07     Keywords: mysql, browser, database, sql

    this might be way too much info, but please bear with me! the end result is, i need to do a query that joins tables that exist in different databases on different servers. how do i do that?

    anyway, i'm building a site for a real estate guy who's hosted through 1and1. they only allow you to have 100mb of data per database. he's given me ~500mb of property data and ~100mb of property tax data. i split up the property data and kind of spanned it across five db's, then put the tax data in a sixth. each database you create with 1and1 gets dropped on a random server. i'm able to search property data by checking db1, then db2, and so on... and appending the results. i connect to them all like so

    //connect to property records 1 db
    $props1_link = mysql_connect('some_server1','name','pwd') or die ("failed to connect to server 1.");
    $props1_db   = mysql_select_db('db_name1',$props1_link) or die("unable to select property records 1 database: ".mysql_error());

    //connect to property records 2 db
    $props2_link = mysql_connect('some_server2','name','pwd') or die ("failed to connect to server 2.");
    $props2_db   = mysql_select_db('db_name2',$props2_link) or die("unable to select property records 2 database: ".mysql_error());

    //connect to taxes db
    $tax_link = mysql_connect('some_server','name','pwd') or die ("failed to connect to taxes server.");
    $tax_db   = mysql_select_db('tax_db',$tax_link) or die("unable to select tax database: ".mysql_error());


    i have one database containing one table on each of the six servers.

    i perform a search by constructing the query and looping through the $props... connections, doing this for each

    $res  = mysql_query($sql,$props1_link) or die($sql.": ".mysql_error());


    i dump the results to a csv file, then move on to the next db, append those results, move on, etc., until we have one big csv which i pass to the browser. that all works fine if i only need to query properties.

    my problem is that some of his queries need to join the properties table/s with the tax records table. simplified, something like

    SELECT p.`name` FROM `properties` AS `p`, `taxes` AS `t` WHERE p.`tax_id` = t.`id`


    i've done things like this before with multiple db's on the same server; but here i need to use multiple $links to multiple servers in order perform the query. is that possible? (beyond doing multiple queries to the different db's than comparing results manually.)

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

  12. MySQL Problems

    Date: 03/18/07     Keywords: mysql, database, sql

    I have the following piece of code:

    $sql = "SELECT id, alt_name, databasename, gametype FROM ".$_MB->db_name.".servers";
    $res = mysql_query($sql, $_MB->connection) or die(mysql_error());
    $row = mysql_fetch_assoc($res);
    $_SMARTY->assign("server_list", $row);

    It is supposed to return whatever rows are in the servers table, but for some reason it only returns the first. I've executed the SQL statement via MySQL directly and it acts as it should. Any ideas why it's acting wonky?

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

  13. pop to mysql

    Date: 03/18/07     Keywords: mysql, sql, google

    I've wanted to do this for awhile but I'm not sure where to start.
    I want to write a script that takes emails from my pop account and inserts them in to a mysql table.
    I found xeoport doing some Google searches but it seems the site is down.

    Have suggestions?

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

  14. Anomaly.

    Date: 03/17/07     Keywords: php, mysql, browser, database, sql

    I can't seem to figure out this problem for the life of me.

    The error is this: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /opt/lampp/htdocs/_projects/medievalbattles/current/v8_r3/httpdocs/access.php on line 139

    LIne 139 is: $servername = $row["alt_name"];

    Even if I comment out this entire portion of code, the error still exits (even after cleaning my entire browser cache and restarting my computer five times). I've tried cleaning my Smarty template cache, but that didn't help.

    	// was inevitable to requery this. maybe use memcached?
    $count = 1;
    $sql = "SELECT alt_name, databasename FROM ".$_MB->db_name.".servers";
    $res = mysql_query($sql, $_MB->connection) or die(mysql_error());
    while ($row = mysql_fetch_assoc($res))
    {
    $server_name = $row["alt_name"];
    $server_database = $row["databasename"];

    $sql2 = "SELECT serverstart, tickstart, serverend, round FROM ".$server_database.".game_info";
    $res2 = mysql_query($sql2, $_MB->connection) or die(mysql_error());
    $row2 = mysql_fetch_assoc($res2);
    $time_data[$server_name]["serverstart"] = $row2["serverstart"];
    $time_data[$server_name]["tickstart"] = $row2["tickstart"];
    $time_data[$server_name]["serverend"] = $row2["serverend"];
    $time_data[$server_name]["round"] = $row2["round"];

    $count++;
    }


    Please help.

    $verifylogin = "yes";
    include("header.php");

    $sql = "SELECT name, prestige, rank, kills, verified FROM ".$_MB->db_name.".accounts WHERE id = '".$_SESSION["account_id"]."'";
    $res = mysql_query($sql, $_MB->connection) or die(mysql_error());
    $row = mysql_fetch_assoc($res);
    $_SMARTY->assign("account_data", $row);

    //if ($user_verified != "y")
    //    $_MB->redirectuser("user_validate.php", "");

    if ($_SESSION["successful_reg"] == "1")
    {
        unset($_SESSION["successful_reg"]);
        unset($_SESSION["msg"]);
        $_SESSION["cdbname"] = $cdbname;
        $_SESSION["cloggedin"] = "yes";
        $_SESSION["loggedin"] = 1;

        header("Refresh: 5; game/overview.php");
        exit();    
    }
    else
    {
        $_SMARTY->assign("msg", $_MB->resultmessage());
        unset($_SESSION["msg"]);

        if ($_POST["login"])
        {
            $game = $_POST["game"];
            $_MB->use_db = $_POST["db"];
            $non_bar_clock = date("M d, y - h:ia");
            $clock = $_MB->month." ".$_MB->time;

            $sql = "SELECT id FROM ".$_MB->use_db.".users WHERE accountid = '".$_SESSION["account_id"]."'";
            $res = mysql_query($sql, $_MB->connection) or die(mysql_error());
            if (mysql_num_rows($res))
            {
                $row = mysql_fetch_assoc($res);
                $userid = $row["id"];
           
                $sql = "SELECT tpw FROM ".$_MB->db_name.".servers WHERE id = '".$game."'";
                $res = mysql_query($sql, $_MB->connection) or die(mysql_error());
                $row = mysql_fetch_assoc($res);
                    $ticks_per_week = $row["tpw"];
       
                $sql = "UPDATE ".$_MB->use_db.".user_aids SET timer = '".$ticks_per_week."' WHERE user_id = '".$userid."'";
                mysql_query($sql, $_MB->connection) or die(mysql_error());

                $sql = "UPDATE ".$_MB->use_db.".users SET online = 'y', lastlogin = '".$clock."'  WHERE id = '".$userid."'";
                mysql_query($sql, $_MB->connection) or die(mysql_error());

                $sql = "INSERT INTO ".$_MB->use_db.".user_online (id, userid, time, ip) VALUES ('', '".$userid."', '".$clock."', '".$_SERVER["REMOTE_ADDR"]."')";
                mysql_query($sql, $_MB->connection) or die(mysql_error());

                $_SESSION["cdbname"] = $_MB->use_db;
                $_SESSION["cloggedin"] = "yes";
                redirectuser("game/overview.php", "");
            }
            else
                redirectuser("access.php", "You do not have an empire on that server.");
        }

        if ($_POST["gameregistration"])
        {
            // Empire creation
            $game = $_POST["game"];
            $_MB->use_db = $_POST["db"];
            $sql = "SELECT * FROM ".$_MB->db_name.".servers WHERE id = '".$game."'";
            $res = mysql_query($sql, $_MB->connection) or die(mysql_error());
            if (mysql_num_rows($res))
            {
                $sql = "SELECT * FROM ".$_MB->use_db.".users WHERE accountid = '".$_SESSION["account_id"]."'";
                $res = mysql_query($sql, $_MB->connection) or die(mysql_error());
                if (!mysql_num_rows($res))
                {
                    $_SMARTY->assign("create_empire", TRUE);
                    $_SMARTY->assign("db", $_MB->use_db);
                    $_SMARTY->assign("game", $game);

                    $sql = "SELECT id, name FROM ".$_MB->db_name.".races ORDER BY name ASC";
                    $res =mysql_query($sql, $_MB->connection) or die(mysql_error());
                    $row = mysql_fetch_assoc($res);
                    $_SMARTY->assign("races", $row);

                    $sql = "SELECT id, name FROM ".$_MB->db_name.".classes ORDER BY name ASC";
                    $res =mysql_query($sql, $_MB->connection) or die(mysql_error());
                    $row = mysql_fetch_assoc($res);
                    $_SMARTY->assign("classes", $row);
                }
                else
                    redirectuser("access.php", "You already have an empire on that server.");
            }
        }
        else
        {
            $sql = "SELECT id, alt_name, databasename, gametype FROM ".$_MB->db_name.".servers";
            $res = mysql_query($sql, $_MB->connection) or die(mysql_error());
            $row = mysql_fetch_assoc($res);
            $_SMARTY->assign("server_list", $row);

            // was inevitable to requery this. maybe use memcached?
            $count = 1;
            $sql = "SELECT id, alt_name, databasename, gametype FROM ".$_MB->db_name.".servers";
            $res = mysql_query($sql, $_MB->connection) or die(mysql_error());
            while ($row = mysql_fetch_assoc($res))
            {
                $server_alt_name = $row["alt_name"];
                $_MB->use_db = $row["databasename"];

                $sql2  = "SELECT serveractive FROM ".$_MB->use_db.".game_info";
                $res2 =mysql_query($sql2, $_MB->connection) or die(mysql_error());
                $row2 = mysql_fetch_assoc($res2);
                    $server_data[$server_alt_name]["active"] = $row2["serveractive"];

                $sql2 = "SELECT empirename FROM ".$_MB->use_db.".users WHERE accountid = '".$_SESSION["account_id"]."'";
                $res2 =mysql_query($sql2, $_MB->connection) or die(mysql_error());
                $row2 = mysql_fetch_assoc($res2);
                    $server_data[$server_alt_name]["empire"] = $row2["empirename"];

    `            $count++;
            }

            $_SMARTY->assign("server_loop_max", $count);
            $_SMARTY->assign("server_data", $server_data);
        }

        $sql = "SELECT alt_name, databasename FROM ".$_MB->db_name.".servers";
        $res = mysql_query($sql, $_MB->connection) or die(mysql_error());
        $_SMARTY->assign("server_time", mysql_fetch_assoc($res));   

        // was inevitable to requery this. maybe use memcached?
        $count = 1;
        $sql = "SELECT alt_name, databasename FROM ".$_MB->db_name.".servers";
        $res = mysql_query($sql, $_MB->connection) or die(mysql_error());
        while ($row = mysql_fetch_assoc($res))
        {
            $server_name = $row["alt_name"];
            $server_database = $row["databasename"];

            $sql2 = "SELECT serverstart, tickstart, serverend, round FROM ".$server_database.".game_info";
            $res2 = mysql_query($sql2, $_MB->connection) or die(mysql_error());
            $row2 = mysql_fetch_assoc($res2);
                $time_data[$server_name]["serverstart"] = $row2["serverstart"];
                $time_data[$server_name]["tickstart"] = $row2["tickstart"];
                $time_data[$server_name]["serverend"] = $row2["serverend"];
                $time_data[$server_name]["round"] = $row2["round"];

            $count++;
        }
           
        $_SMARTY->assign("time_loop_max", $count);
        $_SMARTY->assign("time_data", $time_data);
    }

    $_SMARTY->display("pages/access.tpl");

    include("footer.php");
    ?>

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

  15. Stupid Error

    Date: 03/15/07     Keywords: php, mysql, sql, apache

    Can someone point out what I am not seeing here?

    I am using WAMP (Winblows-Apache-MySQL-PHP) on a server that I am forced to work on. I uncommented the mod_rewrite line in httpd.conf.

    From php_info():

    Loaded Modules  
    
    core mod_win32 mpm_winnt http_core mod_so mod_php5 mod_actions mod_alias mod_asis 
    mod_auth_basic mod_authn_default mod_authn_file mod_authz_default mod_authz_groupfile
    mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_dir mod_env mod_imagemap
    mod_include mod_isapi mod_log_config mod_mime mod_negotiation mod_rewrite mod_setenvif mod_userdir


    AllowOverride is set to All by default, which means that the server will indeed look for .htaccess files.

    To test, I set up a dummy .htaccess file, which is in the root dir:

    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^page/([A-Za-z-]+)$ /index.php?test=$1 [QSA,L]
    


    And the end result is a 404 error. I've tried every possible combo of rewrite syntax, rules, conditions, etc.

    Does anyone have any ideas here?? I've never tried mod_rewrite on winblows, but the OS shouldn't matter as long as I'm running Apache and not IIS.

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

  16. Unexpected EXPLAIN's with php & mysql

    Date: 03/14/07     Keywords: php, mysql, sql

    solved: Turns out there was a ini_set, mysql.trace buried in the job configuration file so that kicked off the pre-emptive explains on everything.

      While debugging another issue, I had the general/slow query logs enabled and tailed.  What caught me off guard and I assume this is part of the php mysql library, is that every single select query was being preceeded with EXPLAIN SELECT .  I've looked through the mysql_ library docs and there is no mention of this.  Direct mysql queries from the console don't have these preceeding EXPLAINS so it's got to be something unexpected inside the php code library.

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

  17. LTE script?

    Date: 03/12/07     Keywords: php, database

    does anybody know of a good 'letter to the editor' script or have any ideas?

    i'm helping a political advocacy group who'd like to help people email local newspapers and/or congress people with letters, etc

    i found local ink:
    https://sourceforge.net/projects/localink/

    and i have everything set up but i have no idea how to add newspaper/zip code information into the database correctly. i tried with phpMyAdmin adding it in manually and that didn't work either.

    any ideas? would appreciate any help in the right direction with somebody who's done something like this before, either with local ink or something else.

    thanks so much!

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

  18. Sorry to be a nuisance.

    Date: 03/12/07     Keywords: no keywords

    But I could really use any input regarding my previous post on a PECL / imagick wrapper error. Thanks in advance.

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

  19. How I earn up to $4500, being able to program and desing a little, working from home

    Date: 03/11/07     Keywords: no keywords




    How I earn up to $4500, being able to program and desing a little, working from home








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

  20. MySQL Functions Flat-Out Lying to Me

    Date: 03/11/07     Keywords: php, mysql, database, sql

    Hi, folks. I've been pulling my hair out over this one. I have a class that's supposed to serve as a base class for a variety of others; it's a sort of PHP version of Rails' ActiveRecord. Object properties map to columns in an associated database table. One of the columns is hide, a column that holds either 0 or 1. If a given row has a 1 in its hide column, the framework I'm building should omit the item from display.

    So, I have an is_hidden() function that returns the object's status (as a Boolean), and the method that's giving me fits is toggle_hidden(), which takes an optional argument: basically, you can "toggle the hidden-state on", toggle it off, or "just toggle it", meaning flip it from whichever state it's in to the other one.

    So that method looks like this:

    function toggle_hidden($state = 'toggle') {
         global $DBH;
         if (is_string($state)) {
              $state = strtolower($state);
         }
         # Add some syntactic sugar to make life sweet...
         if ($state == 'off' || $state == 'false' || $state == 'no' || $state == false) {
              $state = 0;
         } elseif ($state != 'toggle') {
              $state = 1;
         } else {
                   $state = (int) $this->is_hidden();
                   $state = 1 - $state;
         }
         $sql = "UPDATE $this->_db_table SET hide = '$state' WHERE id = '$this->id'";
         $dbq = mysql_query($sql);
         if (! $dbq) {
              $this->_errormsg = "Unable to set 'hide' state of $this->_objname #this->id to $state; SQL error: " . mysql_error();
              return false;
         }
         return true;
    }


    ($DBH is a global database handle that's already been set up; the object properties $id, $_db_table, $_objname and $_errormsg all do exactly what it seems like they should. They're not the problem.)

    If I call toggle_hidden(1) or toggle_hidden(0), I can force an object's state to hidden or visible, no problem. But if I call the method with no argument, it claims it's doing the right thing... but nothing changes.

    Even worse, I wrote up this version with loads of print statements for debugging:

    function toggle_hidden($state = 'toggle') {
         global $DBH;
         print "INITIAL CALL: toggle_hidden($state)
    \n";
         if (is_string($state)) {
              $state = strtolower($state);
         }
         if ($state == 'off' || $state == 'false' || $state == 'no' || $state == false) {
              $state = 0;
              print "I'm forcing \$hide to $state
    \n";
         } elseif ($state != 'toggle') {
              $state = 1;
              print "forcing \$hide to $state
    \n";
         } else {
                   $state = (int) $this->is_hidden();
                   print "state was originally $state; ";
                   $state = 1 - $state;
                   print "converting to $state
    \n";
         }
         $sql = "UPDATE $this->_db_table SET hide = '$state' WHERE id = '$this->id'";
         print "SQL Query: $sql
    \n";
         $dbq = mysql_query($sql);
         if (! $dbq) {
              $this->_errormsg = "Unable to set 'hide' state of $this->_objname #this->id to $state; SQL error: " . mysql_error();
              return false;
         }
         print "affected " . mysql_affected_rows() . " rows
    \n";
         $sql = "SELECT id, hide FROM $this->_db_table";
         # Tell me what *really* happened...
         print "
    \n$sql:
    \n";
         $dbq = mysql_query($sql);
         while (list($id, $hide) = mysql_fetch_row($dbq)) {
              print "     $id [hide] = $hide
    \n";
         }
         print "
    \nreturning true
    \n";
         return true;
    }


    When I run it, it not only claims it's doing what it should; it then runs the "tell me what *really* happened" section and claims that the database now has the new values.

    Except that it doesn't. So that final "SELECT id, hide FROM $this->_db_table" call is effectively returning invalid data?

    Here's sample output from a run of this method.

    Loaded object Practitioner id #2; hide is '1'
    INITIAL CALL: toggle_hidden(toggle)
    state was originally 1; converting to 0
    SQL Query: UPDATE practitioners SET hide = '0' WHERE id = '2'
    affected 1 rows

    SELECT id, hide FROM practitioners:
         1 [hide] = 1
         2 [hide] = 0

    returning true


    Despite what the last few lines of output claim, the database has not changed; I can query the database with any other tool (including other pages from this very same framework!) and see that both rows still have 1 in their hide column.

    Does anyone here have any clue what's going on, and how I can get my database queries to stop lying to me? (It seems almost like I need to commit the change, but I'm not using transactions...)

    Source: http://community.livejournal.com/php/551083.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