AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Off-Topic (https://forums.alliedmods.net/forumdisplay.php?f=15)
-   -   PHP Mysql Update (https://forums.alliedmods.net/showthread.php?t=146842)

shuttle_wave 01-01-2011 23:22

PHP Mysql Update
 
this code doesnt seem to update the status colum where steam id =...

PHP Code:

    if ($matches[1] == "Successful")
    {
        
mysql_select_db(SQL_DB$sql_conn);
        
mysql_query("UPDATE inviter SET Status = 'INVITED'
WHERE Steamid = '%s';"
$invite_steam_id);
    } 


joaquimandrade 01-01-2011 23:25

Re: PHP Mysql Update
 
PHP Code:

    if ($matches[1] == "Successful")
    {
        
mysql_select_db(SQL_DB$sql_conn);
        
mysql_query(sprintf("UPDATE inviter SET Status = 'INVITED'
WHERE Steamid = '%s';"
$invite_steam_id));
    } 


lynettekecds 02-25-2011 17:29

Re: PHP Mysql Update
 
Quote:

Originally Posted by joaquimandrade (Post 1384185)

Code:

    if ($matches[1] == "Successful")
    {
        mysql_select_db(SQL_DB, $sql_conn);
        mysql_query(sprintf("UPDATE inviter SET Status = 'INVITED'
WHERE Steamid = '%s';", $invite_steam_id));
    }

[/code]

I do not fully understand the sample, Could you give more details? Would you pls offer the related documentation?

Seta00 02-27-2011 01:40

Re: PHP Mysql Update
 
Quote:

Originally Posted by lynettekecds (Post 1423664)
I do not fully understand the sample, Could you give more details? Would you pls offer the related documentation?

http://linux.die.net/man/3/sprintf

Styles 03-01-2011 13:50

Re: PHP Mysql Update
 
Most people don't use string formating in php, why not sure, it's just not that common. Most people just do something like

"UPDATE inviter SET Status = 'INVITED'
WHERE Steamid = '". mysql_real_string_escape($var) . "'"

Remember to use mysql_real_string_escape on ANY variable RIGHT before it gets inserted! Otherwise you can be vulnerable to sql injections. Writing a small class to handle all db interactions is probably a good idea.


All times are GMT -4. The time now is 09:25.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.