SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Thread: {} problems

  1. #1
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    {} problems

    I have this file. the error is here
    And here is the file. I can't get it to display it says something about a unexpected { but I have looked and the only 1 I can't account for it on line 70 right after the else statement
    here is my code
    PHP Code:
     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
     <html>
     <head>
     <title>New Life Baptist Church</title>
     </head>
     
     <body>
     <h3><font face="Arial, Helvetica, sans-serif">New Life Baptist Church News Administration</font></h3>
     
     <?php
     
     
    // Display new testimonial form if add link was selected
     
    if (ISSET($_GET['add']))
     {
         
    ?>
     <form action="<? echo $_SERVER['PHP_SELF']?>" method="post">
     <p>Add New Member: </p>
     <p>Title:<input type="text" name="titlefromform" size = "30"/></p>
     <p>Name:<input type="text" name="namefromform" size = "30" /></p>
     <p>Address:<input type="text" name="addressfromform" size= "30" /></p>
     <p>Town:<input type="text" name="townfromform" size="30" /></p>
     <p>State(two letter abbr.):<input type="text" name="statefromform" size="2" /></p>
     <p>Zip Code:<input type="text" name="zipfromform" size="30" /></p>
     <p>Phone:<input type="text" name="phonefromform" size="30" /></p>
     <p>Email:<input type="text" name="emailfromform" size="30" /></p>
     <p><input type="submit" name="submit" value="SUBMIT" /></p>
     </form>
     <?
     
     
    }
         elseif (ISSET(
    $_GET['edit']))
     {
     
     
    connecttodatabase();
     
    selectdatabase();
     
    $IDTOEDIT $_GET['edit'];
     
    $sql "SELECT * FROM addresslist WHERE ID = $IDTOEDIT";
     
    $result = @mysql_query($sql);
     if (!
    result)
     {
         die (
    '<p>Error performing query: ' .
              
    mysql_error() . '</p>');
     }
     
    $salu=mysql_result($result,$i,"salu");
     
    $name=mysql_result($result,$i,"name");
     
    $address=mysql_result($result,$i,"address");
     
    $town=mysql_result($result,$i,"town");
     
    $state=mysql_result($result,$i,"state");
     
    $zip=mysql_result($result,$i,"zip");
     
    $phone=mysql_result($result,$i,"phone");
     
    $email=mysql_result($result,$i,"email");
         
    ?>
     <form action="<? echo $_SERVER['PHP_SELF']?>" method="post">
     <p>Edit Member: </p>
     <p>Title:<input type="text" name="titlefromform" size = "10" value="<? echo "$salu"?>"/></p>
     <p>Name:<input type="text" name="namefromform" size = "30" value="<? echo "$name"?>"/></p>
     <p>Address:<input type="text" name="addressfromform" size= "30" value="<? echo "$address"?>"/></p>
     <p>Town:<input type="text" name="townfromform" size="30" value="<? echo "$town"?>"/></p>
     <p>State(two letter abbr.):<input type="text" name="statefromform" size="2" value="<? echo "$state"?>"/></p>
     <p>Zip Code:<input type="text" name="zipfromform" size="30" value="<? echo "$zip"?>"/></p>
     <p>Phone:<input type="text" name="phonefromform" size="30" value="<? echo "$phone"?>"/></p>
     <p>Email:<input type="text" name="emailfromform" size="30" value="<? echo "$email"?>"/></p>
     <input type=hidden name="id" size="3" value="<? echo "$IDTOEDIT"?>"/>
     <p><input type="submit" name="edit" value="UPDATE" /></p>
     </form>
     <?
     
     
    }
         else
     {
     
     
    connecttodatabase();
     
    selectdatabase();
     
     if (ISSET(
    $_POST['submit']))
     {
         
    $salu $_POST['salufromform'];
         
    $name $_POST['namefromform'];
         
    $address $_POST['addressfromform'];
         
    $town $_POST['townfromform'];
         
    $state $_POST['statefromform'];
         
    $zip $_POST['zipfromform'];
         
    $phone $_POST['phonefromform'];
         
    $email $_POST['emailfromform'];
         
    $sql "INSERT INTO addresslist SET
                     salu = '
    $salu',
                 name = '
    $name',
                 address = '
    $address',
                 town = '
    $town',
                 state = '
    $state',
                 zip = '
    $zip',
                 phone = '
    $phone',
                 email = '
    $email'";
         if (!@
    mysql_query($sql))
         {
             echo (
    '<p>Error adding member: ' mysql_error() . '</p>');
         }
     }
     
     
    // If users want to view a news item, display it
     
    if (ISSET($_GET['view']))
     {
         
    $id $_GET['view'];
         
    $sql "SELECT * FROM addresslist WHERE ID = $id";
         
    $result = @mysql_query($sql);
     
         if (!
    result)
         {
             die (
    '<p>Error performing query: ' .
              
    mysql_error() . '</p>');
         }
         
         while (
    $row mysql_fetch_array($result))
         {
             
    $salu $row['salu'];
             
    $name $row['name'];
             
    $address $row['address'];
             
    $town $row['town'];
             
    $state $row['state'];
             
    $zip $ro['zip'];
             
    $phone $row['phone'];
             
    $email $row['email'];
             echo 
    "<center><b>$salu $name</b><br>$address<br>$town$state $zip<br>$phone<br><br></center>";
             echo (
    '<p><a href = "' $_SERVER['PHP_SELF'] . '">Back to members listing</a></p>');
         }
     }
     
     
    // If a news item has been deleted, remove it from database
     
    if (ISSET($_GET['delete']))
     {
         
    $id $_GET['delete'];
         
    $sql "DELETE FROM addresslist where ID = $id";
         if (@
    mysql_query($sql))
         {
             echo (
    '<p>Member deleted succesfully!</p>');
         }
             else
         {
             echo (
    '<p>Error deleting Member: ' mysql_error() . '</p>');
         }
     }
     
     
    // If a news item has been edited, update the database
     
    if (ISSET($_POST['edit']))
     {
         
    $salu $_POST['salufromform'];
         
    $name $_POST['namefromform'];
         
    $address $_POST['addressfromform'];
         
    $town $_POST['townfromform'];
         
    $state $_POST['statefromform'];
         
    $zip $_POST['zipfromform'];
         
    $phone $_POST['phonefromform'];
         
    $email $_POST['emailfromform'];
         
    $sql "UPDATE addresslist SET
                salu = '
    $salu',
                 name = '
    $name',
                 address = '
    $address',
                 town = '
    $town',
                 state = '
    $state',
                 zip = '
    $zip',
                 phone = '
    $phone',
                 email = '
    $email'
                        WHERE ID = '
    $id'";
         if (@
    mysql_query($sql))
         {
             echo (
    '<p>Member info updated succesfully!</p>');
         }
             else
         {
             echo (
    '<p>Error updating Member info: ' mysql_error() . '</p>');
         }
     }
     
     
    // Retrieve records from the newsitems table
     
     
     
     // Display the news items from previous query
     
    $query mysql_query("SELECT ID, name FROM addresslist");
     echo (
    '<form action="' $_SERVER['PHP_SELF'] . '"method=get>
     <select name=view>'
    );
     while (
    $r mysql_fetch_array($query))
     {
     
    $name $r["name"];
     
    $id $r["ID"];
     
    //echo "<option value=$name>$name</option>";
     
    echo '<option value="' $id '">' $name '</option>';
     }
     echo 
    "</select>";
     echo (
    '<input type="submit" /></form>');
     
     
     
    // Display link to add news item to database
     
    echo ('<p><a href = "' $_SERVER['PHP_SELF'] .
           
    '?add=1">Add a Member</a></p>');
     }
     
    // Connect to the news database
     
    function connecttodatabase()
     {
     
    $db = @mysql_connect('localhost''nlbc_nlbc''risen');
     if (!
    $db)
         {
             die (
    '<p>Unable to connect to the ' .
              
    'news database at this time.</p>');
         }
     }
     
     
    // Select the testimonials database
     
    function selectdatabase() {
     if (! @
    mysql_select_db('nlbc_addresslist') )
         {
             die (
    '<p>Unable to locate the news ' .
              
    'database at this time.</p>');
         }
     }
     
     
    ?>
     </body>
     </html>

  2. #2
    SitePoint Member Junelle's Avatar
    Join Date
    Jan 2006
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    good for you .. you know how to code PHP .. i need help step by step with IT
    Check our weblogs. Information for YOU to Read!
    Open Source Business
    Renewable Energy Generation
    Business Communication

  3. #3
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is a tough one to learn. but I barely know it as you can see by the error.

  4. #4
    SitePoint Member Junelle's Avatar
    Join Date
    Jan 2006
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    could we have a chat?
    Check our weblogs. Information for YOU to Read!
    Open Source Business
    Renewable Energy Generation
    Business Communication

  5. #5
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    never mind I fixed it.

  6. #6
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well I never fixed I was looking at the wrong page. If any one can help me I would desperatly appreciate it. here is my code. Also here you can see the error.
    PHP Code:
     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
     <html>
     <head>
     <title>New Life Baptist Church</title>
     </head>
     
     <body>
     <h3><font face="Arial, Helvetica, sans-serif">New Life Baptist Church News Administration</font></h3>
     
     <?php
     connecttodatabase
    ();
     
    selectdatabase();
     
    // Display new testimonial form if add link was selected
     
    if (ISSET($_GET['add']))
     {
         
    ?>
     <form action="<? echo $_SERVER['PHP_SELF']?>" method="post">
     <p>Add New Member: </p>
     <p>Title:<input type="text" name="titlefromform" size = "30"/></p>
     <p>Name:<input type="text" name="namefromform" size = "30" /></p>
     <p>Address:<input type="text" name="addressfromform" size= "30" /></p>
     <p>Town:<input type="text" name="townfromform" size="30" /></p>
     <p>State(two letter abbr.):<input type="text" name="statefromform" size="2" /></p>
     <p>Zip Code:<input type="text" name="zipfromform" size="30" /></p>
     <p>Phone:<input type="text" name="phonefromform" size="30" /></p>
     <p>Email:<input type="text" name="emailfromform" size="30" /></p>
     <p><input type="submit" name="submit" value="SUBMIT" /></p>
     </form>
     <?
     
    }
         elseif (ISSET(
    $_GET['edit']))
     {
     
    $IDTOEDIT $_GET['edit'];
     
    $sql "SELECT * FROM addresslist WHERE ID = $IDTOEDIT";
     
    $result = @mysql_query($sql);
     if (!
    result)
     {
         die (
    '<p>Error performing query: ' .
              
    mysql_error() . '</p>');
     }
     
    $row mysql_fetch_array($result)
         
    $salu1 $row['salu'];
         
    $name1 $row['name'];
         
    $address1 $row['address'];
         
    $town1 $row['town'];
         
    $state1 $row['state'];
         
    $zip1 $row['zip'];
         
    $phone1 $row['phone'];
         
    $email1 $row['email'];
             
         
    ?>
     <form action="<? echo $_SERVER['PHP_SELF']?>" method="post">
     <p>Edit Member: </p>
     <p>Title:<input type="text" name="titlefromform" size = "10" value="<? echo "$salu1"?>"/></p>
     <p>Name:<input type="text" name="namefromform" size = "30" value="<? echo "$name1"?>"/></p>
     <p>Address:<input type="text" name="addressfromform" size= "30" value="<? echo "$address1"?>"/></p>
     <p>Town:<input type="text" name="townfromform" size="30" value="<? echo "$town1"?>"/></p>
     <p>State(two letter abbr.):<input type="text" name="statefromform" size="2" value="<? echo "$state1"?>"/></p>
     <p>Zip Code:<input type="text" name="zipfromform" size="30" value="<? echo "$zip1"?>"/></p>
     <p>Phone:<input type="text" name="phonefromform" size="30" value="<? echo "$phone1"?>"/></p>
     <p>Email:<input type="text" name="emailfromform" size="30" value="<? echo "$email1"?>"/></p>
     <input type=hidden name="id" size="3" value="<? echo "$IDTOEDIT"?>"/>
     <p><input type="submit" name="edit" value="UPDATE" /></p>
     </form>
     <?
     
    }
     
         else
     {
     
    connecttodatabase();
     
    selectdatabase();
     if (ISSET(
    $_POST['submit']))
     {
         
    $salu $_POST['salufromform'];
         
    $name $_POST['namefromform'];
         
    $address $_POST['addressfromform'];
         
    $town $_POST['townfromform'];
         
    $state $_POST['statefromform'];
         
    $zip $_POST['zipfromform'];
         
    $phone $_POST['phonefromform'];
         
    $email $_POST['emailfromform'];
         
    $sql "INSERT INTO addresslist SET
                     salu = '
    $salu',
                 name = '
    $name',
                 address = '
    $address',
                 town = '
    $town',
                 state = '
    $state',
                 zip = '
    $zip',
                 phone = '
    $phone',
                 email = '
    $email'";
         if (!@
    mysql_query($sql))
         {
             echo (
    '<p>Error adding member: ' mysql_error() . '</p>');
         }
     }
     
     
    // If users want to view a news item, display it
     
    if (ISSET($_GET['view']))
     {
     
         
    $id $_GET['view'];
         
    $sql "SELECT * FROM addresslist WHERE ID = $id";
         
    $result = @mysql_query($sql);
     
         if (!
    result)
         {
             die (
    '<p>Error performing query: ' .
              
    mysql_error() . '</p>');
         }
         
         while (
    $row mysql_fetch_array($result))
         {
             
    $salu $row['salu'];
             
    $name $row['name'];
             
    $address $row['address'];
             
    $town $row['town'];
             
    $state $row['state'];
             
    $zip $ro['zip'];
             
    $phone $row['phone'];
             
    $email $row['email'];
             echo 
    "<center><b>$salu $name</b><br>$address<br>$town$state $zip<br>$phone<br><br></center>";
             echo (
    '<p><a href = "' $_SERVER['PHP_SELF'] . '">Back to members listing</a></p>
             <a href = "' 
    $_SERVER['PHP_SELF'] .
               
    '?view=' $newsID '">View</a> | ''<a href = "' $_SERVER['PHP_SELF'] .
               
    '?edit=' $newsID '">Edit</a> | ''<a href = "' $_SERVER['PHP_SELF'] .
               
    '?delete=' $newsID '">Delete</a>');
         }
     }
     
     
    // If a news item has been deleted, remove it from database
     
    if (ISSET($_GET['delete']))
     {
     
         
    $id $_GET['delete'];
         
    $sql "DELETE FROM addresslist where ID = $id";
         if (@
    mysql_query($sql))
         {
             echo (
    '<p>Member deleted succesfully!</p>');
         }
             else
         {
             echo (
    '<p>Error deleting Member: ' mysql_error() . '</p>');
         }
     }
     
     
    // If a news item has been edited, update the database
     
    if (ISSET($_POST['edit']))
     {
     
         
    $salu $_POST['salufromform'];
         
    $name $_POST['namefromform'];
         
    $address $_POST['addressfromform'];
         
    $town $_POST['townfromform'];
         
    $state $_POST['statefromform'];
         
    $zip $_POST['zipfromform'];
         
    $phone $_POST['phonefromform'];
         
    $email $_POST['emailfromform'];
         
    $sql "UPDATE addresslist SET
                salu = '
    $salu',
                 name = '
    $name',
                 address = '
    $address',
                 town = '
    $town',
                 state = '
    $state',
                 zip = '
    $zip',
                 phone = '
    $phone',
                 email = '
    $email'
                        WHERE ID = '
    $id'";
         if (@
    mysql_query($sql))
         {
             echo (
    '<p>Member info updated succesfully!</p>');
         }
             else
         {
             echo (
    '<p>Error updating Member info: ' mysql_error() . '</p>');
         }
     }
     
     
    // Retrieve records from the newsitems table
     
     // Display the news items from previous query
     
    $query mysql_query("SELECT ID, name FROM addresslist");
     echo (
    '<form action="' $_SERVER['PHP_SELF'] . '"method=get>
     <select name=view>'
    );
     while (
    $r mysql_fetch_array($query))
     {
     
    $name $r["name"];
     
    $id $r["ID"];
     
    //echo "<option value=$name>$name</option>";
     
    echo '<option value="' $id '">' $name '</option>';
     }
     echo 
    "</select>";
     echo (
    '<input type="submit" /></form>');
     
     
     
    // Display link to add news item to database
     
    echo ('<p><a href = "' $_SERVER['PHP_SELF'] .
           
    '?add=1">Add a Member</a></p>');
     }
     function 
    connecttodatabase()
     {
     
    $db = @mysql_connect('localhost''nlbc_nlbc''risen');
     if (!
    $db)
         {
             die (
    '<p>Unable to connect to the ' .
              
    'news database at this time.</p>');
         }
     }
     
     
    // Select the testimonials database
     
    function selectdatabase() {
     if (! @
    mysql_select_db('nlbc_addresslist') )
         {
             die (
    '<p>Unable to locate the news ' .
              
    'database at this time.</p>');
         }
     }
     
     
     
    ?>
     </body>
     </html>

  7. #7
    SitePoint Addict SirAdrian's Avatar
    Join Date
    Jul 2005
    Location
    Kelowna, BC
    Posts
    289
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Line 41:
    $row = mysql_fetch_array($result)

    You missed the semicolon.
    Adrian Schneider - Web Developer

  8. #8
    SitePoint Member Junelle's Avatar
    Join Date
    Jan 2006
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wow... thats a real helper :-)
    Check our weblogs. Information for YOU to Read!
    Open Source Business
    Renewable Energy Generation
    Business Communication

  9. #9
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks alot. Thats the problem with looking at it with your eyes. Thats why it helps to have someeleses.

  10. #10
    SitePoint Member Junelle's Avatar
    Join Date
    Jan 2006
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    :-) i hope someone could help me with my puzzle problem!
    Check our weblogs. Information for YOU to Read!
    Open Source Business
    Renewable Energy Generation
    Business Communication


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
  •