Reputation: 1
I want to count my users and then send a command to update a different table to change their displayed "Level" on their profile. Here's what I got....
<?php
$query = mysql_query("SELECT COUNT(*) FROM 'ow_base_user'.'id' WHERE 'id'") or die (mysql_error());
$row = mysql_fetch_row($query);
$count = $row[0];
$username = [userid];
$count = "";
$lvl = UPDATE `founda_Inspire`.`ow_base_authorization_role` SET `name` = 'empower' WHERE `ow_base_authorization_role`.`id` =13; }
if ($count >= 2720) { $lvl = UPDATE `founda_Inspire`.`ow_base_authorization_role` SET `name` = 'integrity' WHERE `ow_base_authorization_role`.`id` =18; }
else if ($count >= 625) { $lvl = UPDATE `founda_Inspire`.`ow_base_authorization_role` SET `name` = 'honor' WHERE `ow_base_authorization_role`.`id` =17; }
else if ($count >= 125) { $lvl = UPDATE `founda_Inspire`.`ow_base_authorization_role` SET `name` = 'passion' WHERE `ow_base_authorization_role`.`id` =16; }
else if ($count >= 25) { $lvl = UPDATE `founda_Inspire`.`ow_base_authorization_role` SET `name` = 'creative' WHERE `ow_base_authorization_role`.`id` =15; }
else if ($count >= 5) { $lvl = UPDATE `founda_Inspire`.`ow_base_authorization_role` SET `name` = 'inspire' WHERE `ow_base_authorization_role`.`id` =14; }
?>
Upvotes: 0
Views: 55
Reputation: 6876
Your code snippet above has several problems, lets start here..
$query = mysql_query("SELECT COUNT(*) FROM 'ow_base_user'.'id' WHERE 'id'") or die (mysql_error());
your where clause in the above statement is blank and this is not allowed in SQL
Futher in your snippet you have
$lvl = UPDATE `founda_Inspire`.`ow_base_authorization_role` SET `name` = 'empower' WHERE `ow_base_authorization_role`.`id` =13; }
if ($count >= 2720) { $lvl = UPDATE `founda_Inspire`.`ow_base_authorization_role` SET `name` = 'integrity' WHERE `ow_base_authorization_role`.`id` =18; }
else if ($count >= 625) { $lvl = UPDATE `founda_Inspire`.`ow_base_authorization_role` SET `name` = 'honor' WHERE `ow_base_authorization_role`.`id` =17; }
else if ($count >= 125) { $lvl = UPDATE `founda_Inspire`.`ow_base_authorization_role` SET `name` = 'passion' WHERE `ow_base_authorization_role`.`id` =16; }
else if ($count >= 25) { $lvl = UPDATE `founda_Inspire`.`ow_base_authorization_role` SET `name` = 'creative' WHERE `ow_base_authorization_role`.`id` =15; }
else if ($count >= 5) { $lvl = UPDATE `founda_Inspire`.`ow_base_authorization_role` SET `name` = 'inspire' WHERE `ow_base_authorization_role`.`id` =14; }
And your quotes are all in the wrong places so your SQL strings are not being built correctly
On a side note, you will generally get a better response on stackoverflow when you have shown an effort to solve your problems prior to posting. Based on what you posted it seems like you just said "eh its not working let me ask on SO"
Upvotes: 1