loxfear Posted August 18, 2014 Share Posted August 18, 2014 i made a submitter, that workes: <?php include 'sqlconnect.php'; $sql = sprintf( "INSERT INTO aktiviteter (`title`, `firma`, `beskrivelse`, `information`, `pris`, `rabat`, `adresse`, `by`, `postnummer`, `telefon`, `hjemmeside`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", mysqli_real_escape_string($con, $_POST['title']), mysqli_real_escape_string($con, $_POST['firma']), mysqli_real_escape_string($con, $_POST['beskrivelse']), mysqli_real_escape_string($con, $_POST['information']), mysqli_real_escape_string($con, $_POST['pris']), mysqli_real_escape_string($con, $_POST['rabat']), mysqli_real_escape_string($con, $_POST['adresse']), mysqli_real_escape_string($con, $_POST['by']), mysqli_real_escape_string($con, $_POST['postnummer']), mysqli_real_escape_string($con, $_POST['telefon']), mysqli_real_escape_string($con, $_POST['hjemmeside']) ); if (!mysqli_query($con, $sql)) { die('Error: ' . mysqli_error($con)); } echo "Aktiviteten er uploaded"; mysqli_close($con); but then i changed a few parameters and now it doesnt. i cant figure out why <?php include 'sqlconnect.php'; $sql = sprintf( "INSERT INTO menus (`navn`, `kommentar`, `pris`, `target`) VALUES ('%s', '%s', '%s', '%s')", mysqli_real_escape_string($con, $_POST['navn']), mysqli_real_escape_string($con, $_POST['kommentar']), mysqli_real_escape_string($con, $_POST['pris']), mysqli_real_escape_string($con, $_POST['target']), ); if (!mysqli_query($con, $sql)) { die('Error: ' . mysqli_error($con)); } echo "menuen er uploaded"; mysqli_close($con); can anyone spot the mistake i made? Quote Link to comment https://forums.phpfreaks.com/topic/290514-php-add-to-mysql-doesnt-work/ Share on other sites More sharing options...
Ch0cu3r Posted August 18, 2014 Share Posted August 18, 2014 but then i changed a few parameters and now it doesnt. i cant figure out why What output are you getting? Do you get any errors? If you do post them here in full. What steps have you taken to debug your code? Also make sure you error reporting enabled in your php.ini configuration or add the following two lines at the top of your script ini_set('display_errors', 1); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/290514-php-add-to-mysql-doesnt-work/#findComment-1488119 Share on other sites More sharing options...
Solution jazzman1 Posted August 18, 2014 Solution Share Posted August 18, 2014 Get rid of the last comma from sprintf function, I think that's your problem - mysqli_real_escape_string($con, $_POST['target']), Quote Link to comment https://forums.phpfreaks.com/topic/290514-php-add-to-mysql-doesnt-work/#findComment-1488122 Share on other sites More sharing options...
loxfear Posted August 18, 2014 Author Share Posted August 18, 2014 Thanks man! Quote Link to comment https://forums.phpfreaks.com/topic/290514-php-add-to-mysql-doesnt-work/#findComment-1488125 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.