Sql error maar weet niet welke?
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
session_start();
if ($_SESSION['security'] == 'validated'){
require('../config.php');
if ($_POST['action1'] == 'insert_user'){
$username4=$_POST['username4'];
$password=$_POST['password'];
$email=$_POST['email'];
$adminlvl=$_POST['adminlvl'];
$mysql = mysql_pconnect($hostname_mysql, $username_mysql, $password_mysql) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database_mysql, $mysql);
$query_users1= "SELECT * FROM users";
$users1 = mysql_query($query_users1, $mysql) or die(mysql_error());
$row_users1 = mysql_fetch_assoc($users1);
$totalRows_users1 = mysql_num_rows($users1);
$key= 0 + $totalRows_users + 1;
$mysql = mysql_pconnect($hostname_mysql, $username_mysql, $password_mysql) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database_mysql, $mysql);
$sql = "INSERT INTO users (key, username, password, mail, adminlvl) VALUES ('$key','$username4','$password','$email','$adminlvl')";
mysql_query ($sql) or trigger_error (mysql_error ());
$admin="[email protected]";
$onderwerp="divined account aangemaakt door ".$_SESSION['username']." ";
$bericht="gebruikersnaam: ".$username4."\n";
$bericht .="admin LVL: ".$adminlvl."\n";
$bericht .="e-mail: ".$email."\n";
mail($admin,$onderwerp,$bericht);
echo "<SCRIPT LANGUAGE=JavaScript>window.alert('Account Toegevoegd')</SCRIPT>";
}
?>
session_start();
if ($_SESSION['security'] == 'validated'){
require('../config.php');
if ($_POST['action1'] == 'insert_user'){
$username4=$_POST['username4'];
$password=$_POST['password'];
$email=$_POST['email'];
$adminlvl=$_POST['adminlvl'];
$mysql = mysql_pconnect($hostname_mysql, $username_mysql, $password_mysql) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database_mysql, $mysql);
$query_users1= "SELECT * FROM users";
$users1 = mysql_query($query_users1, $mysql) or die(mysql_error());
$row_users1 = mysql_fetch_assoc($users1);
$totalRows_users1 = mysql_num_rows($users1);
$key= 0 + $totalRows_users + 1;
$mysql = mysql_pconnect($hostname_mysql, $username_mysql, $password_mysql) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database_mysql, $mysql);
$sql = "INSERT INTO users (key, username, password, mail, adminlvl) VALUES ('$key','$username4','$password','$email','$adminlvl')";
mysql_query ($sql) or trigger_error (mysql_error ());
$admin="[email protected]";
$onderwerp="divined account aangemaakt door ".$_SESSION['username']." ";
$bericht="gebruikersnaam: ".$username4."\n";
$bericht .="admin LVL: ".$adminlvl."\n";
$bericht .="e-mail: ".$email."\n";
mail($admin,$onderwerp,$bericht);
echo "<SCRIPT LANGUAGE=JavaScript>window.alert('Account Toegevoegd')</SCRIPT>";
}
?>
hier zit de fout
hji geeft sql syntax error bij het stukje insert into ....
Gewijzigd op 01/01/1970 01:00:00 door Dennis
hij geeft de fout bij regel 19
Gewijzigd op 01/01/1970 01:00:00 door dennis
dit is de exacte error
Notice: You have an error in your SQL syntax near 'key, username, password, mail, adminlvl) VALUES ('1','test','test','test','2')' at line 1 in /home/httpd/vhosts/mijnsite.nl/subdomains/admin/httpdocs/admin/new_account.php on line 19
variabelen buiten de quotes ;-)
maakt niet uit nog steeds de zelfde fout
Probeer die kolom eens anders te noemen. Bijvoorbeeld id.
Elwin