You have an error in your SQL syntax; check the manual checkthat corresponds to your

My Assistant
Welcome Guest (
&You have an error in your SQL check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 7
Group: Members
Joined: 6-March 12
Member No.: 16,654
&?php$mysql_host = &********&;$mysql_database = &********&;$mysql_user = &*************&;$mysql_password = &*********&;$fname=$_POST['fname'];$lname=$_POST['lname'];$user=$_POST['username'];$password=$_POST['password'];$verify=$_POST['verify'];$email=$_POST['email'];$country=$_POST['country'];$month=$_POST['month'];$day=$_POST['day'];$year=$_POST['year'];$con = mysql_connect( $mysql_host, $mysql_user, $mysql_password );if ( !$con ){die( 'Could not connect: ' . mysql_error() );}mysql_select_db( &$mysql_database&,$con );$table = &CREATE TABLE `$user`(`fname` varchar(30),`lname` varchar(30),`username` varchar(30),`password` varchar(30),`email' varchar(30),'country' varchar(30),'month' varchar(30),'day' int(2),'year' int(4),PRIMARY KEY '$user')& ; echo &Table Created!&;mysql_query($table,$con)
or die (mysql_error());mysql_close($con);?&Above is my php code. I am trying to make a login system. I keep getting this error message &You have an error in your SQL check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 7& I have no idea what this means because i have no code on line 7. Any help is greatly appreciated. Also if you have any suggestions, please pm me.The form for this php code is on the page & &Please visit and give me any suggestions as to what to do! Thanks!
Advanced Member
Group: Members
Posts: 167
Joined: 2-September 07
From: New Mexico
Member No.: 3,702
QUOTE(tyler.watkins @ Apr 10 ;24 PM) &?php$mysql_host = &********&;$mysql_database = &********&;$mysql_user = &*************&;$mysql_password = &*********&;$fname=$_POST['fname'];$lname=$_POST['lname'];$user=$_POST['username'];$password=$_POST['password'];$verify=$_POST['verify'];$email=$_POST['email'];$country=$_POST['country'];$month=$_POST['month'];$day=$_POST['day'];$year=$_POST['year'];$con = mysql_connect( $mysql_host, $mysql_user, $mysql_password );if ( !$con ){die( 'Could not connect: ' . mysql_error() );}mysql_select_db( &$mysql_database&,$con );$table = &CREATE TABLE `$user`(`fname` varchar(30),`lname` varchar(30),`username` varchar(30),`password` varchar(30),`email' varchar(30),'country' varchar(30),'month' varchar(30),'day' int(2),'year' int(4),PRIMARY KEY '$user')& ; echo &Table Created!&;mysql_query($table,$con)
or die (mysql_error());mysql_close($con);?&This line:$user=$_POST['username'];is the first error. You rename username to user.This error cascades to make the rest of the program not work.Note that this error is valid code, the error is with your use.Note also that you're confused with a variable ($v) and a literal string (v) even with the same name.This is the first cascade error:$table = &CREATE TABLE `$user`The name of the table is not user as you seem to want but some name that $user contains.This is the next error cluster:`email' varchar(30),'country' varchar(30),'month' varchar(30),'day' int(2),'year' int(4),PRIMARY KEY '$user'Note that you use an apostrophe instead of a backtick.The PRIMARY KEY statement belongs with the definition for user (which doesn't exist).You need to pay more attention to all the nitty gritty.I didn't go into any other errors.
Jocular coder
Group: Members
Posts: 2,298
Joined: 31-August 06
Member No.: 43
QUOTEAbove is my php code. I am trying to make a login system. I keep getting this error message &You have an error in your SQL check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 7& I have no idea what this means because i have no code on line 7. Any help is greatly appreciated.I'm pretty sure that the MySQL error message means line 7 of the chunk of SQL you have thrown at it. It looks as though this might be the first line on which you have used a quote (') in place of a backtick, so the confusing '' might somehow be meant to be ''', i.e. a quote inside quotes. Anyway, SQL error messages are not the most helpful, but as Ephraim said, you have to be *much* more careful.I'm not sure I understand his comment about the $user variable, though. Maybe it's a mistake, or maybe there's a more major confusion and you are trying to create a table for each user, which is not what you want.
Group: Members
Joined: 6-March 12
Member No.: 16,654
What would I do if I wanted to create a table with the name of the user? Like they have their own individual table.
Jocular coder
Group: Members
Posts: 2,298
Joined: 31-August 06
Member No.: 43
QUOTEWhat would I do if I wanted to create a table with the name of the user? Like they have their own individual table.If you think you want to do this, you have almost certainly missed the whole point of using a database. (You could try reading the first three chapters of the book again!)You need one table for each *class* of entity (e.g. 'customer'), then you need one entry in the customer table for each customer. Nothing else makes any sense.So generally it's simpler to use phpmyadmin (e.g.) to create the table, since you only need to do this once.
Group: Members
Joined: 6-March 12
Member No.: 16,654
So I would make a table called users and everyone's information will be stored in that?
Jocular coder
Group: Members
Posts: 2,298
Joined: 31-August 06
Member No.: 43
QUOTESo I would make a table called users and everyone's information will be stored in that?Yes. (This really should be in Chapter 1 of the book!)Because every 'user' has the same properties: name, id, date joined, whatever, something else...
Advanced Member
Group: Members
Posts: 167
Joined: 2-September 07
From: New Mexico
Member No.: 3,702
QUOTE(Brian Chandler @ Apr 11 ;38 AM) QUOTESo I would make a table called users and everyone's information will be stored in that?Yes. (This really should be in Chapter 1 of the book!)Because every 'user' has the same properties: name, id, date joined, whatever, something else...See:
Group: Members
Joined: 6-March 12
Member No.: 16,654
What book?
Jocular coder
Group: Members
Posts: 2,298
Joined: 31-August 06
Member No.: 43
Whichever book you're using. (I suppose it might be an online tutorial)Incidentally there's a very delicate question: should you call the table &users& (because it's something that holds all the users, or &user&, because what you get from it is a table row representing a user. I tend to think the singular is better...
Group: Members
Joined: 6-March 12
Member No.: 16,654
But if I make a table for all the users wouldn't all the usernames and passwords be stored there? And when someone goes to login how would I know if they use the right password that corresponds to their username?
WDG Member
Group: Root Admin
Posts: 8,206
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3
QUOTEBut if I make a table for all the users wouldn't all the usernames and passwords be stored there?Yes. That's the point.QUOTEAnd when someone goes to login how would I know if they use the right password that corresponds to their username?Don't look for an entry that merely has the password they entered. Instead, look for an entry that has the username they entered AND the password they entered.
Group: Members
Joined: 6-March 12
Member No.: 16,654
I'm sorry for all the probably amateurish questions, but I'm new to this. But do you have any examples of the code? Or what it would look like? I'm not asking for a full page of code, just a small snippet. And thanks a lot for all the help everyone!!This post has been edited by tyler.watkins: Apr 11
Advanced Member
Group: Members
Posts: 167
Joined: 2-September 07
From: New Mexico
Member No.: 3,702
+----------+ . . . . . . . .+--------+
| database +-+--------------+ table2 |+----------+ |. . . . . . . +-----+--+. . . . . . .|. .+--------+ . . . |. . . . . . .+---+ table1 + . . . |. . . . . . . . .+-----+--+ . . . |. . . . . . . . . . . .|. . . . . |
+----+----------+----------+------+. . . . . . . . . . . .|. . . . . +-+ id + username + password + more +. . . . . . . . . . . .|. . . . . |
+----+----------+----------+------+. . . . . . . . . . . .|. . . . . |
+----+----------+----------+------+. . . . . . . . . . . .|. . . . . +-+ id + username + password + more +. . . . . . . . . . . .|. . . . . .
+----+----------+----------+------+. . . . . . . . . . . .|. . . . . . . . . . . . . . etc. . . . . . . . . . . .|. . . . . . . . . . . .|
+----+----------+----------+------+. . . . . . . . . . . .+-+ id + column 1 + column 2 + more +. . . . . . . . . . . . .+----+----------+----------+------+. . . . . . . . . . . . . . . . . . . . etcIGNORE THE DOTSDoes anyone know how to keep spaces from collapsing in this board?This post has been edited by Ephraim F. Moya: Apr 11
Group: Members
Joined: 6-March 12
Member No.: 16,654
You lost me?
Advanced Member
Group: Members
Posts: 167
Joined: 2-September 07
From: New Mexico
Member No.: 3,702
QUOTE(tyler.watkins @ Apr 11 ;50 PM) You lost me?first you select the database using the database's name. In this case the database name is database.Next you use a sql query to select the data you want.mysql_query( SELECT * FROM `table2` FOR `id` = 7 );In English: give me all (*) the data for the row with id = 7.What you'll get back is an array with all the data in row 7 or you'll get back a false if there's no row 7.Study the diagram I posted. It describes a simple database like I think you want.This post has been edited by Ephraim F. Moya: Apr 12
Group: Members
Joined: 6-March 12
Member No.: 16,654
Thanks!
Advanced Member
Group: Members
Posts: 167
Joined: 2-September 07
From: New Mexico
Member No.: 3,702
QUOTE(tyler.watkins @ Apr 12 ;38 AM) Thanks!I made a mistake in the query string for reading a row. FOR should be WHERE.$query = &SELECT * FROM `table2` WHERE `id` = '7'&; and then I noticed that you're using mysqliThis fits in the $resultArray = mysqli_query( $con, &{$query}&, MYSQLI_STORE_RESULT ); instruction like this.Of course there are supporting instructions all around these.
Group: WDG Moderators
Posts: 6,890
Joined: 10-August 06
Member No.: 7
I moved one post to its own thread:
Group: Members
Joined: 20-April 13
Member No.: 19,046
Please help! I'm having the same problem.. Here is my php code&?php
$id = @$_REQUEST['id']; session_start();
include(&../admin/connections.php&);
$query =
mysql_query(&SELECT * FROM album WHERE id = $id&); $fetch = mysql_fetch_array($query);
if(isset($_SESSION['account'])) {
$acct = $_SESSION['account']; }
$sql = &SELECT a.name as name, r.id as id, r.account_id as act_id, r.album_id as albm_id, r.review as review, r.rating as rating, r.date as date FROM reviews r &; $sql .= &LEFT JOIN accounts a ON a.acc_id = r.account_id WHERE r.album_id = $id&; $res = mysql_query($sql) or die(mysql_error());
if($_POST) {
$comment = $_POST['comment'];
$acct_id = $acct['id'];
$album_id = $fetch['id'];
$rating = @$_POST['rate'];
$date = date('Y-m-d H:i:s');
$sql = &INSERT INTO reviews(account_id, album_id, review, rating, date)&;
$sql .= &VALUES($acct_id, $album_id, '$comment', $rating, '$date')&;
$result = mysql_query($sql) or die(mysql_error());
header(&Location: viewalbum.php&); }?&thank you in advance~
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:
Forum Home
Web Authoring
&&|-- Markup (HTML, XHTML, XML)
&&|-- Cascading Style Sheets
&&|-- Web Site Functionality
&&|-- Graphics, Flash and Multimedia
&&|-- General Web Design
Programming
&&|-- Client-side Scripting
&&|-- Server-side Scripting
&&|-- Databases
&&|-- Web Server Configuration
General Interest
&&|-- Site Review Requests
&&|-- Jobs Seeking Programmers
&&|-- Programmers Seeking Jobs
&&|-- Off Topic
Service Providers
&&|-- eCommerce Applications and Providers
&&|-- Hosting Providers
&&|-- Web Development Software
Administrative
&&|-- News and Announcements
&&|-- Feedback and Assistance
&&|-- Test
Display Mode:4829人阅读
JDBC(19)
MySql(19)
今下午一连遇到了俩错误, 都是比较低级的&
只能说是基础不到家, 唉。。。。。。。。。。&
String psql = &select * from users where id = ?&;
pstmt = conn.prepareStatement(psql);
pstmt.setInt(1, id);
ResultSet rs = pstmt.executeQuery(psql);&
ResultSet rs = pstmt.executeQuery(psql); 运行【完】这的时候 会抛出一个异常:&
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException:
You have an error in your SQL
check the manual that corresponds to your MySQL server version for the
right syntax to use near '?' at line 1&
============================================&
在解决问题的时候 一直围绕着 “参数”-- ? --求解,但是。。。。&
没有留意&executeQuery () 的用法&
executeQuery& 一个是不带参数的, 另一个是带参数的:
二者之间的区别
executeQuery&()&是& pstmt 中的方法&
executeQuery&(sql)& 是继承自stmt中的方法
=============================================
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:1530144次
积分:20863
积分:20863
排名:第190名
原创:578篇
转载:134篇
评论:317条
(13)(4)(2)(1)(1)(6)(4)(1)(1)(1)(3)(3)(1)(1)(1)(2)(1)(1)(2)(2)(2)(1)(8)(7)(7)(19)(5)(10)(3)(2)(4)(3)(5)(2)(3)(4)(4)(7)(3)(15)(18)(5)(7)(9)(3)(9)(8)(15)(22)(11)(7)(20)(7)(46)(56)(41)(23)(32)(60)(66)(48)(34)select count(*) as iq_total_page from iq_rw where uid= 执行错误: You have an error in your SQL check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
select count(*) as iq_total_page from iq_rw where uid= 执行错误: You have an error in your SQL check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
/home/ftp/7//wwwroot/include/mysql.php on line 34
&&&&&&&&$this-&arrSql[]&=&$sql;
&&&&&&&&if($result&=&mysql_query($sql,&$this-&conn)){
&&&&&&&&&&&&return&$result;
&&&&&&&&}else{
&&&&&&&&&&&&if(mysql_error()!=''){
&&&&&&&&&&&&&&&&syError("{$sql}&br&/&执行错误:&"&.&mysql_error());
&&&&&&&&&&&&}else{
&&&&&&&&&&&&&&&&return&TRUE;
&&&&&&&&&&&&}
/home/ftp/7//wwwroot/include/mysql.php on line 7
if(!defined('APP_PATH')||!defined('IQ_PATH'))exit('Access&Denied');
class&db_mysql&{
&&&&public&$conn;
&&&&public&$arrSql;
&&&&public&function&getArray($sql){
&&&&&&&&if(!$result&=&$this-&exec($sql))return&array();
&&&&&&&&if(!mysql_num_rows($result))return&array();
&&&&&&&&$rows&=&array();
&&&&&&&&while($rows[]&=&mysql_fetch_array($result,MYSQL_ASSOC)){}
&&&&&&&&mysql_free_result($result);
&&&&&&&&array_pop($rows);
/home/ftp/7//wwwroot/include/syModel.php on line 124
&&&&public&function&updateField($conditions,&$field,&$value){
&&&&&&&&return&$this-&update($conditions,&array($field=&$value));
&&&&public&function&findSql($sql){
&&&&&&&&return&$this-&_db-&getArray($sql);
&&&&public&function&runSql($sql){
&&&&&&&&return&$this-&_db-&exec($sql);
/home/ftp/7//wwwroot/include/Functions.php on line 628
&&&&return&$allfields;
function&&total_page($sql,$v='iq_total_page'){
&&&&$a=syDB('molds')-&findSql('select&count(*)&as&'.$v.'&from&'.$sql);
&&&&return&$a[0][$v];
//支付平台
function&payment($pay){
&&&&$payment=syDB('payment')-&find(array('pay'&=&&$pay),null,'name');
/home/ftp/7//wwwroot/source/task.php on line 218
&&&&&&&&&&&&$w.="and&aid=".$this-&syArgs("aid")."&";
&&&&&&&&$order='&order&by&addtimes&desc,aid&desc';
&&&&&&&&$db=$GLOBALS['G_DY']['db']['prefix'].'rw';
&&&&&&&&$sql='select&*&from&'.$db.$w.$order;
&&&&&&&&$total_page=total_page($db.$w);
&&&&&&&&$list_c=$this-&Class-&syPager($this-&syArgs('page',0,1),20,$total_page)-&findSql($sql);
&&&&&&&&$pages=$this-&Class-&syPager()-&getPager();
&&&&&&&&$this-&pages=html_url('classtype',1,$pages,$this-&syArgs('page',0,1));
&&&&&&&&foreach($list_c&as&$v){
&&&&&&&&&&&&if($this-&syArgs("qq",1)){
/home/ftp/7//wwwroot/include/Functions.php on line 17
&&&&$handle_controller&=&syClass($__controller,&null,&$GLOBALS['G_DY']["controller_path"].'/'.$__controller.".php");
&&&&if(!is_object($handle_controller)&||&!method_exists($handle_controller,&$__action)){
&&&&&&&&syError('route&Error');
&&&&$handle_controller-&$__action();
&&&&if(FALSE&!=&$GLOBALS['G_DY']['view']['auto_display']){
&&&&&&&&$__tplname&=&$__controller.$GLOBALS['G_DY']['view']['auto_display_sep'].$__action.$GLOBALS['G_DY']['view']['auto_display_suffix'];&
&&&&&&&&$handle_controller-&auto_display($__tplname);
&&&&spLaunch("router_postfilter");
/home/ftp/7//wwwroot/index.php on line 6
require("route.php");
require(IQ_CONFIG_PATH."/config_iq.php");
$IqConfig['view']['config']['template_dir']&=&APP_PATH.'/template/'.$IqConfig['ext']['view_themes'];
require(IQ_PATH."/sys.php");DESCRIBE 执行错误: You have an error in your SQL check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
DESCRIBE 执行错误: You have an error in your SQL check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
E:\aqcz2013\SpeedPHP\Drivers\mysql.php on line 62
&&&&&&&&$this-&arrSql[]&=&$sql;
&&&&&&&&if(&$result&=&mysql_query($sql,&$this-&conn)&){
&&&&&&&&&&&&return&$result;
&&&&&&&&}else{
&&&&&&&&&&&&spError("{$sql}&br&/&执行错误:&"&.&mysql_error());
&&&&&*&返回影响行数
E:\aqcz2013\SpeedPHP\Drivers\mysql.php on line 26
&&&&&*&@param&sql&&执行的SQL语句
&&&&public&function&getArray($sql)
&&&&&&&&if(&!&$result&=&$this-&exec($sql)&)return&array();
&&&&&&&&if(&!&mysql_num_rows($result)&)return&array();
&&&&&&&&$rows&=&array();
&&&&&&&&while($rows[]&=&mysql_fetch_array($result,MYSQL_ASSOC)){}
&&&&&&&&mysql_free_result($result);
&&&&&&&&array_pop($rows);
E:\aqcz2013\SpeedPHP\Drivers\mysql.php on line 81
&&&&&*&@param&tbl_name&&表名称
&&&&public&function&getTable($tbl_name)
&&&&&&&&return&$this-&getArray("DESCRIBE&{$tbl_name}");
&&&&&*&构造函数
E:\aqcz2013\SpeedPHP\spFunctions.php on line 311
function&spDB($tbl_name,&$pk&=&null){
&&&&$modelObj&=&spClass("spModel");
&&&&$modelObj-&tbl_name&=&(TRUE&==&$GLOBALS['G_SP']["db_spdb_full_tblname"])&?&$tbl_name&:&&&&$GLOBALS['G_SP']['db']['prefix']&.&$tbl_name;
&&&&if(&!$pk&){&//&主键通过数据库驱动getTable来获取
&&&&&&&&@list($pk)&=&$modelObj-&_db-&getTable($modelObj-&tbl_name);$pk&=&$pk['Field'];
&&&&$modelObj-&pk&=&$pk;
&&&&return&$modelObj;
E:\aqcz2013\controller\main.php on line 148
&&&&&&&&$args&=&$this-&spArgs();
&&&&&&&&//&table
&&&&&&&&$res&=&$args[res];
&&&&&&&&$id&=&$args[id];
&&&&&&&&//&浏览次数加1
&&&&&&&&spDB($res)-&findSql('update&'.$res.'&set&'.Consts::COLUMN_SCAN_NUM.'='.Consts::COLUMN_SCAN_NUM.'&+&1&where&'.Consts::COLUMN_ID.'='.$id);
&&&&&&&&$this-&data&=&spDB($res)-&findBy(Consts::COLUMN_ID,&$id);
&&&&&&&&//*************设置文章信息*************
&&&&&&&&//&标题
&&&&&&&&$fileName=iconv("UTF-8","gb2312",&$this-&data[Consts::COLUMN_FILENAME]);
&&&&&&&&//&内容
E:\aqcz2013\SpeedPHP\spFunctions.php on line 21
&&&&if(!is_object($handle_controller)&||&!method_exists($handle_controller,&$__action)){
&&&&&&&&eval($GLOBALS['G_SP']["dispatcher_error"]);
&&&&//&路由并执行用户代码
&&&&$handle_controller-&$__action();
&&&&//&控制器程序运行完毕,进行模板的自动输出
&&&&if(FALSE&!=&$GLOBALS['G_SP']['view']['auto_display']){
&&&&&&&&$__tplname&=&$__controller.$GLOBALS['G_SP']['view']['auto_display_sep'].
&&&&&&&&&&&&&&&&$__action.$GLOBALS['G_SP']['view']['auto_display_suffix'];&//&拼装模板路径
&&&&&&&&$handle_controller-&auto_display($__tplname);
E:\aqcz2013\index.php on line 37
&&&&for&($i&=&0;&$i&&&count($list);&$i++)&{
&&&&&&&&$list[$i][res]&=&$res;
&&&&return&$list;
spRun();&//&SpeedPHP&3新特性

我要回帖

更多关于 manual check 的文章

 

随机推荐