By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,665 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

Is something wrong with my query?

P: 8
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).
Expand|Select|Wrap|Line Numbers
  1.     if (empty($errors)) {     
  2.         $query1 = "UPDATE owner SET
  3.                 name = '{$name}'
  4.             WHERE ownerId= '{$ownerId}'";
  5.         $query1_result = mysql_query($query1);
  6.         if (mysql_affected_rows()==1) { 
  7.             $query3 = "UPDATE queue_acl SET
  8.                         date_expires = '{$date_expires}' 
  9.                     WHERE user_id='{$ownerId}'";
  10.             $query3_result = mysql_query($query3);
  11.             if (mysql_affected_rows()==1) {
  12.                 $query2 = "UPDATE ownerOrganization SET
  13.                         orgId = {$orgId}
  14.                     WHERE ownerId = '{$ownerId}'";
  15.                 $query2_result = mysql_query($query2);
  16.                 if (mysql_affected_rows()==1) {
  17.                         $_SESSION['name'] = $name;
  18.                         $_SESSION['updates_occurred'] = true;
  19.                 }
  20.             }
  21.         }
  22.  
Sorry if it is trivial; I have never worked with multiple tables before.
Thanks very much for any/all suggestions
-N
Jun 4 '12 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 1,031
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_...functions):
echo "mysqlerror".mysql_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...
Jun 9 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.