Results 1 to 4 of 4

Thread: Help with PHP

  1. #1
    Senior Member
    Join Date
    Dec 2001
    Posts
    304

    Help with PHP

    Ok first off I would like to say that I really know little about PHP. I am good at looking at code and figureing out what it does though. With that said I am trying to modify a PHP script and having a bit of trouble.

    I will give a little history first

    Ok this script uses a database as well. What it does is it gives you a page where you can add a file information, example : filename, version , author ect... I am using this script to keep track of my files. The script would be perfect on its own exept I am trying to add a feild to put the md5sum of the file so it will list that as well as all the other information. This is were I am running into trouble.

    There are 3 files that I have been editing to do this.

    One is called file.php and it is in the includes directory
    One is called file.php and it is in the includes/admin directory
    One is called language.php and that is in the language directory

    file.php in the includes directory is the file that displays the final information after you submit it
    file.php in the includes/admin directory is where you fill out and submit the information
    language.php is the language file of course [ not having any trouble there but just thought I would give the complete list of files i altered.

    So I take a look at the source of includes/file.php and see that for the field long discription it has a statment like this

    PHP Code:
    <tr><td width="20%" class="datacell"><?php echo $str[desc]; ?>:</td><td width="80%" class="datacell"><?php echo $file[file_longdesc]; ?></td></tr>
    ok that tells me that to make the field long discription display the discription that was inputed from includes/admin/file.php you have to include the <?php echo $file[file_longdesc]; ?> .

    Ok since I want to display md5sum this is what I added to make the field appear on that page


    PHP Code:
    <tr><td width="20%" class="datacell"><?php echo $str[md5sum]; ?>:</td><td width="80%" class="datacell"><?php echo $file[file_mdsum]; ?></td></tr>
    Ok, upload it and the field is there, now I have to get the information from includes/admin/file.php to includes/file.php

    So I take a look at that

    I notice that for the long description line they have this

    PHP Code:
    <tr><td width="50%" align="right" class="datacell"><?php echo $str[fileld]; ?></td><td width="50%" align="left" class="datacell"><input type="text" class="forminput" size="50" name="form[longdesc]">
    <a class="small"><?php echo $str[fileldinfo]; ?></td></tr>
    Ok this tells me that they use "form[longdesc]" as the name so that if you remember from includes/file.php they added <?php echo $file[file_longdesc]; ?> ok but the one is saying form and the other is saying $file that didnt make sence to me untill i scrolled down and saw this

    PHP Code:
    $query .= "file_longdesc = '$form[longdesc]', "
    ok that makes sence... this line tells us that '$form[longdesc]', "; is refered to with the statment
    "file_longdesc ok good.. So this is what I do:

    I add

    PHP Code:
    <tr><td width="50%" align="right" class="datacell"><?php echo $str[md5sum]; ?></td><td width="50%" align="left" class="datacell"><input type="text" class="forminput" size="50" name="form[mdsum]">
    <a class="small"><?php echo $str[md5sumexplain]; ?></td></tr>
    to make the feild to put the info in and then go down the script a bit and add

    PHP Code:
    $query .= "file_mdsum = '$form[mdsum]', "
    along with the other $query feilds to I guess you would say declare it.

    I then edited the language file to make all my $str statements work. Upload all this and refresh and its all there , a place to add the info and a place to display the final outcome of adding the info

    So I add something to test it submit and to my dismay it is not including the md5sum the feild is just empty. Ok maybe my logic wrong, i screwed up somewhere . BUt then got the idea, ok the info is displaying for long discription and everything else but not md5sum. I edit the includes/admin/file.php to make the statement for the md5sum be <?php echo $file[file_longdesc]; ?> instead of <?php echo $file[file_mdsum]; ?> upload and refresh and now in the md5sum feild it displays a description... so my logic is right.

    I dont understand why this dont work then. Because I added another feild do I have to add another table to the database you think so it has a place to store it or should the database be fine.

    Any help would be appreciated
    Violence breeds violence
    we need a world court
    not a republican with his hands covered in oil and military hardware lecturing us on world security!

  2. #2
    Senior Member
    Join Date
    Dec 2001
    Posts
    304
    After further look at the code, I dont belive that it is a problem with the php. The problem lies that i know nothing about mysql and I dont know how to make a table for this to work. I am currently reading up on it but if anyone has any idea of a table to use would be helpfull
    Violence breeds violence
    we need a world court
    not a republican with his hands covered in oil and military hardware lecturing us on world security!

  3. #3
    Senior Member
    Join Date
    Dec 2001
    Posts
    304
    Ok, here is the code to create the default database

    CREATE TABLE $db[prefix]_admin (
    admin_id int(10) NOT NULL auto_increment,
    admin_username text,
    admin_password text,
    admin_email text,
    admin_status int(1) default NULL,
    PRIMARY KEY (admin_id)
    )";
    $pafiledb_sql->query($db,$query,0);
    echo "Done
    ";

    echo "Creating table $db[prefix]_cat: ";
    $query = "
    CREATE TABLE $db[prefix]_cat (
    cat_id int(10) NOT NULL auto_increment,
    cat_name text,
    cat_desc text,
    cat_files int(10) default NULL,
    cat_1xid int(10) default NULL,
    cat_parent int(50) default NULL,
    cat_order int(50) default NULL,
    PRIMARY KEY (cat_id)
    )";
    $pafiledb_sql->query($db,$query,0);
    echo "Done
    ";

    echo "Creating table $db[prefix]_custom: ";
    $query = "
    CREATE TABLE $db[prefix]_custom (
    custom_id int(50) NOT NULL auto_increment,
    custom_name text NOT NULL,
    custom_description text NOT NULL,
    PRIMARY KEY (custom_id)
    )";
    $pafiledb_sql->query($db,$query,0);
    echo "Done
    ";

    echo "Creating table $db[prefix]_customdata: ";
    $query = "
    CREATE TABLE $db[prefix]_customdata (
    customdata_file int(50) NOT NULL default '0',
    customdata_custom int(50) NOT NULL default '0',
    data text NOT NULL
    )";
    $pafiledb_sql->query($db,$query,0);
    echo "Done
    ";

    echo "Creating table $db[prefix]_files: ";
    $query = "
    CREATE TABLE $db[prefix]_files (
    file_id int(10) NOT NULL auto_increment,
    file_name text,
    file_desc text,
    file_creator text,
    file_version text,
    file_longdesc text,
    file_ssurl text,
    file_dlurl text,
    file_time int(50) default NULL,
    file_catid int(10) default NULL,
    file_posticon text,
    file_license int(10) default NULL,
    file_dls int(10) default NULL,
    file_last int(50) default NULL,
    file_pin int(2) default NULL,
    file_docsurl text,
    file_rating text NOT NULL,
    file_totalvotes text NOT NULL,
    PRIMARY KEY (file_id)
    )";
    $pafiledb_sql->query($db,$query,0);
    echo "Done
    ";

    echo "Creating table $db[prefix]_license: ";
    $query = "
    CREATE TABLE $db[prefix]_license (
    license_id int(10) NOT NULL auto_increment,
    license_name text,
    license_text text,
    PRIMARY KEY (license_id)
    )";
    $pafiledb_sql->query($db,$query,0);
    echo "Done
    ";
    }
    if ($settings[installtype] != 4) {
    echo "Creating table $db[prefix]_settings: ";
    $query = "
    CREATE TABLE $db[prefix]_settings (
    settings_id int(1) NOT NULL default '1',
    settings_dbname text NOT NULL,
    settings_dbdescription text NOT NULL,
    settings_dburl text NOT NULL,
    settings_topnumber int(5) NOT NULL default '0',
    settings_homeurl text NOT NULL,
    settings_newdays int(5) NOT NULL default '0',
    settings_timeoffset int(5) NOT NULL default '0',
    settings_timezone text NOT NULL,
    settings_header text NOT NULL,
    settings_footer text NOT NULL,
    settings_style text NOT NULL,
    settings_stats int(5) NOT NULL default '0',
    settings_lang text NOT NULL,
    settings_viewall int(5) NOT NULL,
    settings_showss int(5) NOT NULL,
    settings_disable int(5) NOT NULL
    )";
    $pafiledb_sql->query($db,$query,0);
    echo "Done
    ";


    I am pretty sure that the part that i need to change is

    CREATE TABLE $db[prefix]_files (
    file_id int(10) NOT NULL auto_increment,
    file_name text,
    file_desc text,
    file_creator text,
    file_version text,
    file_longdesc text,
    file_ssurl text,
    file_dlurl text,
    file_time int(50) default NULL,
    file_catid int(10) default NULL,
    file_posticon text,
    file_license int(10) default NULL,
    file_dls int(10) default NULL,
    file_last int(50) default NULL,
    file_pin int(2) default NULL,
    file_docsurl text,
    file_rating text NOT NULL,
    file_totalvotes text NOT NULL,
    PRIMARY KEY (file_id)
    )";

    i assuemed that i had to add in that table file_mdsum text;

    but that dont work. Can anyone help me figure out what i have to add to this table?
    Violence breeds violence
    we need a world court
    not a republican with his hands covered in oil and military hardware lecturing us on world security!

  4. #4
    Hey ..... I saw this thread and just wanted to know what is PHP and what is it use for ? I know and understand P@P is it the same thing ???? thankx


    -alpa

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •