0

Hey I am trying to run this in php:

// Retrieve data from table where row that match this passkey
$sql1="SELECT * FROM $tbl_name1 WHERE confirm_code ='$passkey'";
$result1=mysql_query($sql1) or die(mysql_error())

and I get 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 '' at line 1

Any ideas on what I am doing wrong?

7
Contributors
6
Replies
9
Views
9 Years
Discussion Span
Last Post by saiprem
0

You've missed out on a semicolon after 'die'.
do this:
.... or die(mysql_error());
This will not give an error

0

hello try this may works:

$sql1="SELECT * FROM $tbl_name1 WHERE confirm_code =".$passkey;
$result1=mysql_query($sql1) or die(mysql_error());
0

You need to know whether the generated query is a valid or not. For this, print the query e.g.

$sql1="SELECT * FROM $tbl_name1 WHERE confirm_code ='$passkey'";
echo $sql1."<br>";
$result1=mysql_query($sql1) or die(mysql_error());

Post back the query you get.

0

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 'INSERT INTO raf_emails VALUES(1, 'Email Verification Link', 'You or someone else' at line 12.


Any ideas on what to do?

Its for a raffle system.

0

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 'INSERT INTO raf_emails VALUES(1, 'Email Verification Link', 'You or someone else' at line 12.


Any ideas on what to do?

Its for a raffle system.

I am having the same problem. Any help will be appreciated

0

Hi first check that your PHP variables are passing values to your query...

Try your code like this

// Retrieve data from table where row that match this passkey
echo $sql1="SELECT * FROM $tbl_name1 WHERE confirm_code ='".$passkey."'";
$result1=mysql_query($sql1) or die(mysql_error());

In the above query, if all the values are displaying, there is nothing wrong in your query...

Same case in your insert statements,
If your table contains more than 3 columns and you are passing only 3 values to your insert statement, then it will results to error.

so in order to avoid confusion for your insert query

try like this

INSERT INTO raf_emails (column1, column2, column3) VALUES (1, 'Email Verification Link','column3_value')

Hey I am trying to run this in php:

// Retrieve data from table where row that match this passkey
$sql1="SELECT * FROM $tbl_name1 WHERE confirm_code ='$passkey'";
$result1=mysql_query($sql1) or die(mysql_error())

and I get 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 '' at line 1

Any ideas on what I am doing wrong?

Edited by saiprem: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.