Search
Left Quote    Copy from one, it's plagiarism; copy from two, it's research.
- Wilson Mizner    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: '@' error in mysql
  This user is offline  LaudArch
  Subject: "'@' error in mysql" Posted: @ 6:32 pm on Sep 22 2008   
Member #: 754
Rank: User - (5)
Since: 09/16/08
Posts: 5
From: Accra, Ghana

Sup,
Am designing a simple subscription form where users
enter their email addresses and its entered into the
database. but I keep getting this 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 '@hotmail.com)' at line 1"

I use PHP 5.2.6 with sql 5.0

I will really apprecite any help here.

Peace!


Qremia Evolution
    Viewed: 7,049 Times | Reply to This | To top
  This user is offline  misterhaan
  Subject: "re: '@' error in mysql" Posted: @ 3:01 pm on Sep 23 2008    

Member #: 5
Rank: User - (213)
Since: 02/11/05
Posts: 148
From: chair

what




please note that the above post is likely made up in its entirety.

    Viewed: 7,036 Times | Reply to This | To top
  This user is offline  LaudArch
  Subject: "re: '@' error in mysql" Posted: @ 8:58 pm on Sep 26 2008    
Member #: 754
Rank: User - (5)
Since: 09/16/08
Posts: 5
From: Accra, Ghana

Sorry I didn't respond early I had to go to a program u can check it on http://www.thei tchallenge.4x2. net

Thanks
Here is my query;

<?php
...
$email_ad = $_POST['subEma il'];

$stmt_sql = 'INSERT INTO Subscription (email) values ($email_ad)';< br />
$query = mysql_query( $stmt_sql );

if ( !$query ) {
echo '<br>Mys ql Error: '.mysql_error( );
}
..
?>




Qremia Evolution

    Viewed: 7,000 Times | Reply to This | To top
  This user is offline  misterhaan
  Subject: "re: '@' error in mysql" Posted: @ 2:31 pm on Sep 29 2008    

Member #: 5
Rank: User - (213)
Since: 02/11/05
Posts: 148
From: chair

yeah, you need to put quotes around the value:

$stmt_sql = 'INSERT INTO Subscription (email) values (\'$email_ad \')';

also, you are leaving yourself open to sql injection unless your server has magic quotes turned on. you can fix that with running $email_ad through addslashes() before putting it into the sql query.




please note that the above post is likely made up in its entirety.

    Viewed: 6,977 Times | Reply to This | To top
  This user is offline  LaudArch
  Subject: "re: '@' error in mysql" Posted: @ 12:56 am on Oct 04 2008    
Member #: 754
Rank: User - (5)
Since: 09/16/08
Posts: 5
From: Accra, Ghana

Thanks, it work.

Peace!




Qremia Evolution

    Viewed: 6,930 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

You must be logged in to post on the forums. Login or Register








"AllSyntax.com" Copyright © 2002-2018; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank