Jump to content

Need help


topflight

Recommended Posts

An UPDATE query that does not have a WHERE clause will match and therefore operate on all rows in your table. You don't even need any php code as you can execute the query directly against your database using your favorite database management tool.

Link to comment
Share on other sites

I actually spotted an error in my update. Missing a parenthesis.

 

UPDATE members SET last_report_n = CONCAT_WS('-', RIGHT(last_pirep, 4), LEFT(last_pirep, 2), RIGHT(LEFT(last_pirep, LOCATE('.', last_pirep, 3), 2)));

Link to comment
Share on other sites

This is my code and nothing isn't happening.

 

$get = mysql_query("SELECT * FROM members");
while($row = mysql_fetch_assoc($get)){

$id = $row['login'];
$od = str_replace('.', '-', strrev($row['last_pirep']));

mysql_query("UPDATE members SET last_report_n = STR_TO_DATE(last_pirep,'%m.%d.%Y')");

}

echo'UPDATED Sucessfully!'

?>

Link to comment
Share on other sites

If you read through what everyone is posting, they are saying you only need to run this ONE query.  You can do that through mysql directly, through phpmyadmin, etc.

 

If you want to it through php, this is ALL you need...

 

mysql_query("UPDATE members SET last_report_n = STR_TO_DATE(last_pirep,'%m.%d.%Y')");

Link to comment
Share on other sites

LOL, topflight, you introduced a typo in the last_report (last_pirep) source field name in the code you posted in Reply #13. That error has carried through to this point in the thread. It is kind of your responsibly to LOOK at the code you post and to look at the code someone else posts in response to make sure it applies to what you are doing. How are we supposed to know that you did not actually have a column by that name or renamed your original column to that name? We only have access to and see the information that you post and have to assume that what you post is accurate, even if it changes during the life of a thread. We are not psychic after all :psychic:

 

If you correct the last query posted so that it has the correct field name, it will work.

 

And frankly, just posting that something does not work is not helpful. If is also your responsibly to investigate why something is not working on your server with your data. At least look at the code (and queries) you are using that are not working and attempt to find why they are not working.

Link to comment
Share on other sites

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.