Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: admin panel help - editing data

  1. #1
    Join Date
    Mar 2007
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default admin panel help - editing data

    I'm still new to this whole PHP thing and Ive essentially created a form where if you type in the date listed in the database, it will display the events information and give you the option to edit.

    Below is the code that I have constructed for the page that displays the information based on examples and tutorials.

    I get an error message on the 18th line which talks about "$current_???_html .= "$current_???_html" I just put the ?? there because I figured this code is needed but Im not sure what it means or what it is suppose to be coded as. Can anyone explain this and help me get my code working. Thanks in advance!

    PHP Code:
    <?php
        
        
    include 'session.inc.php';
        include 
    'config.inc.php';
        include 
    'db.inc.php';
        
        
    $link db_connect();

        if (
    $_POST != '')
            
    $id $_POST['hid'];
        else
            
    $id $_GET['id'];

        
    $query "SELECT ('$date','$venue','$location','$information') FROM showdates;
        
    $result = db_query($query$link);

        if (mysql_num_rows(
    $result)) {
            
    $current_horses_html = "<table cellpadding=1 cellspacing=2 width=99&#37; border=0><tr align='center' bgcolor='#cccccc'><td><B>Date</B></td><td><B>Venue</B></td><td><B>Location</B></td><td><B>Information/B></td><td colspan='2'><B>Action</B></td></tr>";
            
    while (list($id$date$venue$location$information) = mysql_fetch_array($result)) {
                
    $current_showdates_html .= "<tr bgcolor=#FFFFFF align=center><td>$date</td><td>$venue</td><td>$location</td><td>$information</td><td><a href='edit.php?id=$id'>Edit</a></td></tr>";
            }
            
    $current_???_html .= "<tr><td></td><td></td></tr></table>";
        } else {
            
    $current_???_html '<p>Show does not exist. Please try again.</p>';
        }
        
        if (isset(
    $_GET['err_msg'])) {
            
    $err_msg $_GET['err_msg'];
            if (!empty(
    $err_msg)) {
                echo 
    "<p><b>Error</b>:<br>$err_msg</p>";
            }
        }

    ?>
    <html>
    <head>
    <title></title>
    <link href=../admin/rustedshows.css rel=stylesheet type="text/css">
    </head>
    <body>
    <center><img src="images/banner.jpg" border=0></center>
    <br>
            <table border=0 width=55% bgcolor="#BEC9D4" cellpadding=0 cellspacing=0 align=center style="border:1px solid #000;">
    <tr>
    <td style="padding:12px;"><h3>Update Show Details</h3></UL>
    <form action="../admin/edit.php" method="post" name="Update Show Details" id="Update Show Details">
    <?=$current_???_html?>
    </form>
    <p><br>
    <a href="../admin/?logout">Logout</a>&nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;<a href="update.php">Update Another Show</a>&nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;<a href="admin.php">Back to Main Page</a></td>
    </tr>
    </table>
            <center>
                Design © Llora McGrath 2007</center>
        </body>
    </html>
    Last edited by llorax; 04-03-2007 at 09:08 PM.

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Well, I see a couple of things that is wrong with the code (and anyone of these could cause the error message.

    Code:
    <?php
        
        include 'session.inc.php';
        include 'config.inc.php';
        include 'db.inc.php';
        
        $link = db_connect();
    
        if ($_POST != '')
            $id = $_POST['hid'];
        else
            $id = $_GET['id'];
    
        $query = "SELECT ('date','venue','location','information') FROM showdates";
        $result = db_query($query, $link);
    
        if (mysql_num_rows($result)) {
            $current_horses_html = "<table cellpadding=1 cellspacing=2 width=99 border=0><tr align='center' bgcolor='#cccccc'><td><B>Date</B></td><td><B>Venue</B></td><td><B>Location</B></td><td><B>Information/B></td><td colspan='2'><B>Action</B></td></tr>";
            while (list($id, $date, $venue, $location, $information) = mysql_fetch_array($result)) {
                $current_horses_html .= "<tr bgcolor=#FFFFFF align=center><td>$date</td><td>$venue</td><td>$location</td><td>$information</td><td><a href='edit.php?id=$id'>Edit</a></td></tr>";
            }
            $current_horses_html .= "<tr><td></td><td></td></tr></table>";
        } else {
            $current_horses_html = '<p>Show does not exist. Please try again.</p>';
        }
        
        if (isset($_GET['err_msg'])) {
            $err_msg = $_GET['err_msg'];
            if (!empty($err_msg)) {
                echo "<p><b>Error</b>:<br>$err_msg</p>";
            }
        }
    
    ?>
    <html>
    <head>
    <title></title>
    <link href=../admin/rustedshows.css rel=stylesheet type="text/css">
    </head>
    <body>
    <center><img src="images/banner.jpg" border=0></center>
    <br>
            <table border=0 width=55&#37; bgcolor="#BEC9D4" cellpadding=0 cellspacing=0 align=center style="border:1px solid #000;">
    <tr>
    <td style="padding:12px;"><h3>Update Show Details</h3></UL>
    <form action="../admin/edit.php" method="post" name="Update Show Details" id="Update Show Details">
    <?=$current_horses_html?>
    </form>
    <p><br>
    <a href="../admin/?logout">Logout</a>&nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;<a href="update.php">Update Another Show</a>&nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;<a href="admin.php">Back to Main Page</a></td>
    </tr>
    </table>
            <center>
                Design &#169; Llora McGrath 2007</center>
        </body>
    </html>
    Anyways, that is your code that has been editted, and it should work (according to the syntax).

    Hope this helps.
    Last edited by thetestingsite; 04-04-2007 at 02:56 AM.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Mar 2007
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    but why should it say horses? What is that referring to?

  4. #4
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    This variable:

    Code:
    $current_horses_html
    could be whatever you want it to be (as long as you keep it the same throughout your script). In other words, you could name it anything and it will still work (as long as you replace all occurrences of the old variable in the script).

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  5. #5
    Join Date
    Mar 2007
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    now im getting this error:
    Could not send query: Operand should contain 1 column(s)

  6. #6
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Sorry, completely overlooked this part:

    Code:
    $query = "SELECT ('$date','$venue','$location','$information') FROM showdates";
    Remove the parts in red (I also editted the code I editted for you originally).
    Hope this helps
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  7. #7
    Join Date
    Mar 2007
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I believe I edited everything you suggested and I'm still getting the same error message.

    PHP Code:
    <?php
        
        
    include 'session.inc.php';
        include 
    'config.inc.php';
        include 
    'db.inc.php';
        
        
    $link db_connect();

        if (
    $_POST != '')
            
    $id $_POST['hid'];
        else
            
    $id $_GET['id'];

        
    $query "SELECT ('date','venue','location','information') FROM showdates";
        
    $result db_query($query$link);

        if (
    mysql_num_rows($result)) {
            
    $current_shows_html "<table cellpadding=1 cellspacing=2 width=99 border=0><tr align='center' bgcolor='#cccccc'><td><B>Date</B></td><td><B>Venue</B></td><td><B>Location</B></td><td><B>Information/B></td><td colspan='2'><B>Action</B></td></tr>";
            while (list(
    $id$date$venue$location$information) = mysql_fetch_array($result)) {
                
    $current_shows_html .= "<tr bgcolor=#FFFFFF align=center><td>$date</td><td>$venue</td><td>$location</td><td>$information</td><td><a href='edit.php?id=$id'>Edit</a></td></tr>";
            }
            
    $current_shows_html .= "<tr><td></td><td></td></tr></table>";
        } else {
            
    $current_shows_html '<p>Show does not exist. Please try again.</p>';
        }
        
        if (isset(
    $_GET['err_msg'])) {
            
    $err_msg $_GET['err_msg'];
            if (!empty(
    $err_msg)) {
                echo 
    "<p><b>Error</b>:<br>$err_msg</p>";
            }
        }

    ?>
    <html>
    <head>
    <title></title>
    <link href=../admin/rustedshows.css rel=stylesheet type="text/css">
    </head>
    <body>
    <center><img src="images/textbanner.gif" border=0></center>
    <br>
            <table border=0 width=55% bgcolor="#BEC9D4" cellpadding=0 cellspacing=0 align=center style="border:1px solid #000;">
    <tr>
    <td style="padding:12px;"><h3>Update Show Details</h3></UL>
    <form action="../admin/edit.php" method="post" name="Update Show Details" id="Update Show Details">
    <?=$current_shows_html?>
    </form>
    <p><br>
    <a href="../admin/?logout">Logout</a>&nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;<a href="update.php">Update Another Show</a>&nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;<a href="admin.php">Back to Main Page</a></td>
    </tr>
    </table>
            <center>
                Design © Llora McGrath 2007</center>
        </body>
    </html>

  8. #8
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Question, do you have a function in any of these files:

    session.inc.php,
    config.inc.php,
    db.inc.php

    that has a function named "db_query()"?

    If not, then you may want to try changing this line:
    Code:
    $result = db_query($query, $link);
    to this:
    Code:
    $result = mysql_query($query, $link);
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  9. #9
    Join Date
    Mar 2007
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    my db inc file does include that function:

    PHP Code:
    <?php

    function db_connect() {
        global 
    $cfg;
        
    $link mysql_connect($cfg['db_server'], $cfg['db_user'], $cfg['db_pass']) or die("Could not connect: " mysql_error());
        
    mysql_select_db($cfg['db_name']) or die("Could not select database: " mysql_error());
        return 
    $link;
    }

    function 
    db_query($query$link) {
        
    $result mysql_query($query$link) or die("Could not send query: " mysql_error());
        return 
    $result;
    }

    function 
    db_close($result$link) {
        
    /* Free resultset */
        
    if (isset($result)) {
            
    mysql_free_result($result);
        }

        
    /* Closing connection */
        
    mysql_close($link);
    }
    ?>

  10. #10
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Ok, I'm going to try this once again.

    Code:
    <?php
        
        include 'session.inc.php';
        include 'config.inc.php';
        include 'db.inc.php';
        
        $link = db_connect();
    
        if ($_POST != '')
            $id = $_POST['hid'];
        else
            $id = $_GET['id'];
    
        $query = "SELECT (`date`,`venue`,`location`,`information`) FROM showdates";
        $result = db_query($query, $link);
    
        if (mysql_num_rows($result)) {
            $current_shows_html = "<table cellpadding=1 cellspacing=2 width=99 border=0><tr align='center' bgcolor='#cccccc'><td><B>Date</B></td><td><B>Venue</B></td><td><B>Location</B></td><td><B>Information/B></td><td colspan='2'><B>Action</B></td></tr>";
            while (list($id, $date, $venue, $location, $information) = mysql_fetch_array($result)) {
                $current_shows_html .= "<tr bgcolor=#FFFFFF align=center><td>$date</td><td>$venue</td><td>$location</td><td>$information</td><td><a href='edit.php?id=$id'>Edit</a></td></tr>";
            }
            $current_shows_html .= "<tr><td></td><td></td></tr></table>";
        } else {
            $current_shows_html = '<p>Show does not exist. Please try again.</p>';
        }
        
        if (isset($_GET['err_msg'])) {
            $err_msg = $_GET['err_msg'];
            if (!empty($err_msg)) {
                echo "<p><b>Error</b>:<br>$err_msg</p>";
            }
        }
    
    ?>
    <html>
    <head>
    <title></title>
    <link href=../admin/rustedshows.css rel=stylesheet type="text/css">
    </head>
    <body>
    <center><img src="images/banner.jpg" border=0></center>
    <br>
            <table border=0 width=55&#37; bgcolor="#BEC9D4" cellpadding=0 cellspacing=0 align=center style="border:1px solid #000;">
    <tr>
    <td style="padding:12px;"><h3>Update Show Details</h3></UL>
    <form action="../admin/edit.php" method="post" name="Update Show Details" id="Update Show Details">
    <?=$current_shows_html?>
    </form>
    <p><br>
    <a href="../admin/?logout">Logout</a>&nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;<a href="update.php">Update Another Show</a>&nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;<a href="admin.php">Back to Main Page</a></td>
    </tr>
    </table>
            <center>
                Design &#169; Llora McGrath 2007</center>
        </body>
    </html>
    Notice the parts in red in the query. This should do it. Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

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
  •