Cosizzle Posted January 12, 2009 Share Posted January 12, 2009 I read about this forever ago but for the life of me I cant remember where. When I query I tend to assign something to a variable then use that variable within the query. Im following a tutorial and its using %s and %d as the input. Could someone shed some light on this? $query = sprintf(‘INSERT INTO %sUSER (USERNAME, PASSWORD, ‘ . ‘EMAIL_ADDR, IS_ACTIVE) VALUES (“%s”, “%s”, “%s”, %d)’, DB_TBL_PREFIX, mysql_real_escape_string($this- > username, $GLOBALS[‘DB’]), mysql_real_escape_string($this- > password, $GLOBALS[‘DB’]), mysql_real_escape_string($this- > emailAddr, $GLOBALS[‘DB’]), $this- > isActive); Link to comment https://forums.phpfreaks.com/topic/140577-sql-query-within-php-alternative/ Share on other sites More sharing options...
genericnumber1 Posted January 12, 2009 Share Posted January 12, 2009 All is explained here: http://us3.php.net/manual/en/function.sprintf.php Link to comment https://forums.phpfreaks.com/topic/140577-sql-query-within-php-alternative/#findComment-735655 Share on other sites More sharing options...
Cosizzle Posted January 12, 2009 Author Share Posted January 12, 2009 ah, thanks a lot - trying to search this in google wasnt working out so well! Link to comment https://forums.phpfreaks.com/topic/140577-sql-query-within-php-alternative/#findComment-735658 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.