Is something wrong with my query?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • newbie93
    New Member
    • May 2012
    • 8

    Is something wrong with my query?

    Hey guys. I'm working on a database with 3 tables, some with overlapping information. A few columns from each table can be updated by the user via the web app that I am creating. But... There is an issue. Not sure what it is, but my updates aren't happening. I am wondering if something is wrong with my query. (Actually, after debugging, I am quite certain there is).
    Code:
    	if (empty($errors)) { 	
    		$query1 = "UPDATE owner SET
    				name = '{$name}'
    			WHERE ownerId= '{$ownerId}'";
    		$query1_result = mysql_query($query1);
    		if (mysql_affected_rows()==1) { 
    			$query3 = "UPDATE queue_acl SET
    						date_expires = '{$date_expires}' 
    					WHERE user_id='{$ownerId}'";
    			$query3_result = mysql_query($query3);
    			if (mysql_affected_rows()==1) {
    				$query2 = "UPDATE ownerOrganization SET
    						orgId = {$orgId}
    					WHERE ownerId = '{$ownerId}'";
    				$query2_result = mysql_query($query2);
    				if (mysql_affected_rows()==1) {
    						$_SESSION['name'] = $name;
    						$_SESSION['updates_occurred'] = true;
    				}
    			}
    		}
    Sorry if it is trivial; I have never worked with multiple tables before.
    Thanks very much for any/all suggestions
    -N
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    I dont think the error is in your query
    I think its in your PHP-code

    Are you certain that the code at line 5 is executed?
    What errors did you see when debugging?

    You could also try to add this after line5 (and other mysql_...functi ons):
    echo "mysqlerror".my sql_error();

    The error given should give a god guide on how to fix the query. I nothing is return, than probably th queries are not executed...

    Comment

    Working...