Cianz Posted June 8, 2008 Share Posted June 8, 2008 I need some help, I cant see the problem -- this wont work: $query = sprintf("INSERT INTO trades SET anchr=%s, url=%s, domain=%s, username=%s, password=%s, status='pending'", anti_inject($_POST['anchr']), anti_inject($_POST['url']), anti_inject($_POST['domain']), anti_inject($_POST['username']), anti_inject($_POST['password'])); mysql_query($query) or die(sql_failure_handler($query, mysql_error())); But this will work: $retusername = anti_inject($_POST['username']); $password = anti_inject($_POST['password']); $retanchr = anti_inject($_POST['anchr']); $returl = anti_inject($_POST['url']); $retdomain = anti_inject($_POST['domain']); $query = "INSERT INTO trades SET username='$retusername', password='$retpassword', anchr='$retanchr', url='$returl', domain='$retdomain', status='pending'"; $queryin = mysql_query($query) or die(sql_failure_handler($query, mysql_error())); Link to comment https://forums.phpfreaks.com/topic/109215-solved-sprintf-wont-work-for-me/ Share on other sites More sharing options...
MiCR0 Posted June 8, 2008 Share Posted June 8, 2008 shocked that last one works as its an UPDATE statement check this guide out http://www.w3schools.com/PHP/php_mysql_insert.asp Link to comment https://forums.phpfreaks.com/topic/109215-solved-sprintf-wont-work-for-me/#findComment-560252 Share on other sites More sharing options...
sasa Posted June 8, 2008 Share Posted June 8, 2008 try <?php $query = sprintf("INSERT INTO trades SET anchr='%s', url='%s', domain='%s', username='%s', password='%s', status='pending'", anti_inject($_POST['anchr']), anti_inject($_POST['url']), anti_inject($_POST['domain']), anti_inject($_POST['username']), anti_inject($_POST['password'])); mysql_query($query) or die(sql_failure_handler($query, mysql_error())); ?> Link to comment https://forums.phpfreaks.com/topic/109215-solved-sprintf-wont-work-for-me/#findComment-560264 Share on other sites More sharing options...
Cianz Posted June 8, 2008 Author Share Posted June 8, 2008 Thanks sasa! that worked perfectly. It is taking data from a form and storing it so i'm pretty sure insert is the right command? Thanks. Link to comment https://forums.phpfreaks.com/topic/109215-solved-sprintf-wont-work-for-me/#findComment-560372 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.