Author |
Message |
myrtletrees
Involved
![Involved Involved](modules/Forums/images/ranks/4stars.gif)
![](modules/Forums/images/avatars/44fbb573445a9d36e3110.jpg)
Joined: Sep 13, 2005
Posts: 259
Location: Cornfields of Indiana
|
Posted:
Tue Mar 29, 2011 12:29 pm |
|
What would be the MySQL command to update the nuke_users table field user_allow_viewonline and change the value for all users from 0 to 1?
Better yet, can someone provide the command so that it can be executed from a PHP script?
If not, then I can probably figure out how to add the script to a php file myself. As long as I have the actual command. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
myrtletrees
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Mar 29, 2011 12:48 pm |
|
Well, I've played around a little more, I guess I need someone to verify this for me.
Will this accomplish what I asked in my previous question?
Code: global $prefix, $db, $user_prefix, $dbErrors;
$sql = 'UPDATE '.$prefix.'_users SET user_allow_viewonline='1'';
sqlexec($sql);
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
Site Admin/Owner
![](modules/Forums/images/avatars/45030c033f18773153cd2.gif)
Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Tue Mar 29, 2011 2:22 pm |
|
That should work . |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
myrtletrees
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Mar 29, 2011 3:17 pm |
|
Thanks, it didn't seem to work as a PHP script.
If I run this command in PHPmyadmin manually, it works fine:
UPDATE nuke_users SET user_allow_viewonline=1
My entire PHP script looks like this and I have it in the root directory where config.php is located.
Code:<?php
define('INCLUDE_PATH', './');
require_once INCLUDE_PATH . 'config.php';
global $prefix, $db, $user_prefix, $dbErrors;
$sql = 'UPDATE '.$prefix.'_users SET user_allow_viewonline='1'';
sqlexec($sql);
?>
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Mar 29, 2011 3:45 pm |
|
CHANGE:
$sql = 'UPDATE '.$prefix.'_users SET user_allow_viewonline='1'';
TO:
$sql = 'UPDATE '.$prefix.'_users SET user_allow_viewonline=1'; |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
wHiTeHaT
Life Cycles Becoming CPU Cycles
![](modules/Forums/images/avatars/gallery/blank.gif)
Joined: Jul 18, 2004
Posts: 579
|
Posted:
Tue Mar 29, 2011 3:52 pm |
|
notice '1' and 1
if '1' means it can be replaced with any number.
if 1 it means 1
is my notition of your code correct Raven? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Palbin
Site Admin
![](modules/Forums/images/avatars/Dilbert/Dilbert_-_Dogbert_King.gif)
Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania
|
Posted:
Tue Mar 29, 2011 4:03 pm |
|
Code:
<?php
global $db, $prefix;
require 'mainfile.php';
$db->sql_query('UPDATE `' . $prefix . '_users` SET `user_allow_viewonline`="1"');
?>
|
|
_________________ "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan. |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Mar 29, 2011 8:59 pm |
|
wHiTeHaT wrote: | notice '1' and 1
if '1' means it can be replaced with any number.
if 1 it means 1
is my notition of your code correct Raven? |
'1' and 1 will both resolve as 1. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
duck
Involved
![Involved Involved](modules/Forums/images/ranks/4stars.gif)
![](modules/Forums/images/avatars/gallery/blank.gif)
Joined: Jul 03, 2006
Posts: 273
|
Posted:
Tue Mar 29, 2011 10:27 pm |
|
Palbin is most correct with reqiring mainfile instead of config but one last thing should be user_prefix instead of prefix in case they do not match. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Mar 29, 2011 11:08 pm |
|
I was only addressing the SQL syntax as the original request only said a PHP script. I took that to mean not [necessarily] in the CMS context. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Palbin
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Wed Mar 30, 2011 5:23 am |
|
duck wrote: | Palbin is most correct with reqiring mainfile instead of config but one last thing should be user_prefix instead of prefix in case they do not match. |
Good catch. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
|