Jump to content

error handling PHP and MSSQL


ashleek007

Recommended Posts

Hi All,

 

I'm running some queries to add information to a MS-SQL DB like this: -

 

$new_page = "INSERT INTO **** (url, section, morder, mtext) VALUES ('$new_url_1', '$menu', '$menu_pos', '$mtext')";   
$new_page_result = mssql_query($new_page);
if (!$new_page_result) { 
$delete_content = "DELETE FROM **** WHERE cid = '$cid'";
$delete_result = mssql_query($delete_content);	
$domain="database-error.php?err=there was an error writing to the table";  
header('Location:'. $domain);
}

 

The idea is to quit the SQL statement if an error occurs, delete everything that has happened before the statement and re-direct the user to an error page...

 

For some reason it doesnt work though, and I have no idea why... any clues?

 

Ash ???

Link to comment
https://forums.phpfreaks.com/topic/60175-error-handling-php-and-mssql/
Share on other sites

hey,

 

this throws an error: -

 

Warning: Wrong parameter count for mssql_rows_affected() in content-add-page-1.php on line 154

 

im trying to force the error... like this

 

$new_content = "INSERTXXX INTO xxxx (content, title, menu_category, downloadonly) VALUES ('$content', '$mtext', '$menu', '0')"; 

$new_content_result = mssql_query($new_content);

if (mssql_rows_affected() == 0) {

$domain="database-error.php"; 

header('Location:'. $domain);

}

 

thanks for the help so far

Ash

 

 

sorry a different error still shows: -

 

Warning: mssql_rows_affected(): supplied argument is not a valid MS SQL-Link resource

 

with this...

 

$new_content = "INSERTXXX INTO xxx (content, title, menu_category, downloadonly) VALUES ('$content', '$mtext', '$menu', '0')"; 

$new_content_result = mssql_query($new_content);

if (mssql_rows_affected($new_content_result) == 0) {

$domain="database-error.php"; 

header('Location:'. $domain);

}

 

Cheers,

Ash

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.