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 |
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 |
tyler.watkins |
Apr 10 2012, 03:24 PM
Post
#1
|
Novice Group: Members Posts: 27 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 syntax; 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 "http://blocks.netne.net/register.html " Please visit and give me any suggestions as to what to do! Thanks! |
mde27 |
Apr 20 2013, 08:31 PM
Post
#2
|
Group: Members Posts: 1 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~ |
Lo-Fi Version | Time is now: 25th April 2024 - 12:25 PM |