Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 21

Thread: Issue with code

  1. #1
    Regular Coder
    Join Date
    Jun 2008
    Posts
    682
    Thanks
    114
    Thanked 2 Times in 2 Posts

    Issue with code

    PHP Code:
    <?php
    }
    else
    {
    ?>
    <center><table><tr><td>Title:</td><td>
    <?php
    echo '<select onchange="showTitle(this.value)">';
    $data mysql_query("SELECT titlename FROM titles");
    while(
    $row mysql_fetch_assoc($data)) {
        echo 
    '<option value="'.$row['titlename'].'">'.$row['titlename'].'</option>';
    }
    echo 
    '</select>'
    ?></td></tr></table></center>
    <?php
    $q
    =$_GET["q"];

    $con mysql_connect('?", "?", "?"');
    if (!
    $con)
     {
     die(
    'Could not connect: ' mysql_error());
     }

    mysql_select_db("?"$con);

    $sql="SELECT * FROM titles WHERE id = '".$q."'";

    $result mysql_query($sql);

    echo 
    "<table border='1'>
    <tr>
    <th>Title Name:</th>
    <th>Type:</th>
    <th>Status:</th>
    <th>Champion:</th>
    <th>Contender 1:</th>
    <th>Contender 2:</th>
    <th>Contender 3:</th>
    </tr>"
    ;

    while(
    $row mysql_fetch_array($result))
     {
     echo 
    "<tr>";
     echo 
    "<input type="text" name="titlename" maxlength="60" value=" $row['type'] . ">";
     echo 
    "<select name="type" value=" $row['type'] . ">"
    <option>Singles</option><option>Tag Team</option><option>Stable</option></select>;
     echo 
    "<select name="status" value=" $row['status'] . ">"
    <option>Active</option><option>Inactive</option></select>;

    echo 
    '<select value=" . $row['champion'] . ">';
    $data mysql_query("SELECT wrestlingname FROM singles");
    while(
    $row mysql_fetch_assoc($data)) {
        echo 
    '<option value="'.$row['wrestlingname'].'">'.$row['wrestlingname'].'</option>';
    echo 
    '</select>'

    echo 
    '<select value=" . $row['champion'] . ">';
    $data mysql_query("SELECT wrestlingname FROM singles");
    while(
    $row mysql_fetch_assoc($data)) {
        echo 
    '<option value="'.$row['wrestlingname'].'">'.$row['wrestlingname'].'</option>';
    echo 
    '</select>'

    echo 
    '<select value=" . $row['champion'] . ">';
    $data mysql_query("SELECT wrestlingname FROM singles");
    while(
    $row mysql_fetch_assoc($data)) {
        echo 
    '<option value="'.$row['wrestlingname'].'">'.$row['wrestlingname'].'</option>';
    echo 
    '</select>'
    echo 
    '<select value=" . $row['champion'] . ">';
    $data mysql_query("SELECT wrestlingname FROM singles");
    while(
    $row mysql_fetch_assoc($data)) {
        echo 
    '<option value="'.$row['wrestlingname'].'">'.$row['wrestlingname'].'</option>';
    echo 
    '</select>'

     }
    echo 
    "</table>";

    mysql_close($con);
    ?>

     
    <?php
    }
    ?>

  • #2
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,303
    Thanks
    4
    Thanked 204 Times in 201 Posts
    I'm sorry but my mind reader is broken. What is your "issue with code"?
    Dave .... HostMonster for all of your hosting needs

  • #3
    Regular Coder
    Join Date
    May 2008
    Location
    Ohio
    Posts
    231
    Thanks
    3
    Thanked 21 Times in 21 Posts
    ...and the issues are? We don't read minds. What should it be doing? What is the script doing? Is it printing the wrong data? Is it showing you an error? Is it displaying nothing at all?

    Edit: Looks like Dave beat me to the punch
    zok@zoklet:~$ whereis zok
    zok: http://zoklet.net | http://zoklet.net/otg | /derzok/at/gmail/dot/com

  • #4
    Regular Coder
    Join Date
    Jun 2008
    Posts
    682
    Thanks
    114
    Thanked 2 Times in 2 Posts
    It says Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/content/y/a/n/yankeefaninkc/html/edittitle2.php on line 71

    But I can't find it.

  • #5
    Regular Coder
    Join Date
    May 2008
    Location
    Ohio
    Posts
    231
    Thanks
    3
    Thanked 21 Times in 21 Posts
    It looks fine to me (unless I'm sleepier than I thought this morning)... Are you sure you've uploaded the most recent version of the code and that you aren't running an old one? One thing you might want to do: put your
    PHP Code:
    echo '</select>'
    OUTSIDE your while loop - otherwise you'll display a '</select>' for every value of the drop down.

    That wouldn't cause PHP errors though, that'd just make the html look funny...
    zok@zoklet:~$ whereis zok
    zok: http://zoklet.net | http://zoklet.net/otg | /derzok/at/gmail/dot/com

  • #6
    Regular Coder
    Join Date
    May 2008
    Posts
    187
    Thanks
    7
    Thanked 7 Times in 7 Posts
    look at this:
    Code:
     echo "<input type="text" name="titlename" maxlength="60" value=" . $row['type'] . ">";
     echo "<select name="type" value=" . $row['type'] . ">"
    That's part of the problem, the interpreter reads it as
    echo "<input type=" <--expected simicolon
    text <--where does this come from
    " name=" <--String, what do I do with this?

  • Users who have thanked malfist for this post:

    CoolAsCarlito (08-05-2008)

  • #7
    Regular Coder
    Join Date
    Jun 2008
    Posts
    682
    Thanks
    114
    Thanked 2 Times in 2 Posts
    What should I do with it though?

  • #8
    Regular Coder
    Join Date
    May 2008
    Location
    Ohio
    Posts
    231
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Just noticed some more errors - you never close any of your while loops. They're all like this:

    PHP Code:
    while(something mysql_something) {
        
    // some stuff

    while(something mysql_something) {
       
    // some more stuff 
    Instead of:

    PHP Code:
    while(something mysql_something) {
        
    // some stuff
    }
    while(
    something mysql_something) {
       
    // some more stuff

    You need a closing bracket if you have an opening bracket!

    Quote Originally Posted by CoolAsCarlito View Post
    What should I do with it though?
    Put it in single quotes instead - like you did for the other HTML you outputted. It's traditional to put HTML in single quotes (because you so often have to use double quotes inside of it) and to put text inside of regular quotes (because we often put apostrophes in our text). This prevents needing to escape every quote. If you have your heart set on using double quotes you'll have to add a '\' character in front of every double quote inside of the outermost double quotes - ie: "the man said "Hello"" => "the man said \"Hello\"" - the same rule follows for single quotes: 'The man said 'Boo!'' => 'The man said \'Boo!\'' - this is why we blend quotes the way we do: 'The man said "Hello"' or "the man said 'Boo!'"
    Last edited by derzok; 08-05-2008 at 02:43 PM.
    zok@zoklet:~$ whereis zok
    zok: http://zoklet.net | http://zoklet.net/otg | /derzok/at/gmail/dot/com

  • #9
    Regular Coder
    Join Date
    May 2008
    Posts
    187
    Thanks
    7
    Thanked 7 Times in 7 Posts
    Quote Originally Posted by CoolAsCarlito View Post
    What should I do with it though?
    You should lookup what to do with quotes. Use ' and ", and you can also escape it like \"

    http://ca.php.net/types.string

  • #10
    Regular Coder
    Join Date
    Jun 2008
    Posts
    682
    Thanks
    114
    Thanked 2 Times in 2 Posts
    Okay well I erased a whole bunch of things off the php and tried doing a little bit at a time and try making it work one piece at a time.

    http://www.kansasoutlawwrestling.com/edittitle2.php

    See my problem now?

  • #11
    Regular Coder
    Join Date
    May 2008
    Location
    Ohio
    Posts
    231
    Thanks
    3
    Thanked 21 Times in 21 Posts
    I see the problem but I need to see the code in order to correct it... It looks like you just missed some quotes but I'd have to look to know where.
    zok@zoklet:~$ whereis zok
    zok: http://zoklet.net | http://zoklet.net/otg | /derzok/at/gmail/dot/com

  • #12
    Regular Coder
    Join Date
    Jun 2008
    Posts
    682
    Thanks
    114
    Thanked 2 Times in 2 Posts
    http://kansasoutlawwrestling.com/edittitle2.php

    Code is here:

    PHP Code:
    <html>
    <head>
    <script src="selecttitle.js"></script>
    </head>


    <?php
    // Connects to your Database
    $link mysql_connect("?""?""?") or die(mysql_error());
    mysql_select_db("?",$link) or die(mysql_error());
     
    if (!
    mysql_select_db("?"$link)) {
    echo 
    'Could not select database';
    exit;
    }
    ?>
    <center><table><tr><td>Title:</td><td>
    <?php
    echo '<select onchange="showTitle(this.value)">';
    $data mysql_query("SELECT titlename FROM titles");
    while(
    $row mysql_fetch_assoc($data)) {
        echo 
    '<option value="'.$row['titlename'].'">'.$row['titlename'].'</option>';
    }
    echo 
    '</select>'
    ?></td></tr></table></center>

    <center><table border=1 cellpadding=5 cellspacing=0 width=350>
    <font color="#CC0000"><h2><center>Edit a Title</h2></center></font>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    <tr><td>Title Name:</td><td>
    <input type="text" name="titlename" maxlength="60" value=" . $row['titlename'] . ">
    </td></tr>

    </html>

  • #13
    Regular Coder
    Join Date
    May 2008
    Posts
    187
    Thanks
    7
    Thanked 7 Times in 7 Posts
    this:
    <input type="text" name="titlename" maxlength="60" value=" . $row['FirstName'] . ">
    Is html, you need part of that to be php.

  • #14
    Regular Coder
    Join Date
    Jun 2008
    Posts
    682
    Thanks
    114
    Thanked 2 Times in 2 Posts
    Huh? WHat do you mean?

  • #15
    Regular Coder
    Join Date
    May 2008
    Posts
    187
    Thanks
    7
    Thanked 7 Times in 7 Posts
    What I mean is, there's no PHP there, it's just HTML. HTML sees you want the value to be " . $row['FirstName'] . ", so it makes it " . $row['FirstName'] . ". However something like this might be more appropriate for what you want.
    Code:
    <input type="text" name="titlename" maxlength="60" value="<?php echo $row['FirstName']; ?>">

  • Users who have thanked malfist for this post:

    CoolAsCarlito (08-05-2008)


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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