SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL Insert works, SQL delete doesn't
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ITdevGirl
Starting Member

Canada
3 Posts

Posted - 06/22/2012 :  12:10:41  Show Profile  Reply with Quote
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

USA
261 Posts

Posted - 06/22/2012 :  12:33:42  Show Profile  Reply with Quote
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

Canada
3 Posts

Posted - 06/22/2012 :  12:35:50  Show Profile  Reply with Quote
<?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

USA
261 Posts

Posted - 06/22/2012 :  13:00:14  Show Profile  Reply with Quote
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

Canada
3 Posts

Posted - 06/22/2012 :  13:08:04  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

2111 Posts

Posted - 06/22/2012 :  14:08:00  Show Profile  Reply with Quote
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
Yak Posting Veteran

Denmark
98 Posts

Posted - 06/22/2012 :  17:10:17  Show Profile  Reply with Quote
syntax for delete in all sql databases I have come a cross is:

delete from table where ....
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.28 seconds. Powered By: Snitz Forums 2000