6 Replies - 453 Views - Last Post: 09 February 2013 - 07:23 AM Rate Topic: -----

#1 xxrhy  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 51
  • Joined: 08-April 12

Error in Create Database Table

Posted 09 February 2013 - 05:22 AM

got this error when executing my php.
"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 7"

validate.php
<?php

$host="localhost"; // Host name 
$username="root"; // Mysql username 
$password=""; // Mysql password 
$db_name="gradingsys_db"; // Database name 
$tbl_name = mysql_real_escape_string($_POST['gs_name']); 

//connet database
$con = mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
// Create table
mysql_select_db("$db_name") or die(mysql_error());

// create table
mysql_query("CREATE TABLE $tbl_name(
uid int (255) NOT NULL AUTO_INCREMENT,
stnd_name varchar(255),
stnd_id varchar(255),
adviser varchar(255),
sy varchar(255),
)") or die(mysql_error());

echo "Table Created!";
mysql_close($con);

?>




and for my html
<div id="layer1" style="position: absolute; width: 923px; height: 574px; z-index: 1; left: 14px; top: 4px">
	<p class="auto-style1"><strong>CREATE SECTION</strong></p>
	<form method="post" action="validate.php" class="auto-style2">
	
		Grade-Section Name:
		<input name="gs_name" style="width: 248px" type="text" /> <br />
		<input name="Button1" style="width: 108px" type="submit" value="Create Section" /><br />
	</form>
	&nbsp;
	&nbsp;
	<p><strong>LIST OF GRADES/SECTIONS</strong></p>
	<table style="width: 100%; height: 127px" border="1px" cellspacing="0">
	
	</table>
</div>



any one?

Is This A Good Question/Topic? 0
  • +

Replies To: Error in Create Database Table

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3524
  • View blog
  • Posts: 10,169
  • Joined: 08-June 10

Re: Error in Create Database Table

Posted 09 February 2013 - 05:28 AM

there's a comma right before the closing parenthesis.
Was This Post Helpful? 0
  • +
  • -

#3 xxrhy  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 51
  • Joined: 08-April 12

Re: Error in Create Database Table

Posted 09 February 2013 - 05:33 AM

where?
Was This Post Helpful? -1
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6058
  • View blog
  • Posts: 23,495
  • Joined: 23-August 08

Re: Error in Create Database Table

Posted 09 February 2013 - 06:42 AM

Jeez, look closely! Here's your query:

CREATE TABLE $tbl_name(
  uid int (255) NOT NULL AUTO_INCREMENT,
  stnd_name varchar(255),
  stnd_id varchar(255),
  adviser varchar(255),
  sy varchar(255),
)

Was This Post Helpful? 0
  • +
  • -

#5 xxrhy  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 51
  • Joined: 08-April 12

Re: Error in Create Database Table

Posted 09 February 2013 - 07:18 AM

sorry but i don't know where's my error is.
Was This Post Helpful? 0
  • +
  • -

#6 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3524
  • View blog
  • Posts: 10,169
  • Joined: 08-June 10

Re: Error in Create Database Table

Posted 09 February 2013 - 07:20 AM

before the last ).
Was This Post Helpful? 0
  • +
  • -

#7 xxrhy  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 51
  • Joined: 08-April 12

Re: Error in Create Database Table

Posted 09 February 2013 - 07:23 AM

sorry :D my fault. i see it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1