SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast wildekyote's Avatar
    Join Date
    Apr 2003
    Location
    Fredericksburg, VA
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Odd error when deleting from SQL

    Not sure if this is a PHP error or SQL. The code below is set up to delete records from 2 tables where the variable "job_num" is found. This works fine if the job_num variable is just #'s, but in some of these job cases there is a letter first (ex. A00007) When I attempt to delete these records I get the following error:

    Unknown column 'a00007' in 'where clause'

    any ideas?

    PHP Code:
    <?php 
                      
    require_once('Connections/cq.php');  
                      
    mysql_select_db($database_cq$cq);
                      
                      if (isset(
    $HTTP_GET_VARS['job_num'])) {
                              
    $job_num $HTTP_GET_VARS['job_num']; 
                              
    $sql="DELETE FROM jobs WHERE job_num=$job_num";
                            
    $sql1="DELETE FROM files WHERE job_num=$job_num";
                            if (@
    mysql_query($sql)) {
                                echo(
    "<p align=center>Job has been deleted</p>");
                            } else {
                                echo(
    "<p align=center>Error: ".mysql_error()."</p>");
                            }
                            if (@
    mysql_query($sql1)) {
                                echo(
    "<p align=center>Job files have been deleted</p>");
                            } else {
                                echo(
    "<p align=center>Error: ".mysql_error()."</p>");
                            }
                        }
                        

                        
                            
    $query_full_list "SELECT id, job_num, name FROM jobs";
                            
    $full_list mysql_query($query_full_list$cq) or die(mysql_error());
                            
    $row_full_list mysql_fetch_assoc($full_list);
                            
    $totalRows_full_list mysql_num_rows($full_list);
                        
    ?>
                      <table width="350" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#666666">
                      
                        <?php do { ?>
                        <tr> 
                          <td width="128"><p><?php echo $row_full_list['job_num']; ?></p></td>
                          <td width="129"><p><?php echo $row_full_list['name']; ?></p></td>
                          <td width="79"><div align="center"> 
                              <p><a href="delete.php?job_num=<?php echo $row_full_list['job_num']; ?>">Delete</a></p>
                            </div></td>
                        </tr>
                        <?php } while ($row_full_list mysql_fetch_assoc($full_list)); ?>
                      </table>
    You only regret the risks you didn't take.

    Keith Andersen.com

  2. #2
    Resistance is Futile webgodjj's Avatar
    Join Date
    Nov 2002
    Location
    Madison, WI USA
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think it is becaus you need to quote the $job_num. try putting it in single quotes... see what happens.

  3. #3
    SitePoint Enthusiast wildekyote's Avatar
    Join Date
    Apr 2003
    Location
    Fredericksburg, VA
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that did it thanks
    You only regret the risks you didn't take.

    Keith Andersen.com


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
  •