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())); Quote Link to comment 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 Quote Link to comment 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())); ?> Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.