SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot
    Join Date
    May 2001
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Extra Set of Eyes REALLY needed!!

    Hi all,

    I get a parse error on line 166 of this script, but I am not sure why. It worked before, but I added a bunch of stuff to it, and then it wouldn't work anymore. Obviously something to do with the if: , else: <php endif; ?> part of things. If you can figure this out, I would be forever indebted to you!! P.S. - Sorry the code is so long! (and I know I have a crude way of goin about things...I am just new at this stuff! )

    Cheers,

    -XGuy.

    PHP Code:
    <!-- newart.php -->
    <HTML>
    <HEAD>
    <TITLE>Add New Article</TITLE>
    </HEAD>
    <BODY>
    <H1>Add New Article</H1>
    <?php

    if ($submit): // A new article has been entered
                  // using the form below.

      
    if ($aid == "") {
        echo(
    "<P>You must choose an author " .
             
    "for this document. Click 'Back' " .
             
    "and try again. </P>");
        exit();
      }

      if (
    $type == "") {
        echo(
    "<P>You must choose a <u>document</u> type " .
             
    "for this document. Click 'Back' " .
             
    "and try again. </P>");
        exit();
      }

      if (
    $pdate == "") {
        echo(
    "<P>You must choose a date of publication " .
             
    "for this document. Click 'Back' " .
             
    "and try again. </P>");
        exit();
      }

      if (
    $country == "") {
        echo(
    "<P>You must choose a country " .
             
    "for this document. Click 'Back' " .
             
    "and try again. </P>");
        exit();
      }

      
    $html = isset ($html);
      
    $pdf  = isset ($pdf);

      if (!
    $html && !$pdf) {
        echo(
    "<P>You must choose a <u>file</u> type " .
             
    "for this document. Click 'Back' " .
             
    "and try again. </P>");
        exit();
      }

       if (
    $userfile) { 
          
          if (
    $html) {
            
             if (
    $type=="1") {
                  
    $html="http://www.somewhere.ca/assets/documents/articles/$userfile_name";
                  if (
    copy($userfile,"../documents/articles/$userfile_name")) { 
                     echo(
    "<B> File successfully uploaded</B>");
                     } else {
                     echo(
    "<B>Error uploading file. However, document details will still be entered into the database. Please upload file manually to the articles folder.</B>");
                     }   

             } else {
     
             if (
    $type=="2") {
                  
    $html="http://www.somewhere.ca/assets/documents/regulations/$userfile_name";
                  if (
    copy($userfile,"../documents/regulations/$userfile_name")) { 
                     echo(
    "<B> File successfully uploaded</B>");
                     } else {
                     echo(
    "<B>Error uploading file. However, document details will still be entered into the database. Please upload file manually to the educational folder.</B>");
                     }    

             } else {

             if (
    $type=="3") {
                  
    $html="http://www.somewhere.ca/assets/documents/educational/$userfile_name";
                  if (
    copy($userfile,"../documents/educational/$userfile_name")) { 
                     echo(
    "<B> File successfully uploaded</B>");
                     } else {
                     echo(
    "<B>Error uploading file. However, document details will still be entered into the database. Please upload file manually to the regulations folder.</B>");
                     }    
          } 
    // end of html if statement

          
    if ($pdf) {
            
             if (
    $type=="1") {
                  
    $pdf="http://www.somewhere.ca/assets/documents/articles/$userfile_name";
                  if (
    copy($userfile,"../documents/articles/$userfile_name")) { 
                     echo(
    "<B> File successfully uploaded</B>");
                     } else {
                     echo(
    "<B>Error uploading file. However, document details will still be entered into the database. Please upload file manually to the articles folder.</B>");
                     }   

             } else {
     
             if (
    $type=="2") {
                  
    $pdf="http://www.somewhere.ca/assets/documents/regulations/$userfile_name";
                  if (
    copy($userfile,"../documents/regulations/$userfile_name")) { 
                     echo(
    "<B> File successfully uploaded</B>");
                     } else {
                     echo(
    "<B>Error uploading file. However, document details will still be entered into the database. Please upload file manually to the educational folder.</B>");
                     }    

             } else {

             if (
    $type=="3") {
                  
    $pdf="http://www.somewhere.ca/assets/documents/educational/$userfile_name";
                  if (
    copy($userfile,"../documents/educational/$userfile_name")) { 
                     echo(
    "<B> File successfully uploaded</B>");
                     } else {
                     echo(
    "<B>Error uploading file. However, document details will still be entered into the database. Please upload file manually to the regulations folder.</B>");
                     }    
          } 
    // end of pdf if statement
     
       
    // end of userfile if statement

    unlink($userfile);

    $html htmlspecialchars($html);
    $pdf  htmlspecialchars($pdf);

    $dbcnx = @mysql_connect("localhost""user""pass");
    mysql_select_db("my_db");

      
    $sql "INSERT INTO articles SET " .
             
    "AID='$aid', " .
             
    "pub_date='$pdate', " .
             
    "Country='$country', " .
             
    "TYPE='$type', " .  
             
    "HTMLlink='$html', " .
             
    "PDFlink='$pdf', " .
             
    "Comments='$ments', " .
             
    "Description='$scrip'";         
      if (
    mysql_query($sql)) {
        echo(
    "<P>New Article Added</P>");
      } else {
        echo(
    "<P>Error adding new article: " .
             
    mysql_error() . "</P>");
      }

    $rid mysql_insert_id();

    $cats mysql_query("SELECT ID, Name FROM categories");

     while (
    $cat mysql_fetch_array($cats)) {
       
    $cid $cat["ID"];
       
    $cname $cat["Name"];
       
    $var "cat$cid"// The name of the variable
       
    if ($$var) { // The checkbox is checked
         
    $sql "INSERT IGNORE INTO artlookup " .
                
    "SET RID=$rid, CID=$cid";
         
    $ok mysql_query($sql);
         if (
    $ok) {
           echo(
    "<P>Article added to category: $cname</P>");
         } else {
           echo(
    "<P>Error inserting article into category $cname:" .
                
    mysql_error() . "</P>");
         } 
       } 
    // end of if ($$var)
     
    // end of while loop                     
                             
    ?> 
    <P><A HREF="<?php echo($PHP_SELF); ?>">Add another Document</A></P>
    <P><A HREF="articles.php">Return to Databank search</A></P>

    <?php
      
    else: // Allow the user to enter a new document

      
    $dbcnx = @mysql_connect("localhost""user""pass");
      
    mysql_select_db("my_db");

      
    $authors mysql_query("SELECT ID, last_name, first_name FROM authors");
      
    $cats    mysql_query("SELECT ID, Name FROM categories");
    ?>

    <FORM ACTION="<?php echo($PHP_SELF); ?>" METHOD=POST ENCTYPE="multipart/form-data">                        
    <P>Author:
    <SELECT NAME="aid" SIZE=1>
      <OPTION SELECTED VALUE="">Select One
    <?php
     
    while ($author mysql_fetch_array($authors)) {
       
    $aid $author["ID"];
       
    $aname $author["last_name"] . ", " $author["first_name"];
        echo(
    "<OPTION VALUE='$aid'>$aname\n");
     }
    ?>
    </SELECT></P>
    <P>Place in categories:<BR>
    <?php
      
    while ($cat mysql_fetch_array($cats)) {
        
    $cid $cat["ID"];
        
    $cname $cat["Name"];
        echo(
    "<INPUT TYPE=CHECKBOX NAME='cat$cid'>$cname<BR>\n");
      }
    ?>
    </P>
    <P>Choose Document Type:<BR>
                              <SELECT NAME="type" SIZE=1>
                  <OPTION SELECTED VALUE="">Choose One
                  <OPTION VALUE="1">Article
                  <OPTION VALUE="2">Government Document
                  <OPTION VALUE="3">Educational Materials
                  </SELECT>
                  <BR>
    Choose Publication Date:
                <SELECT NAME="pdate" SIZE=1>
                  <OPTION SELECTED VALUE="">Choose One
                  <OPTION VALUE="1">1970
                  <OPTION VALUE="2">1971
                  <OPTION VALUE="3">1972
                  <OPTION VALUE="4">1973
                  <OPTION VALUE="5">1974
                  <OPTION VALUE="6">1975
                        <OPTION VALUE="7">1976
                        <OPTION VALUE="8">1977
                        <OPTION VALUE="9">1978
                        <OPTION VALUE="10">1979
                        <OPTION VALUE="11">1980
                        <OPTION VALUE="12">1981
                        <OPTION VALUE="13">1982
                        <OPTION VALUE="14">1983
                        <OPTION VALUE="15">1984
                        <OPTION VALUE="16">1985
                        <OPTION VALUE="17">1986
                        <OPTION VALUE="18">1987
                        <OPTION VALUE="19">1988
                        <OPTION VALUE="20">1989
                        <OPTION VALUE="21">1990
                        <OPTION VALUE="22">1991
                        <OPTION VALUE="23">1992
                        <OPTION VALUE="24">1993
                        <OPTION VALUE="25">1994
                        <OPTION VALUE="26">1995
                        <OPTION VALUE="27">1996
                        <OPTION VALUE="28">1997
                        <OPTION VALUE="29">1998
                        <OPTION VALUE="30">1999
                        <OPTION VALUE="31">2000
                        <OPTION VALUE="32">2001
                        </SELECT>
                        <BR>
    Choose Country:
    <select name="country" SIZE=1>
    <option selected value="">Select One
    <option value="1">Canada
    <option value="2">United States
    <option value="3">Afghanistan
    <option value="4">Albania
    <option value="5">Algeria
    <option value="6">American Samoa
    <option value="7">Andorra
    <option value="8">Angola
    <option value="9">Anguilla
    <option value="10">Antarctica
    <option value="11">Antigua And Barbuda
    <option value="12">Argentina
    <option value="13">Armenia
    <option value="14">Aruba
    <option value="15">Australia
    <option value="16">Austria
    <option value="17">Azerbaijan
    <option value="18">Bahamas, The
    <option value="19">Bahrain
    <option value="20">Bangladesh
    <option value="21">Barbados
    <option value="22">Belarus
    <option value="23">Belgium
    <option value="24">Belize
    <option value="25">Benin
    <option value="26">Bermuda
    <option value="27">Bhutan
    <option value="28">Bolivia
    <option value="29">Bosnia and Herzegovina
    <option value="30">Botswana
    <option value="31">Bouvet Island
    <option value="32">Brazil
    <option value="33">British Indian Ocean Territory
    <option value="34">Brunei
    <option value="35">Bulgaria
    <option value="36">Burkina Faso
    <option value="37">Burundi
    <option value="38">Cambodia
    <option value="39">Cameroon
    <option value="40">Cape Verde
    <option value="41">Cayman Islands
    <option value="42">Central African Republic
    <option value="43">Chad
    <option value="44">Chile
    <option value="45">China
    <option value="46">Christmas Island
    <option value="47">Cocos (Keeling) Islands
    <option value="48">Colombia
    <option value="49">Comoros
    <option value="50">Congo
    <option value="51">Congo, Democractic Republic of the
    <option value="52">Cook Islands
    <option value="53">Costa Rica
    <option value="54">Cote D'Ivoire (Ivory Coast)
    <option value="55">Croatia (Hrvatska)
    <option value="56">Cuba
    <option value="57">Cyprus
    <option value="58">Czech Republic
    <option value="59">Denmark
    <option value="60">Djibouti
    <option value="61">Dominica
    <option value="62">Dominican Republic
    <option value="63">East Timor
    <option value="64">Ecuador
    <option value="65">Egypt
    <option value="66">El Salvador
    <option value="67">Equatorial Guinea
    <option value="68">Eritrea
    <option value="69">Estonia
    <option value="70">Ethiopia
    <option value="71">Falkland Islands (Islas Malvinas)
    <option value="72">Faroe Islands
    <option value="73">Fiji Islands
    <option value="74">Finland
    <option value="75">France
    <option value="76">French Guiana
    <option value="77">French Polynesia
    <option value="78">French Southern Territories
    <option value="79">Gabon
    <option value="80">Gambia, The
    <option value="81">Georgia
    <option value="82">Germany
    <option value="83">Ghana
    <option value="84">Gibraltar
    <option value="85">Greece
    <option value="86">Greenland
    <option value="87">Grenada
    <option value="88">Guadeloupe
    <option value="89">Guam
    <option value="90">Guatemala
    <option value="91">Guinea
    <option value="92">Guinea-Bissau
    <option value="93">Guyana
    <option value="94">Haiti
    <option value="95">Heard and McDonald Islands
    <option value="96">Honduras
    <option value="97">Hong Kong S.A.R.
    <option value="98">Hungary
    <option value="99">Iceland
    <option value="100">India
    <option value="101">Indonesia
    <option value="102">Iran
    <option value="103">Iraq
    <option value="104">Ireland
    <option value="105">Israel
    <option value="106">Italy
    <option value="107">Jamaica
    <option value="108">Japan
    <option value="109">Jordan
    <option value="110">Kazakhstan
    <option value="111">Kenya
    <option value="112">Kiribati
    <option value="113">Korea
    <option value="114">Korea, North
    <option value="115">Kuwait
    <option value="116">Kyrgyzstan
    <option value="117">Laos
    <option value="118">Latvia
    <option value="119">Lebanon
    <option value="120">Lesotho
    <option value="121">Liberia
    <option value="122">Libya
    <option value="123">Liechtenstein
    <option value="124">Lithuania
    <option value="125">Luxembourg
    <option value="126">Macau S.A.R.
    <option value="127">Macedonia, Former Yugoslav Republic of
    <option value="128">Madagascar
    <option value="129">Malawi
    <option value="130">Malaysia
    <option value="131">Maldives
    <option value="132">Mali
    <option value="133">Malta
    <option value="134">Marshall Islands
    <option value="135">Martinique
    <option value="136">Mauritania
    <option value="137">Mauritius
    <option value="138">Mayotte
    <option value="139">Mexico
    <option value="140">Micronesia
    <option value="141">Moldova
    <option value="142">Monaco
    <option value="143">Mongolia
    <option value="144">Montserrat
    <option value="145">Morocco
    <option value="146">Mozambique
    <option value="147">Myanmar
    <option value="148">Namibia
    <option value="149">Nauru
    <option value="150">Nepal
    <option value="151">Netherlands Antilles
    <option value="152">Netherlands, The
    <option value="153">New Caledonia
    <option value="154">New Zealand
    <option value="155">Nicaragua
    <option value="156">Niger
    <option value="157">Nigeria
    <option value="158">Niue
    <option value="159">Norfolk Island
    <option value="160">Northern Mariana Islands
    <option value="161">Norway
    <option value="162">Oman
    <option value="163">Pakistan
    <option value="164">Palau
    <option value="165">Panama
    <option value="166">Papua new Guinea
    <option value="167">Paraguay
    <option value="168">Peru
    <option value="169">Philippines
    <option value="170">Pitcairn Island
    <option value="171">Poland
    <option value="172">Portugal
    <option value="173">Puerto Rico
    <option value="174">Qatar
    <option value="175">Reunion
    <option value="176">Romania
    <option value="177">Russia
    <option value="178">Rwanda
    <option value="179">Saint Helena
    <option value="180">Saint Kitts And Nevis
    <option value="181">Saint Lucia
    <option value="182">Saint Pierre and Miquelon
    <option value="183">Saint Vincent And The Grenadines
    <option value="184">Samoa
    <option value="185">San Marino
    <option value="186">Sao Tome and Principe
    <option value="187">Saudi Arabia
    <option value="188">Senegal
    <option value="189">Seychelles
    <option value="190">Sierra Leone
    <option value="191">Singapore
    <option value="192">Slovakia
    <option value="193">Slovenia
    <option value="194">Solomon Islands
    <option value="195">Somalia
    <option value="196">South Africa
    <option value="197">South Georgia And The South Sandwich Islands
    <option value="198">Spain
    <option value="199">Sri Lanka
    <option value="200">Sudan
    <option value="201">Suriname
    <option value="202">Svalbard And Jan Mayen Islands
    <option value="203">Swaziland
    <option value="204">Sweden
    <option value="205">Switzerland
    <option value="206">Syria
    <option value="207">Taiwan
    <option value="208">Tajikistan
    <option value="209">Tanzania
    <option value="210">Thailand
    <option value="211">Togo
    <option value="212">Tokelau
    <option value="213">Tonga
    <option value="214">Trinidad And Tobago
    <option value="215">Tunisia
    <option value="216">Turkey
    <option value="217">Turkmenistan
    <option value="218">Turks And Caicos Islands
    <option value="219">Tuvalu
    <option value="220">Uganda
    <option value="221">Ukraine
    <option value="222">United Arab Emirates
    <option value="223">United Kingdom
    <option value="224">United States Minor Outlying Islands
    <option value="225">Uruguay
    <option value="226">Uzbekistan
    <option value="227">Vanuatu
    <option value="228">Vatican City State (Holy See)
    <option value="229">Venezuela
    <option value="230">Vietnam
    <option value="231">Virgin Islands (British)
    <option value="232">Virgin Islands (US)
    <option value="233">Wallis And Futuna Islands
    <option value="234">Yemen
    <option value="235">Yugoslavia
    <option value="236">Zambia
    <option value="237">Zimbabwe
    </select>            
    <BR>
    <P>Enter any comments for the new document:<BR>
    <TEXTAREA NAME="ments" ROWS=15 COLS=45 WRAP>
    </TEXTAREA>
    <P>Enter the description for the new document:<BR>
    <TEXTAREA NAME="scrip" ROWS=15 COLS=45 WRAP>
    </TEXTAREA>
    <P> Upload Document File <BR>
    </P>
    <P>File to Upload 
    <INPUT TYPE="hidden" name="MAX_FILE_SIZE"
    value="2000000"> 
    <INPUT NAME="userfile" TYPE="file" size=35></P>  
    <P>Please specify whether the file is in HTML or PDF format:
    <INPUT NAME="html" TYPE="checkbox">HTML file
    <INPUT NAME="pdf" TYPE="checkbox">PDF file
    <P><INPUT TYPE=SUBMIT NAME="submit" VALUE="SUBMIT"></P>
    </FORM>
    <?php endif; ?>
    </BODY>
    </HTML>
    Last edited by XGuy; Aug 28, 2001 at 19:43.

  2. #2
    1-800-JMULDER JMulder's Avatar
    Join Date
    May 2001
    Location
    The Netherlands
    Posts
    1,745
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could you tell me which line line 166 is?
    Jeroen Mulder

    w: www.jeroenmulder.com

  3. #3
    SitePoint Zealot
    Join Date
    May 2001
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Line 166

    This is Line 166. Thanks for your help!

    else: // Allow the user to enter a new document

    -XGuy.

  4. #4
    :) delemtri's Avatar
    Join Date
    Jun 2001
    Posts
    579
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try changing
    "if ($submit):" to "if ($submit) {"
    "else:" to "} else {"
    "endif:" to "}".

    That might work better.

  5. #5
    SitePoint Zealot
    Join Date
    May 2001
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: changing if: to if {

    Hi delemtri,

    Will that work? I thought the purpose of if: else: endif; statements were so that you could start and finish conditional statements with breaks of pure HTML in between. I may be wrong though. Made the changes and am uploading it as we speak. I will let you know momentarily!

  6. #6
    SitePoint Zealot
    Join Date
    May 2001
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Interesting...

    Hi delemtri....I actually got the exact same error!? Go figure...now I am really perplexed.

    -XGuy.

  7. #7
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this code in place of the userfile stuff, I changed it a bit:

    PHP Code:
       if ($userfile) { 
          
          if (
    $html) {
            
             if (
    $type=="1") {
                  
    $html="http://www.somewhere.ca/assets/documents/articles/$userfile_name";
                  if (
    copy($userfile,"../documents/articles/$userfile_name"))
                     echo(
    "<B> File successfully uploaded</B>");
                  else
                    echo(
    "<B>Error uploading file. However, document details will still be entered into the database. Please upload file manually to the articles folder.</B>");   
             } else if (
    $type=="2") {
                  
    $html="http://www.somewhere.ca/assets/documents/regulations/$userfile_name";
                  if (
    copy($userfile,"../documents/regulations/$userfile_name"))
                     echo(
    "<B> File successfully uploaded</B>");
                  else
                     echo(
    "<B>Error uploading file. However, document details will still be entered into the database. Please upload file manually to the educational folder.</B>");
                         

             } else if (
    $type=="3") {
                  
    $html="http://www.somewhere.ca/assets/documents/educational/$userfile_name";
                  if (
    copy($userfile,"../documents/educational/$userfile_name"))
                     echo(
    "<B> File successfully uploaded</B>");
                  else
                     echo(
    "<B>Error uploading file. However, document details will still be entered into the database. Please upload file manually to the regulations folder.</B>");
             } 
    // end of types
          
    // end of html if statement

          
    if ($pdf) {
            
             if (
    $type=="1") {
                  
    $pdf="http://www.somewhere.ca/assets/documents/articles/$userfile_name";
                  if (
    copy($userfile,"../documents/articles/$userfile_name"))
                     echo(
    "<B> File successfully uploaded</B>");
                  else
                     echo(
    "<B>Error uploading file. However, document details will still be entered into the database. Please upload file manually to the articles folder.</B>");
             else if (
    $type=="2") {
                  
    $pdf="http://www.somewhere.ca/assets/documents/regulations/$userfile_name";
                  if (
    copy($userfile,"../documents/regulations/$userfile_name"))
                     echo(
    "<B> File successfully uploaded</B>");
                  else
                     echo(
    "<B>Error uploading file. However, document details will still be entered into the database. Please upload file manually to the educational folder.</B>");

             } else if (
    $type=="3") {
                  
    $pdf="http://www.somewhere.ca/assets/documents/educational/$userfile_name";
                  if (
    copy($userfile,"../documents/educational/$userfile_name"))
                     echo(
    "<B> File successfully uploaded</B>");
                  else
                     echo(
    "<B>Error uploading file. However, document details will still be entered into the database. Please upload file manually to the regulations folder.</B>");
             } 
    // end of types
          
    // end of pdf if statement
     
       
    // end of userfile if statement 
    ck :: bringing chris to the masses.

  8. #8
    Hi there! Owen's Avatar
    Join Date
    Jan 2000
    Location
    CA
    Posts
    1,165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    According to php.net mixing else { and else: is a very bad idea. They both work identically (ie you can put non-php code between them in the same way.) I don't know if this is your problem, but for future reference...

    Owen


Bookmarks

Posting Permissions

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