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
https://forums.phpfreaks.com/topic/80899-solved-php-insert-into-database/
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';


?>

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

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.