Jump to content

Can Someone Help Me..plleeaase...


sagisgirl

Recommended Posts

hello guys..im new here.. nice to meet u all..

 

i've a prob..i cant solve it...can someone please help me... :confused:

 

i've got an error like this

 

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 ')' at line 9

 

and here are my codes..

 

<?php

 

#Connect to database

$conn = mysql_connect("localhost", "root", "root");

mysql_select_db("spidb", $conn);

 

if ( isset($_POST['save']) && ($_POST['save']) != "" ) {

if ( ($_POST['userName']) || ($_POST['password']) )

 

{

#Get values from textfield['name kt form']

$groupCode= $_POST['groupCode'];

$username = $_POST['userName'];

$password = $_POST['password'];

$email = $_POST['email'];

$userStatus = $_POST['userStatus'];

 

$sql = "INSERT INTO u_user(userID,groupCode,userName,password,email,userStatus)

VALUES

(

'".$_POST['groupCode']."',

'".addslashes(strtoupper($_POST['userName']))."',

'".addslashes(strtoupper($_POST['password']))."',

'".addslashes(strtoupper($_POST['email']))."',

'".addslashes(strtoupper($_POST['userStatus']))."',

)";

 

 

$rslt = mysql_query($sql,$conn);

 

if (!$rslt)

{

die('Error: ' . mysql_error());

}

}

}

 

$query_recCode = "SELECT * FROM u_usergroup ORDER BY groupDesc";

$rc_recCode = mysql_query($query_recCode);

$totalRows_recCode = mysql_num_rows($rc_recCode);

?>

<head><title>..::ADD USER::..</title></head>

 

<body>

<h2 align="center" style="font-style:inherit"> ADD USER</h2>

 

<form action="<? $_SERVER['../PHP_SELF']; ?>" method="post">

<span class="alert"><?php echo $alert; ?></span>

 

<?php if($rslt){ ?>

<h3 align="center" style="margin:5px; background:#CCCCCC; font-family:'Times New Roman',

Times, serif; font-size:18px; border:1px solid #CCC; color:#OOO; border-radius:10px 10px 10px 10px;

text-align:center; margin-top:15px; width:500px; margin-left:200px"> You have successfully add users!</h3>

<? }

?>

Link to comment
Share on other sites

i'm sorry, but i still didnt get it..sholud i change this

 

if ( isset($_POST['save']) && ($_POST['save']) != "" ) {

if ( ($_POST['userName']) || ($_POST['password']) )

 

to this

 

if ( isset($_POST['save']) && $_POST['save'] != "" ) {

if ( $_POST['userName'] || $_POST['password'] )

 

i remove some brackets there..

Link to comment
Share on other sites

^^^ That's not a line in your query. Those are lines of php code.

 

This is your error message -

 

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 ')' at line 9

 

This is the code producing the SQL query statement -

 


$sql = "INSERT INTO u_user(userID,groupCode,userName,password,email,userStatus)
    VALUES
   (
   '".$_POST['groupCode']."',
   '".addslashes(strtoupper($_POST['userName']))."',
   '".addslashes(strtoupper($_POST['password']))."',
   '".addslashes(strtoupper($_POST['email']))."',
   '".addslashes(strtoupper($_POST['userStatus']))."',
   )";

Edited by PFMaBiSmAd
Link to comment
Share on other sites

ok.. then i change the code to this..

 

<?php

 

#Connect to database

$conn = mysql_connect("localhost", "root", "root");

mysql_select_db("spidb", $conn);

 

if ( isset($_POST['save']) && $_POST['save'] != "" ) {

if ( $_POST['userName'] || $_POST['password'] )

{

$sql = "INSERT INTO u_user(userID,groupCode,userName,password,email,userStatus)

VALUES

(

'".$_POST['groupCode']."',

'".addslashes(strtoupper($_POST['userName']))."',

'".addslashes(strtoupper($_POST['password']))."',

'".addslashes(strtoupper($_POST['email']))."',

'".addslashes(strtoupper($_POST['userStatus']))."',

)";

 

$rslt = mysql_query($sql,$conn);

 

if (!$rslt)

{

die('Error: ' . mysql_error());

}

}

}

$query_recCode = "SELECT * FROM u_usergroup ORDER BY groupDesc";

$rc_recCode = mysql_query($query_recCode);

$totalRows_recCode = mysql_num_rows($rc_recCode);

?>

<html>

<head>

<!-- <link rel="stylesheet" href="css/style.css"/>-->

<title>..::TAMBAH PENGGUNA::..</title>

</head>

 

<body>

<h3 align="center"> SISTEM PEMANTAUAN INVENTORI </h3>

<h2 align="center" style="font-style:inherit"> Tambah Pengguna </h2>

 

<form action="<? $_SERVER['../PHP_SELF']; ?>" method="post">

<span class="alert"><?php echo $alert; ?></span>

 

<?php

if($rslt)

{

?>

<h3 align="center" style="margin:5px; background:#CCCCCC; font-family:'Times New Roman', Times, serif; font-size:18px;

border:1px solid #CCC; color:#OOO; border-radius:10px 10px 10px 10px; text-align:center; margin-top:15px;

width:500px; margin-left:200px"> Pengguna telah berjaya ditambah!</h3>

<?

}

?>

 

 

but i still got the same error,

 

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 ')' at line 9

 

why..? Im so confused right now..please help me solve it.. :'(

Link to comment
Share on other sites

im writting this code again on the another file. then im getting a new error.

 

the error :

 

Warning: mysql_query() expects at least 1 parameter, 0 given in C:\AppServ\www\Epic_SPI\aUser1.php on line 22

Error:

 

<?php
#conect to database
$conn = mysql_connect("localhost","root","root");
mysql_select_db("spidb",$conn);
if ( isset($_POST['save']) && $_POST['save'] != "") {
if ($_POST['userName'] || $_POST['password'] ) {

$sql = "INSERT INTO u_user
 (userName,groupCode,userName,password,email,userStatus)
 VALUES
 '".$_POST['groupCode']."',
 '".addslashes(strtoupper($_POST['userName']))."',
 '".addslashes(strtoupper($_POST['password']))."',
 '".addslashes(strtoupper($_POST['email']))."',
 '".addslashes(strtoupper($_POST['userStatus']))."')";

 $rslt = mysql_query($sql,$conn);
 if (!$rslt)
 {
 die('Error:'. mysql_query());
 }
}
}
$query_recCode = "SELECT * FROM u_usergroup ORDER BY groupDesc";
$rc_recCode = mysql_query($query_recCode);
$totalRows_recCode = mysql_num_rows($rc_recCode);
?>
<html>
<head><title></title></head>
<body>
<h3 align="center">SPI </h3>
<h2 align="center" style="font-style:inherit"> User </h2>
<form action="<? $_SERVER['../PHP_SELF']; ?>" method="post">
<span class="alert"><?php echo $alert; ?></span>
<?php
if($rslt)
{
?>
<h3 align="center" style="margin:5px; background:#CCCCCC; font-family:'Times New Roman', Times, serif; font-size:18px;
border:1px solid #CCC; color:#OOO; border-radius:10px 10px 10px 10px; text-align:center; margin-top:15px;
width:500px; margin-left:200px"> Pengguna telah berjaya ditambah!</h3>
<?
}
?>

 

actually there is not much different with the one that i posted.

 

what is the error means? im new in php.please help me.

Edited by sagisgirl
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.