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
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)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.