471,062 Members | 1,898 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,062 software developers and data experts.

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).
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.         }
Sorry if it is trivial; I have never worked with multiple tables before.
Thanks very much for any/all suggestions
Jun 4 '12 #1
1 1504
1,044 Expert 1GB
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.

Similar topics

4 posts views Thread by Robert | last post: by
1 post views Thread by Holly | last post: by
9 posts views Thread by Randy | last post: by
1 post views Thread by alvarojaviervera | last post: by
10 posts views Thread by Guillermo_Lopez | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.