Jump to content

[SOLVED] php insert into database


adam291086

Recommended Posts

Hey the code below just produces error with no mysql problem and no information is put into the database. Can anyone see why?

 

<?php        

session_start();

// is the one accessing this page logged in or not?
if (!isset($_SESSION['db_is_logged_in'])
   || $_SESSION['db_is_logged_in'] !== true) {

   // not logged in, move to login page
   header('Location: login.php');
   exit;
}



$News = $_POST["News"];
$Major = $_POST["Major"];
$WRYL = $_POST["WRYL"];
$Development = $_POST["Development"];
$Events = $_POST["Events"];
$Board = $_POST["Board"];
$NRRC = $_POST["NRRC"];
$Latest = $_POST["Latest Results"];
$Ryedale = $_POST["Ryedale Rumble"];
$Home = $_POST["Home"];
$User = $_POST["User_Name"];
$Password = $_POST["Password"];

include 'config.php';

$conn;
mysql_query("
INSERT INTO tbl_auth_user (
user_name, 
user_password, 
Home page, 
Ryedale Rumble, 
Latest Results, 
National Road Race Championship,   	  
Board, 
Events Workgroup, 
Development, 
WRYL, 
Majour Events, 
News) 
VALUES (
'$User', 
'PASSWORD(Password)', 
'$Home', 
'$Ryedale', 
'$Latest', 
'$NRRC', 
'$Board', 
'$Events', 
'$Development', 
'$WRYL', 
'$Major', 
'$News')");

include 'closedb.php';

if (!mysql_query())
  {
  die('Error: ' .mysql_error());
  }
echo "1 record added";
?>

Link to comment
Share on other sites

Try this, and tell us what it gives you

 

<?php

$query ="
INSERT INTO tbl_auth_user (
user_name, 
user_password, 
Home page, 
Ryedale Rumble, 
Latest Results, 
National Road Race Championship,   	  
Board, 
Events Workgroup, 
Development, 
WRYL, 
Majour Events, 
News) 
VALUES (
'$User', 
'PASSWORD(Password)', 
'$Home', 
'$Ryedale', 
'$Latest', 
'$NRRC', 
'$Board', 
'$Events', 
'$Development', 
'$WRYL', 
'$Major', 
'$News')";

$result = mysql_query($query)or die(mysql_error()."<p>With Query<br>$query");
echo "<p>$query";

include 'closedb.php';


?>

Link to comment
Share on other sites

I tried that code and now get the error

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'page, Ryedale Rumble, Latest Results, National Road Race Cham

 

With Query

INSERT INTO tbl_auth_user ( user_name, user_password, Home page, Ryedale Rumble, Latest Results, National Road Race Championship, Board, Events Workgroup, Development, WRYL, Majour Events, News) VALUES ( 'adam', 'PASSWORD(Password)', 'Home', '', '', 'NRRC', 'Board', 'Events', 'development', 'WRYL', 'Major Events', 'News')

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.