1. Potentially a dumb question...

    Date: 12/03/06     Keywords: database, sql

    I feel like I should know how to do this but I am stumped and perhaps it's because I'm sick but anyway...

    I have a form that will be used to search a database. The form has a total of 12 fields which can be filled out to perform the search.

    My question is: Is there an easy way to include or exclude the fields in SQL query when accessing the database? That is, I only want to include the fields where something has been entered in the query string and am not sure how I would go about doing that.

    Any help is greatly appreciated. Thank you in advance!

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

  2. ADOdb Issue

    Date: 12/01/06     Keywords: php, sql

    Fatal error: Call to a member function MoveNext() on a non-object in /opt/lampp/htdocs/medievalbattles/current/v8/httpdocs/game/skills.php on line 189

    Line 89:         $result2->MoveNext();

    Any idea what's going on?


    The while loop that it is part of:

        $sql2 = "SELECT * FROM skills WHERE spec_id = '$tree_id' ORDER BY spec_points ASC";
        $result2 = $__db->Execute($sql2);
        while (!$result2->EOF)
        {

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

  3. Redirect

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

    I am using a php script to process information on a form.  (the form POSTS to x.php)

    At the end of the script I output a simple thank you page.

     
    Should I be redirecting to a different page, or is it ok (normal) to simply create the web output (thank you) as part of the php page?
    (the address of which  would be www.whatever.com/x.php)

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

  4. file upload error

    Date: 11/24/06     Keywords: php, html, apache

    I'm uploading some images using the following code as a part of the catch and validate system

    	$image_details = getimagesize($_FILES['userfile']['tmp_name']);
    	// Reject upload if the file isn't an image.
    	if (!file_exists($_FILES['userfile']['tmp_name']))
    	{
    		$text = "the file vanished!";
    	}
    	elseif (!$image_details)
    	{
    		$text = "that file wasn't an image";
    	}
    
    Testing the system with some jpeg images, one of them goes through fine while the other one reports that it's vanished. They're both under the upload limits of the html and php.ini and it's the smaller one that vanishes. I've even tried resizing and saving the images, but it doesn't change things.

    Anyone any idea what's happening?

    Just in case it's relevant (which I doubt) this is the one that works and this is the one that doesn't. Working with PHP 5.1.4/ Apache 2 on win2000 and Centos boxes

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

  5. Create a file

    Date: 11/24/06     Keywords: no keywords

    This is the script I used to use to create a file.


    //name of file I want to create
    $filename = "openfile.php";
    //open file
    $openfile=fopen($filename,"w");
    //this is some content
    $filecontent = "ephi is terribly lousy in remembering things.";
    //I put the content there
    fputs($openfile, $filecontent);
    //and close the file
    fclose($openfile);
    ?>


    Default folder file permission is 755.
    Any new file in the folder is set to be 644.

    Now the script doesn't work anymore,
    except if I changed the folder permission
    to 757 or 777.
    But, I didn't wish to do that.

    Any work around you can suggest? Thanks.

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

  6. Out of State Clients and Contracts

    Date: 11/23/06     Keywords: no keywords

    If you are doing work for a client remotely, and they are in a different state than you, how does a contract work? Do you just fax it to the client, have them sign, and fax back? Are there any particularly tricky legalities to the contract since it is in two different states?

    I realize YAANAL (you-all are not lawyers).

    X-Posted

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

  7. mysql_affected_rows error

    Date: 11/22/06     Keywords: mysql, database, sql

    ETA: Solved with the help of '[info]'nickinuse.

    Hi guys, I'm trying to make an email verification script.
    1. User enters values to the contact form (done)
    2. Contact form sends verification email to the entered user email (done)
    3. User clicks on the link and verification process is complete (I'm stuck here)



    // 1. open connection to MySQL (okay, done!)
    $koneksi = mysql_connect($db_host, $db_user, $db_password) or die(mysql_error());
    $db_select = mysql_select_db($db_name) or die(mysql_error());

    // 2. query the database to see if the verification string match the ones in the database (this is okay, too!)
    $query = "SELECT email_id FROM email_ver WHERE verify_string=$verify";
    $result = mysql_query($query);
    while ( $data = mysql_fetch_array($result) )
    { $drid = $data['email_id']; }
    if ($drid!=$id)
    { $t="There are no such ID or request."; }
    else {
    // 3. query the database to update that email has been verified (this is where I'm stuck!)
    $query = "UPDATE email_ver SET email_verify='y', verify_string='0' WHERE email_id=$id";
    // specifically these next two lines!
    $result = mysql_query($query) or die(mysql_error());
    $num_rows = mysql_affected_rows($result);
    // if the query work
    if ($num_rows > 0) { echo "Yay! Your email is valid!"; }
    }


    I got this following error:
    Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource

    Why is that happen? When the actual query is successfully done in the database (I've checked and re-checked). [Edit: It's because I'm feeding it with the wrong kind of resource. *LOL*]

    Thanks!

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

  8. New to PEAR

    Date: 11/22/06     Keywords: php, mysql, software, sql, apache

    Hi all

    am Pretty new to using PEAR, facing some pbms here lately ,
    I ve installed pear with the following setup : windows /apache 2/mysql /php5
    now while execute the following code :


    require_once('DB.php');

    $db_host='localhost';

    $db_database='somedb';

    $db_username='someuser';

    $db_password='somepwd';

    $query='select * from employee';

    $dsn = "mysql://$db_username:$db_password@@db_host/$db_database";

    /$db = DB::connect($dsn);

    ?>

    I am getting the following error :

    "Warning: require_once(DB.php) [function.require-once]: failed to open stream: No such file or directory in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\pear.php on line 3

    Fatal error: require_once() [function.require]: Failed opening required 'DB.php' (include_path='C:\PHP\pear') in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\pear.php on line 3"

    please let me know how to fix this.thx alot.
    Praveen.

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

  9. include paths...

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

    Ok, I'm not understanding how this works.

    I have a file called index.php



    Fine, that works from the root of the web directory.
    As does this images/index.php


    But what happens when this is the case includes/auth.php



    How does index.php and images/index.php know how to deal with logger, and auth.php for that matter?

    I guess I want to know how to set these without including the full unix path.

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

  10. problem with adodb

    Date: 11/19/06     Keywords: php, mysql, database, sql

    Hi. I'm not really completely sure as to why this is happening. Here's my error message:

    Fatal error: Call to a member function Execute() on a non-object in /opt/lampp/htdocs/medievalbattles/current/v8/httpdocs/include/functions.php on line 16

    Here's the functions.php line (the whole function, really). Line 16 is $result = $__db->Execute($sql);
    ----------
    // Does this email exist already?
    function checkemail($email)
    {
        global $dbname;
        $sql = "SELECT * FROM $dbname.accounts WHERE email = '$email'";
        $result = $__db->Execute($sql);
        if ($result->RecordCount >= 1)
        {
            $uid = $result->fields["id"];
            return $uid;
        }
        else
            return false;
    }
    ----------

    At the top of functions.php, I am including my config file (include("config.php");)

    The contents of config.php are as follows:
    ----------
    #####################
    ## Database variables
    #####################
    $dbhost = "localhost";
    $dbuser = "root";
    $dbpass = "";
    $dbname = "mb_game";

    /*
    * ADOdb Lite v1.30
    * http://adodblite.sourceforge.net/index.php
    */
    require_once("/opt/lampp/htdocs/medievalbattles/current/v8/httpdocs/adodb/adodb.inc.php");

    $__db = ADONewConnection($dbtype);
    $__db->debug = false;
    $__db->Connect($dbhost, $dbuser, $dbpass);
    ----------

    Any idea as to why I'm getting this error?

    (PHP v5.1.4 - MySQL v5.0.21)

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

  11. Help with for / for each stuff...

    Date: 11/18/06     Keywords: no keywords

    Hi guys,

    I'm trying to write a small gallery script which gives the possibility to upload a number of 1-10 files at once - first thing the user does is pick the number of files to upload, then he is directed to the upload form(s).

    Now my problem is that I don't know how to process the multiple files at once - there are 4 fields for each photo, the file itself, a title, a description and the gallery id. All of that is inserted into a DB after the images have been resized and uploaded - how do I do both of those things for multiple files at once? It must be something with for or foreach, but I have no idea how to use it with multiple files AND multiple fields to be posted at once. The affected part is the add action. Any help would be very appreciated - I'm pretty much a noob (still). :)

    ( The Code.... )

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

  12. Showing PHP Codes

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

    Is there any way to display php codes in a web page? Particularly this code :

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

  13. Sanity check

    Date: 11/17/06     Keywords: no keywords

    Digging into an extreme wtf code base and 90% of the site tree refers to a couple included files of type '.lib'. Ignoring the naming convention, the real issue is this:

    Inside these .lib files are lines and blocks of comments that start with
    #
    instead of `//' or `/* ... */`.

    Just going by the assumption that the site is actually running, but is '#' really a valid/good/sane escape character for comments?

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

  14. CodeIgniter woe

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

    Anyone familiar with either dreamhost, code igniter, or .htaccess? I'm having a problem getting it all setup, and I suspect that my problem is in the .htaccess file.

    My .htaccess:
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L]

    The website in question: http://www.zastica.com/ (you can see that the index page works, but anything else like zastica.com/blog/ dies with "No Input File Specified"

    Any help would be greatly appreciated.

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

  15. Undefined Offsets and index problem

    Date: 11/16/06     Keywords: php, html

    I keep getting undefined notices. I was going to see if you guys could show me the pro way of writing this code so it won't give me all those notices. I can get the undefined index thing to go away by doing this:

    if (!isset($_REQUEST['DateOfBirth']) or $_REQUEST['DateOfBirth'])
       $_REQUEST['DateOfBirth'] = null;
    I want to know how this should be handled. thanks.

    Notices:
    Notice: Undefined index: DateOfBirth in /var/www/budget.fidelityreserves.com/html/clientbudget.php on line 156

    Notice: Undefined offset: 2 in /var/www/budget.fidelityreserves.com/html/clientbudget.php on line 158

    Notice: Undefined offset: 1 in /var/www/budget.fidelityreserves.com/html/clientbudget.php on line 165

    Notice: Undefined offset: 2 in /var/www/budget.fidelityreserves.com/html/clientbudget.php on line 165

    Code:
    //Remove characters from DateOfBirth and split into array of three numbers
    $date_arr = preg_split('/[\-\/ ]/', $_REQUEST['DateOfBirth']);
    //If last number in array is a date field
    if ( $date_arr[2] > 1900 ) {
            //reorder array with last number first
            $date = $date_arr[0].$date_arr[1].$date_arr[2];
            $_REQUEST['DateOfBirth'] = $date;
    }
    else {
            //else order array with first number first
            $date = $date_arr[1].$date_arr[2].$date_arr[0];
            $_REQUEST['DateOfBirth'] = $date;
    }
    Thanks again ^_^

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

  16. Books, PHP, and OOP.

    Date: 11/16/06     Keywords: php, programming, mysql, database, sql, web

    So I wanted an opinion on some books. I consider myself very well... dumb, in PHP. I can write simple backends to manage website content, upload files, screw with databases... but while loops, for statements, classes... they scare me.

    In an effort to expand my knowledge of PHP I recently purchased two books:

    Web Database Applications with PHP and MySQL (2nd Edition) by O'Reilly
    Object-Oriented PHP: Concepts, Techniques, and Code by Peter Lavin

    And the only purpose of this post is to see if any of you have opinions on these books, or suggestions for what I could do to begin obtaining a more robust handle on PHP programming. Because honestly... I'd rather code PHP than design another club flyer.

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

  17. Quotations on Variable in an Echo'd Form Field

    Date: 11/16/06     Keywords: no keywords

    I am drawing a blank here about this. I am clumsily putting this code in:

    echo "'>";

    This works, but I know this is not how this should be handled. I need to include the contents of the variable $total in the field's value. What is the elegant normal way of doing this?

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

  18. array to xml

    Date: 11/13/06     Keywords: php, xml

    Been scanning through php.net's site for a couple of hours looking to see if there was a function that could convert a nested associative array into an xml object or into xml string. I see plenty of functions to take xml strings and convert them into a DOMDocument.

    I guess I could create something that loops through the elements and places tags based on key/value pairs but I would think with PHP's massive library of functions, such a simple function would exist? Just missing it I guess. Anyone know?

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

  19. holy crap @ adodb

    Date: 11/11/06     Keywords: mysql, technology, sql

    i'm just starting to learn the beauty of adodb. freaking hella saved lines of unnecessarily repeated code.

    $sql = "SELECT * FROM $dbname.accounts WHERE id = '".$_COOKIE["account_id"]."'";
    $result = $__db->Execute($sql);
    $account_name = $result->fields["name"];
    $account_prestige = $result->fields["prestige"];
    $account_rank = $result->fields["rank"];
    $account_kills = $result->fields["kills"];

    replaced:

    $account_query = "SELECT * FROM $dbname.accounts WHERE id = '".$_COOKIE["account_id"]."'";
    $account_result = mysql_query($account_query, $connection) or die("Error getting account data: [" . mysql_error() . "]");
    $account_row = mysql_fetch_array($account_result);
    $account_name = $account_row["name"];
    $account_prestige = $account_row["prestige"];
    $account_rank = $account_row["rank"];
    $account_kills = $account_row["kills"];

    horray for coding technology! time to dance!

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

  20. w2box or something like it

    Date: 11/10/06     Keywords: html, web, linux, apache

    I created a script a while ago that allowed users to upload files to a folder and then update the html page to show the new file and the description given via a form. The users now want to be able to delete items that they uploaded. Naturally this is months after I worked on the script and they want it done today (dammit).
    I found a rather nice tool in w2box:
    http://labs.beffa.org/w2box/
    except I can not get it to work on my server for some reason. Has anyone worked with it? The creators have not responded to my ask for help yet. Is there another script out on the interwebs that allows for file upload, deletion and downloading that is easy to deal with on a Linux/Apache server?

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