Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL Insert works, SQL delete doesn't

Author  Topic 

ITdevGirl
Starting Member

3 Posts

Posted - 2012-06-22 : 12:10:41
Hello,

I am new to this forum and I was wondering if you could help me. I have a website I am working on a database for, and to insert new data into the table is not a problem, even to output the table isn't an issue.

But a delete query won't work and it doesn't return any errors or echo commands that I put in the steps of the logic.

Should I include my code

Many Thanks

xhostx
Constraint Violating Yak Guru

277 Posts

Posted - 2012-06-22 : 12:33:42
quote:
Originally posted by ITdevGirl

Hello,

I am new to this forum and I was wondering if you could help me. I have a website I am working on a database for, and to insert new data into the table is not a problem, even to output the table isn't an issue.

But a delete query won't work and it doesn't return any errors or echo commands that I put in the steps of the logic.

Should I include my code

Many Thanks



Could you please paste some of your script so that we can see what you have there.

Thanks,

kml
Go to Top of Page

ITdevGirl
Starting Member

3 Posts

Posted - 2012-06-22 : 12:35:50
<?php
if($errors == 0)
{
echo "success1!\n";
$DBConnect = @mysql_connect("db.start.ca", "nokeekwe", "1rcPass");
if($DBConnect === FALSE)
{
echo "<p>Unable to connect. " .
"Error code " . mysql_errno() . ": " .
mysql_error() . "</p>\n";
$errors++;
}
else
{
echo "success2!\n";
$DBName = "nokeekwe";
$result = @mysql_select_db($DBName, $DBConnect);
if($result === FALSE)
{
echo "<p>Unable to select DB. " .
"Error code " . mysql_errno($DBConnect) .
": " . mysql_error($DBConnect) .
"</p>\n";
$errors++;
}
}
}
if($errors > 0)
{

echo "<p>Please use your browser's BACK button" .
" to return to the form and fix your errors.</p>\n";
}
echo "success3!\n";
if($errors == 0)
{

echo "success4!\n";
if(isset($_COOKIE['jobID']))
{
$TableName = "tbljobs";
$SQLstring = "DELETE $TableName.* FROM $TableName WHERE $TableName.jobID = {$_COOKIE['jobID']}";
$QueryResult = @mysql_query($SQLstring, $DBConnect);
echo "success5!" . $_COOKIE['jobID'] . "\n";
if($QueryResult === FALSE)
{
echo "<p>Unable to save your review. " .
" Error code " .
mysql_errno($DBConnect) . ": " .
mysql_error($DBConnect) . "</p>\n";

$errors++;
}
else
{
echo "success!\n";
}
}
}
}
}
?>

this is a form action page using the method request from a php page that shows the table contents with 2 forms that include two buttons: one form has a delete button and one form that includes an edit button.

Non of the echo commands show and no errors are outputted either.
Go to Top of Page

xhostx
Constraint Violating Yak Guru

277 Posts

Posted - 2012-06-22 : 13:00:14
hi,

Try and test $SQLstring = "DELETE * FROM $TableName WHERE $TableName.jobID = {$_COOKIE['jobID']}";


Question: is this a Microsoft SQL database? if so, which version?

Thanks

kml
Go to Top of Page

ITdevGirl
Starting Member

3 Posts

Posted - 2012-06-22 : 13:08:04
Server version: 5.1.50-log
Protocol version: 10
MySQL client version: 5.0.27
Used PHP extensions: mysql

changed line to: $SQLstring = "DELETE * FROM $TableName WHERE $TableName.jobID = {$_COOKIE['jobID']}";
still blank page follows without any of the echo commands and therefore I can't even check if $_COOKIE['jobID'] has the right or any value at all...what could be the reason?
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2012-06-22 : 14:08:00
This is a Microsoft SQL SERVER site. You might have better luck with these guys: http://www.dbforums.com/mysql/








How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Go to Top of Page

bitsmed
Aged Yak Warrior

545 Posts

Posted - 2012-06-22 : 17:10:17
syntax for delete in all sql databases I have come a cross is:

delete from table where ....
Go to Top of Page
   

- Advertisement -