Jump to content

data is not inserted in db


paulus4605

Recommended Posts

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 :confused:

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>';
//}
?>

Link to comment
https://forums.phpfreaks.com/topic/246518-data-is-not-inserted-in-db/
Share on other sites

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)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.