Menu

#8 Asset Tag truncated on update screen

open
nobody
None
5
2004-08-23
2004-08-23
Anonymous
No

$assettag = substr($query_data["AssetTag"],1,6);

should be

$assettag = substr($query_data["AssetTag"],0,10);

The database field is 10 characters long and starting
at position 1 chops off the first character. Do we
need substr here instead of pulling the entire field
from the table?

Discussion

  • Timothy

    Timothy - 2004-09-23

    Logged In: YES
    user_id=1127217

    This is due to the form field and the insertstatements in the
    index.php file. A made q quick fix (warning I have not done
    much testing to see the fallout)..

    In Asset_Admin.php change
    ****

    //Asset Tag
    echo "<font class='text11bold'>Asset Tag:<br> <input
    type='text' name='assettag' maxlength=6 size=6 value=\"" .
    $assettag . "\" class='boxtext13'><font color='#ff0033'
    face='arial' size='4'><b> *</b></font><br></font>";
    echo "</td>\n";
    echo "<td class='text11' valign='top'>";

    To
    //Asset Tag
    echo "<font class='text11bold'>Asset Tag:<br> <input
    type='text' name='assettag' maxlength=12 size=10 value=\"" .
    $assettag . "\" class='boxtext13'><font color='#ff0033'
    face='arial' size='4'><b> *</b></font><br></font>";
    echo "</td>\n";
    echo "<td class='text11' valign='top'>";

    ***

    This will make the form field long enough to display a longer
    name, but you sitll have to pull the whole name from the
    database (again is asset_admin)

    ***
    Change

    $assettag = substr($query_data["AssetTag"],0,6);

    to

    $assettag = substr($query_data["AssetTag"],0,12);

    ***

    Finally I noticed that whenever I did an update the asset was
    taegd automatically with an 'A' which is not what I wanted so
    I changes the insert statements..

    Anything of the Form

    sql = "INSERT INTO Assets
    (assettag,assettype,os,assetsupplier,assetmodel,assetserial,a
    ssetprice,notes) VALUES ('A" . $assettag . "','" .
    $assettype . "','" . $os . "','" . $assetsupplier . "','" .
    $assetmodel . "','" . $assetserial . "'," . $assetprice . ",'" .
    $notes . "');";

    I changed to

    sql = "INSERT INTO Assets
    (assettag,assettype,os,assetsupplier,assetmodel,assetserial,a
    ssetprice,notes) VALUES ('" . $assettag . "','" .
    $assettype . "','" . $os . "','" . $assetsupplier . "','" .
    $assetmodel . "','" . $assetserial . "'," . $assetprice . ",'" .
    $notes . "');";

    Hope this helps

     
  • Nobody/Anonymous

    Logged In: NO

    In addidtion to the tip mentionned below, to remove the A,
    you need to change the following:

    $sql = "UPDATE Assets SET assettag='A" .
    $assettag . "',assettype='" . $assettype . "',os='"

    Change it to:

    $sql = "UPDATE Assets SET assettag='" .
    $assettag . "',assettype='" . $assettype . "',os='"

     

Log in to post a comment.

MongoDB Logo MongoDB