Jump to content

Recommended Posts

The following mysql query is not returning rows like I expect it to. '$update_field' is a variable,  matching an actual field name in table 'users'. 'user_task[1]' is an integer value. What am I missing here?

$query_update_user = "UPDATE users SET ".$update_field." = 'Y' WHERE user_no = '".$user_task[1]."'";

Link to comment
https://forums.phpfreaks.com/topic/246265-simple-query-not-working/
Share on other sites

is not returning rows like I expect it to

 

Yes, but what is it doing, so that we would know what sort of problem you are having and could help find the cause.

 

P.S. UPDATE queries don't return rows, if you literally meant you expected that query to 'return rows'

There's nothing technically wrong with the query you posted, provided the variables have expected values, the columns you are referencing exist, the user_no exists, and there are not any other problems in your code such as no database connection...

 

A) echo $query_update_user; so that you know exactly what it contains.

 

B) Are you actually executing the query using a mysql_query() statement? (you would not believe how many times people ask why their query is not doing anything but they don't actually have any code to execute the query.)

 

C) Do you have any error checking and error reporting logic to test if the mysql_query executed without any errors and to tell you if/why the query failed? (if you look at any of the similar threads in the forum, i.e. my query is not working..., you will find suggested  code using mysql_error() that test if the query worked or not and displays the mysql_error() output when it does not.)

 

D) Is the code with the query statement and the mysql_query() statement actually being executed? Perhaps it is in a conditional statement that is false or the whole page is not running due to a fatal parse error or a fatal runtime error.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.