SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast nixon's Avatar
    Join Date
    May 2003
    Location
    Australia
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy prob with delete link on challenge.php

    Am just a newbie to this but i just can't work out my prob with the challenge.php script provided by kevin. Have made some alterations to suit my table but nothing drastic. When trying to delete entry i get:

    Error deleting job: Unknown column '$techjobid' in 'where clause'

    have got everything else to work. here is script I have altered. Problem seems to be in the last section. Any help would be great!!! $techjobid is substituted for $jokeid. Registered_Globals are on:

    <html>
    <head>
    <title>Test Form Page</title>
    </head>

    <body bgcolor="#234580" text="#ffffff">
    <?php
    if (isset($_GET['addjob'])): // If the user wants to add a job
    ?>

    <form action="<?=$_SERVER['PHP_SELF']?>" method="post">

    <font face="Arial">

    <font size="5" color="yellow"><p align="center"><b><u>ICT Faults and Information Form</u></b></p></font><br/ >


    <hr>
    <b>Person Submitting Job/b>
    <p><SELECT NAME="name"></p>
    <OPTION>-------SELECT--------
    <OPTION>Glen Nixon
    <OPTION>Brett Hull
    <OPTION>Jo Tanzer
    <OPTION>Kylie Dibnah
    <OPTION>Michelle Robinson
    <OPTION>Margaret Hetherington
    </SELECT>


    <hr>
    <p><b>Choose the item you are experiencing difficulties with/b></p>
    <p><input type="radio" name="item" value="computer"><font color="#ffff00">Computer</p>
    <p><input type="radio" name="item" value="printer">Printer</p>
    <p><input type="radio" name="item" value="cabling">Cabling</p>
    <p><input type="radio" name="item" value="software">Software</p></font>


    <hr>
    <p><b><font color="#ffffff">Describe the problem or ask a question below/font></b></p>
    <p><TEXTAREA NAME="comments" COLS=50 ROWS=6 WRAP=PHYSICAL>
    </TEXTAREA></p><br/ >
    </font>
    <input type="submit" name="submitjob" value="SUBMIT">


    </form>

    <?php
    else: //Default Page Display

    //Connect to database server
    $dbjob = @mysql_connect('glen', 'root', '');
    if (!$dbjob) {
    die( '<p>Unable to connect to the database server at this time.</p>' );
    }

    //Select the jobs database
    if (! @mysql_select_db('joblog') ) {
    die( '<p>Unable to locate the job database at this time.</p>' );
    }

    //If job has been submitted,
    //add it to the database.
    if (isset($_POST['submitjob'])) {
    $name = $_POST['name'];
    $item = $_POST['item'];
    $comments = $_POST['comments'];
    $sql = "INSERT INTO techjob SET
    name='$name',
    item='$item',
    comments='$comments',
    jobsubmit=CURDATE()";
    if (@mysql_query($sql)) {
    echo('<p>Thank you for your submission</p>');
    } else {
    echo('<p>Error adding job: ' .
    mysql_error() . '</p>');
    }
    }

    //If job has been deleted,
    //delete it from the database.
    if (isset($_GET['deletejob'])) {
    $techjobid = $_GET['deletejob'];
    $sql = 'DELETE FROM techjob WHERE ID=$techjobid';
    if (@mysql_query($sql)) {
    echo('<p>The job has been deleted.</p>');
    } else {
    echo('<p>Error deleting job: ' .
    mysql_error() . '</p>');
    }
    }

    echo('<p align="center"><font size="6" color="yellow">Current Jobs List</font></p>');

    // When clicked, this link will load this page
    // with the job submission form displayed.
    echo('<p align="center"><a href="' . $_SERVER['PHP_SELF'] .
    '?addjob=1">Add a Job!</a></p>');

    //Request the ID and text of all the jobs
    $result = @mysql_query('SELECT ID, name, jobsubmit, comments FROM techjob');
    if (!$result) {
    die('<p>Error performing query: ' .
    mysql_error() . '</p>');
    }

    //Display the text of each joke in a paragraph
    //with a 'delete job' link next to each.
    while ( $row = mysql_fetch_array($result) ) {
    $techjobid = $row['ID'];
    $comments = $row['comments'];
    $name = $row['name'];
    $jobsubmit = $row['jobsubmit'];
    echo('<p>' . $techjobid . $jobsubmit . $name . $comments .
    '<a href="' . $_SERVER['PHP_SELF'] .
    '?deletejob=' . $techjobid . '">' .
    'Delete</a></p>');
    }

    endif;

    ?>
    </body>
    </html>

  2. #2
    Can we go to a 48 hour day?
    Join Date
    May 2002
    Location
    MI
    Posts
    906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you want to put a variable in a string (as in your delete query) you need to use " instead of the single.

    Double means php will check it for variables...single quote strings are not processed for them.
    mitechie.com
    "Techies just think a little differently
    ...at least that is what they keep telling me."

  3. #3
    SitePoint Enthusiast nixon's Avatar
    Join Date
    May 2003
    Location
    Australia
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks deuce, that helped a lot.
    Cheers


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
  •