Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6

Thread: error in code

  1. #1
    Senior Member
    Join Date
    Feb 2005
    Location
    Canada
    Posts
    435
    Member #
    8983
    I have the following source code to print to a waybill my server isn't showing me the error but won't print the file:

    PHP Code:
    <?

    Header
    ("Content-Type: text/html");
    $Sname $_POST['Sname'];
    $Saddress $_POST['Saddress'];
    $Scity $_POST['Scity'];
    $Szip $_POST['Szip'];

    $Rname $_POST['Rname'];
    $Raddress $_POST['Raddress'];
    $Rcity $_POST['Rcity'];
    $Rzip $_POST['Rzip'];

    $pieces $_POST['pieces'];
    $weight $_POST['weight'];
    $dT $_POST['type'];

    $go true;
    echo(
    '<html><head><title>Results</title></head><body><ul>');
    if (!isset(
    $Sname) || $Sname <= "")
     { 

    echo(
    '<li><span style="color:#ff0000;">From field sender NAME not filled out</span></li>');
    $go false;
     }
    if (!isset(
    $Saddress) || $Saddress <= "")
     { 
    echo(
    '<span style="color:#ff0000;">From field sender ADDRESS not filled out</span></li>');
    $go false;
     }
    if (!isset(
    $Scity) || $Scity <= "")
     { 
    echo(
    '<li><span style="color:#ff0000;">From field sender CITY not filled out</span></li>');
    $go false;
     }
    if (!isset(
    $Szip) || $Szip <= "")
     { 
    echo(
    '<li><span style="color:#ff0000;">From field sender POSTAL CODE not filled out</span></li>');
    $go false;
     }

    if (!isset(
    $Rname) || $Rname <= "")
     { 
    echo(
    '<li><span style="color:#ff0000;">From field Reciver NAME not filled out</span></li>');
    $go false;
     }
    if (!isset(
    $Raddress) || $Raddress <= "")
     { 
    echo(
    '<li><span style="color:#ff0000;">From field Reciver ADDRESS not filled out</span>');
    $go false;
     }
    if (!isset(
    $Rcity) || $Rcity <= "")
     { 
    echo(
    '<li><span style="color:#ff0000;">From field Reciver CITY not filled out</span></li>');
    $go false;
     }
    if (!isset(
    $Rzip) || $Rzip <= "")
     { 
    echo(
    '<li><span style="color:#ff0000;">From field Reciver POSTAL CODE not filled out</span></li>');
    $go false;
    $go false;
     }
    if(
    $go == true)
    {
    $id ImageCreateFromPng("wayTemplate.png");
    $black ImageColorAllocate($id00255);
    ImageString($id44070$Sname$black);
    ImageString($id44093$Saddress$black);
    ImageString($id440115$Scity$black);
    ImageString($id4160115$Szip$black);
    $black ImageColorAllocate($id0122255);

    ImageString($id440155$Rname$black);
    ImageString($id440177$Raddress$black);
    ImageString($id440200$Rcity$black);
    ImageString($id4160200$Rzip$black);

    $black ImageColorAllocate($id000);
    ImageString($id4500150$pieces$black);
    /*if($dT == "sameDay")
        {ImageString($id, 4, 500, 57, "*", $black);}
    if($dT == "priority")
        {ImageString($id, 4, 500, 77, "*", $black);}
    if($dT == "rush")
        {ImageString($id, 4, 500, 97, "*", $black);}
    if($dT == "direct")
        {ImageString($id, 4, 500, 117, "*", $black);}*/    
        

    ImagePNG($id,"bills/" $Sname "w1.png");
    echo(
    '<h1>Request Recived</h1>');
    echo(
    '<p>Your Bill has been recived delivery will commence upon recipt of your request.</p>');
    //begin the emailing portion of the script 
    }

    echo(
    '<p>Powered by: <a href="pyrodesign.byethost11.com">Pyrodesign</a></p>');

    echo(
    '</body>');
    echo(
    '</html>');
    ?>
    any ideas
    Thee Pyro Wolf

  2.  

  3. #2
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Last I checked, PHP is case-sensitive; thus, there is no function `Header'. You need to call `header' instead. Poke around for a bit, a recent thread started by raspberryh explains how to enable error-reporting at runtime. The only errors you'll miss then are syntax errors that prevent the script from being parsed in the first place.

  4. #3
    ljm
    ljm is offline
    Senior Member ljm's Avatar
    Join Date
    Aug 2006
    Location
    Manchester, England
    Posts
    284
    Member #
    13684
    Liked
    1 times
    I would also suggest changing the functions to lowercase. For example:

    imagepng, not imagePNG
    imagestring, not imageString
    imagecolorallocate, not imageColorAllocate
    imagecreatefrompng, not imageCreateFromPNG


    Also I think your if statements have something wrong with them. I've had trouble with using 'or' in the statement so either replace it with 'and' (&&), or change it altogether:

    PHP Code:
    if (empty($Sname)) 
     {  

    echo 
    "<li><span style="color:#ff0000;">From field sender NAME not filled out</span></li>"; 
    $go 'false'
     } 
    Note how I've replaced isset() with empty().

    Wait, and there's more after reading through it again.

    PHP Code:
    if($go == true
    should be
    PHP Code:
    if($go == 'true'
    and in each if statement, you need to put quotes around 'false' (and 'true' at the start) since they're strings.

    In fact, I'll post up the edited code, you can see this test to show that there's output now: http://www.chrisbrewster.co.uk/test.php

    PHP Code:
    <?

    header
    ("Content-Type: text/html");
    $Sname $_POST['Sname'];
    $Saddress $_POST['Saddress'];
    $Scity $_POST['Scity'];
    $Szip $_POST['Szip'];

    $Rname $_POST['Rname'];
    $Raddress $_POST['Raddress'];
    $Rcity $_POST['Rcity'];
    $Rzip $_POST['Rzip'];

    $pieces $_POST['pieces'];
    $weight $_POST['weight'];
    $dT $_POST['type'];

    $go 'true';
    echo(
    '<html><head><title>Results</title></head><body><ul>');
    if (empty(
    $Sname))
    {

    echo(
    '<li><span style="color:#ff0000;">From field sender NAME not filled out</span></li>');
    $go 'false';
    }
    if (empty(
    $Saddress))
    {
    echo(
    '<li><span style="color:#ff0000;">From field sender ADDRESS not filled out</span></li>');
    $go 'false';
    }
    if (empty(
    $Scity))
    {
    echo(
    '<li><span style="color:#ff0000;">From field sender CITY not filled out</span></li>');
    $go 'false';
    }
    if (empty(
    $Szip))
    {
    echo(
    '<li><span style="color:#ff0000;">From field sender POSTAL CODE not filled out</span></li>');
    $go 'false';
    }

    if (empty(
    $Rname))
    {
    echo(
    '<li><span style="color:#ff0000;">From field Reciver NAME not filled out</span></li>');
    $go 'false';
    }
    if (empty(
    $Raddress))
    {
    echo(
    '<li><span style="color:#ff0000;">From field Reciver ADDRESS not filled out</span>');
    $go 'false';
    }
    if (empty(
    $Rcity))
    {
    echo(
    '<li><span style="color:#ff0000;">From field Reciver CITY not filled out</span></li>');
    $go 'false';
    }
    if (empty(
    $Rzip))
    {
    echo(
    '<li><span style="color:#ff0000;">From field Reciver POSTAL CODE not filled out</span></li>');
    $go 'false';
    }
    if(
    $go == 'true')
    {
    $id imagecreatefrompng("wayTemplate.png");
    $black imagecolorallocate($id00255);
    imagestring($id44070$Sname$black);
    imagestring($id44093$Saddress$black);
    imagestring($id440115$Scity$black);
    imagestring($id4160115$Szip$black);
    $black imagecolorallocate($id0122255);

    imagestring($id440155$Rname$black);
    imagestring($id440177$Raddress$black);
    imagestring($id440200$Rcity$black);
    imagestring($id4160200$Rzip$black);

    $black imagecolorallocate($id000);
    imagestring($id4500150$pieces$black);

    // DOES THIS BIT NEED TO BE IN COMMENTS???

    /*if($dT == "sameDay")
        {imagestring($id, 4, 500, 57, "*", $black);}
    if($dT == "priority")
        {imagestring($id, 4, 500, 77, "*", $black);}
    if($dT == "rush")
        {imagestring($id, 4, 500, 97, "*", $black);}
    if($dT == "direct")
        {imagestring($id, 4, 500, 117, "*", $black);}*/    
        

    imagepng($id,"bills/" $Sname "w1.png");
    echo(
    '<h1>Request Recived</h1>');
    echo(
    '<p>Your Bill has been recived delivery will commence upon recipt of your request.</p>');
    //begin the emailing portion of the script
    }

    echo(
    '<p>Powered by: <a href="pyrodesign.byethost11.com">Pyrodesign</a></p>');

    echo(
    '</body>');
    echo(
    '</html>');
    ?>

  5. #4
    Senior Member
    Join Date
    Feb 2005
    Location
    Canada
    Posts
    435
    Member #
    8983
    PHP Code:
    if($go == true
    should be
    PHP Code:
    if($go == 'true'
    and in each if statement, you need to put quotes around 'false' (and 'true' at the start) since they're strings.
    actually there boolean variables. thanks for all the help though
    Thee Pyro Wolf

  6. #5
    ljm
    ljm is offline
    Senior Member ljm's Avatar
    Join Date
    Aug 2006
    Location
    Manchester, England
    Posts
    284
    Member #
    13684
    Liked
    1 times
    I see. As I say though I messed with it myself and there's output.

  7. #6
    Senior Member
    Join Date
    Feb 2005
    Location
    Canada
    Posts
    435
    Member #
    8983
    again thanks a bunch i am realativly new to php an am therefore just tring to figure everything out
    Thee Pyro Wolf


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 03:54 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com