Strange: SQL queries not functioning in my class

Discussion in 'PHP' started by Louis11, Aug 17, 2008.

  1. #1
    SOLVED
    I had an obscure delete call that I was using for testing previously. Any inserts where being immediately removed from the database :p
    ---------------

    Well I have been coding a little system for myself, and for the most part it's been pretty straight forward without many problems. Recently, I came across a very strange problem that I cannot seem to resolve. I am hoping that someone else might see it and be able to figure out what is going on.

    Basically, I have a 'modify' portion of my script. The admin (myself) logs in and can click a check box to add/remove this particular item from a category. I've monitored the POST variables and they are being passed when the form submits. I then strip these variables and pass them to an object that inserts (or removes) them from the appropriate table.

    The problem is that they insert/remove queries for the categories is not working inside of the object (which I have called 'modify'). What is strange though, is that in this very same object I have an SQL query that updates some basic default info for the item . . . this query works, but nothing else will work.

    Here is some of my code:
    
    <?
    
    class image
    {
    // Commented out some code
    function modify($tour_id, $name, $default_image, $description, $keywords, $duration, $includes, $bring, $air)
    {
        // update the default tour information (THIS WORKS)
        $sql = "update tours set name='$name', description='$description', includes='$includes', bring='$bring', keywords='$keywords' where id='$tour_id' limit 1";
        $sql = mysql_query($sql) or die(mysql_error());
    
    	// Just testing . . . this doesn't work. In fact, it doesn't appear to do anthing at all
        $sql = mysql_query("select * from category_air");
        while($row = mysql_fetch_assoc($sql))
        {
            print_r($row);
        }
        
        // this also doesn't work. No errors are produced . . . nothing seems to happen
        $sql = mysql_query("insert into category_air values(`image_id`) values ('1')") or die(mysql_error());
    }
    }
    
    
    PHP:
    So to sum up: SQL insert works outside of the object. In the object only the first SQL query appears to run, no subsequent inserts or selects work. Any ideas?
     
    Louis11, Aug 17, 2008 IP