paulus4605 Posted September 6, 2011 Share Posted September 6, 2011 Hi, I am making a website where the user can create a login and he's then redirected to the secured pages this is working ok. Then I want the user who's not yet completely registered to enter his full name and credentials and store this data in the table Owner. however when I am trying to do this with the below mentioned code I don't get any output on error level and I don't get any data inserted in my table what am I missing here <?php //session starten session_start(); ini_set('display_errors', 'On'); error_reporting(E_ALL | E_STRICT); print_r($_SESSION['user_id']); //database verbinding maken mysql_connect("127.0.0.1", "root", "pass")or die("cannot connect"); mysql_select_db("tobysplace")or die("cannot select DB"); //kijken of de gebruikers_id al gekend is in de tabel Owner $result = mysql_query("Select gebruiker_id from Owner where gebruiker_id ='".mysql_real_escape_string($_SESSION['user_id'])"'"); If(!$result){ $gebruiker_id = mysql_insert_id(); } else { $gebruiker_id = mysql_real_escape_string($_SESSION['user_id']); } //de gegevens van de eigenaar wegschrijven in de database $Owner_query="insert into Owner( name, lastname, email, address1, town, postcode, phone, gebruiker_id)values( '" . mysql_real_escape_string($_SESSION['name']) . "', '" . mysql_real_escape_string($_SESSION['lastname']) . "', '" . mysql_real_escape_string($_SESSION['email']) . "', '" . mysql_real_escape_string($_SESSION['address1']) . "', '" . mysql_real_escape_string($_SESSION['town']) . "', '" . mysql_real_escape_string($_SESSION['postcode']) . "', '" . mysql_real_escape_string($_SESSION['phone']) . "', '" . mysql_real_escape_string($_SESSION['user_id']) ."')"; // // de query uitvoeren $result=mysql_query($Owner_query) //foutcontrole or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $Owner_query . "<br />\nError: (" . mysql_errno() . ") " . mysql_error()); print '<p>'.$_SESSION['name'].' U bent met succes ingeschreven op tobys-place</p>'; //} ?> Quote Link to comment https://forums.phpfreaks.com/topic/246518-data-is-not-inserted-in-db/ Share on other sites More sharing options...
voip03 Posted September 6, 2011 Share Posted September 6, 2011 You need to check 1. submit button is there? 2 form action ? 3. inputs name and $_POST 4. session in insert query , why? 5. it would be helpfull , if you post registered code Quote Link to comment https://forums.phpfreaks.com/topic/246518-data-is-not-inserted-in-db/#findComment-1265842 Share on other sites More sharing options...
WebStyles Posted September 6, 2011 Share Posted September 6, 2011 At a quick glance, this: $result = mysql_query("Select gebruiker_id from Owner where gebruiker_id ='".mysql_real_escape_string($_SESSION['user_id'])"'"); should be: $result = mysql_query("Select gebruiker_id from Owner where gebruiker_id ='" . mysql_real_escape_string($_SESSION['user_id']) . "'"); (period missing after mysql_real_escape_string) Quote Link to comment https://forums.phpfreaks.com/topic/246518-data-is-not-inserted-in-db/#findComment-1266230 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.