Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DELETE FROM problem, is it php's fault?

Status
Not open for further replies.

vlakas1981

Programmer
Dec 11, 2002
40
GR
Hi everyone,

I have encountered a problem in my only use of a DELETE statement. Here is the code:

$deleteSQL="DELETE FROM temp_professors WHERE id='$id'";
mysql_select_db($database_sadaes, $sadaes);
$Result2 = mysql_query($deleteSQL, $sadaes) or die(mysql_error());

note that in the same page i have other sql queries running fine, however i think it might have something to do with the previous part of the code which is:

mysql_select_db($database_sadaes, $sadaes);
$query_temp_professor = "SELECT id, name, surname, email, FROM temp_professors WHERE id = $id";
$temp_professor = mysql_query($query_temp_professor, $sadaes) or die(mysql_error());
$row_temp_professor = mysql_fetch_assoc($temp_professor);
$totalRows_temp_professor = mysql_num_rows($temp_professor);
$temp_name=$row_temp_professor['name'] . " " . $row_temp_professor['surname'];
$temp_email=$row_temp_professor['email'];

this is the same table that is being accessed and i think it might have a lock on it.

The error i get from the server is:
You have an error in your SQL syntax near 'FROM temp_professors WHERE id = 1' at line 1

Note also that the query runs fine in mysql.
 
hi,
i just found an extra semicolumn after email in ur query.

$query_temp_professor = "SELECT id, name, surname, email, FROM temp_professors WHERE id = $id";


if u remove it that shd be ok.

spookie
--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
ur query is
$deleteSQL="DELETE FROM temp_professors WHERE id='$id'";

while the error is
You have an error in your SQL syntax near 'FROM temp_professors WHERE id = 1' at line 1

how come 'id=1' is not 'id='1''

it maybe that mysql has a different delete syntax?

 
The error is in this line:
$query_temp_professor = "SELECT id, name, surname, email, FROM temp_professors WHERE id = $id"; and occurs at the comma after "email".

The poster didn't pay enough attention to the line number the die() error message output. He had me confused for some time. Want the best answers? Ask the best questions: TANSTAAFL!
 
use this
$query_temp_professor = "SELECT id, name, surname, email FROM temp_professors WHERE id = $id";

there must be no comma before the word FROM.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top