Delete all NULL characters.

Status
Not open for further replies.
Joined
Dec 4, 2007
Messages
2,502
Reaction score
987
Wrote a PHP script to do it. Just fill in the needed variables, then navigate with your browser to the page and it should execute.

Please note that anyone that knows the path can execute it, there's no security.

The script:
PHP:
<?php
//Written by Wizkid
//Copyright 2008 - 2009

//Let us connect the databases.
//Yeah yeah, ODBC this time.
$host = "PETER-18BEFA497\SQLEXPRESS"; //The host.
$user = "SA"; //The username.
$pass = "password"; //The password. I hope it's unique for you.
$dbname = "GunzDB"; //The dbname. Most likely GunzDB.

$connect = odbc_connect("Driver={SQL Server};Server={$host}; Database={$dbname}", $user, $pass) or die("Can't connect the MSSQL server.");

//The num_rows() function for ODBC since the default one always returns -1.
function num_rows(&$rid) {

//We can try it at least, right?
$num= odbc_num_rows($rid);
if ($num >= 0) {
return $num;
}

if (!odbc_fetch_row($rid, 1)) {
odbc_fetch_row($rid, 0);
return 0;
}

if (!odbc_fetch_row($rid, 2)) {
odbc_fetch_row($rid, 0);
return 1;
}

$lo= 2;
$hi= 8192000;

while ($lo < ($hi - 1)) {
$mid= (int)(($hi + $lo) / 2);
if (odbc_fetch_row($rid, $mid)) {
$lo= $mid;
} else {
$hi= $mid;
}
}
$num= $lo;
odbc_fetch_row($rid, 0);
return $num;
}

//Query time.
$query = odbc_exec($connect,"SELECT CID FROM Character WHERE Name = ''");
$count = num_rows($query);

while(odbc_fetch_row($query))
{
    $cid = odbc_result($query, 1);
    
    odbc_exec($connect,"DELETE FROM CharacterItem WHERE CID = '" . $cid . "'");
    odbc_exec($connect,"DELETE FROM Character WHERE CID = '" . $cid . "'");
    
    echo "Removed the character with CID " . $cid . ". <br />";
}

echo $count . " characters have been totally removed out of the database.";
?>

Might be a helpfull script.
 
why u use ODBC?? u just make it more difficult :S

If you want to search a few hours to find the right ntwdlib.dll, then config your php.ini to load the mssql extension and then get begged by a lot of noobs that it "doesn't work because of mssql_connect", feel free to use the mssql_connect.

Otherwise, use ODBC like I did. Works faster, smoother.
 
If you want to search a few hours to find the right ntwdlib.dll, then config your php.ini to load the mssql extension and then get begged by a lot of noobs that it "doesn't work because of mssql_connect", feel free to use the mssql_connect.

Otherwise, use ODBC like I did. Works faster, smoother.

/agree.

If you get a error with ODBC you just need to make a system-dns.. E/z :) mssql_connect sucks :p
 
Thanks wizkid <3 :D

Error :


Code:
Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]The DELETE statement conflicted with the REFERENCE constraint "Character_PurchaseItemByBountyHistory_FK20050314". The conflict occurred in database "GunzDB", table "dbo.ItemPurchaseLogByBounty", column 'CID'., SQL state 23000 in SQLExecDirect in C:\xampp\htdocs\clear.php on line 58
Removed the character with CID 32.

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]The DELETE statement conflicted with the REFERENCE constraint "Character_PurchaseItemByBountyHistory_FK20050314". The conflict occurred in database "GunzDB", table "dbo.ItemPurchaseLogByBounty", column 'CID'., SQL state 23000 in SQLExecDirect in C:\xampp\htdocs\clear.php on line 58
Removed the character with CID 103.

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]The DELETE statement conflicted with the REFERENCE constraint "Character_PurchaseItemByBountyHistory_FK20050314". The conflict occurred in database "GunzDB", table "dbo.ItemPurchaseLogByBounty", column 'CID'., SQL state 23000 in SQLExecDirect in C:\xampp\htdocs\clear.php on line 58
Removed the character with CID 144.

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]The DELETE statement conflicted with the REFERENCE constraint "Character_PurchaseItemByBountyHistory_FK20050314". The conflict occurred in database "GunzDB", table "dbo.ItemPurchaseLogByBounty", column 'CID'., SQL state 23000 in SQLExecDirect in C:\xampp\htdocs\clear.php on line 58
Removed the character with CID 172.

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]The DELETE statement conflicted with the REFERENCE constraint "Character_PurchaseItemByBountyHistory_FK20050314". The conflict occurred in database "GunzDB", table "dbo.ItemPurchaseLogByBounty", column 'CID'., SQL state 23000 in SQLExecDirect in C:\xampp\htdocs\clear.php on line 58
Removed the character with CID 251.
5 characters have been totally removed out of the database.

However a lot of NULL characters have been removed, except theres still loads more.
 
same, please help me fix

Code:
Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]The DELETE statement conflicted with the REFERENCE constraint "Character_PurchaseItemByBountyHistory_FK20050314". The conflict occurred in database "GunzDB", table "dbo.ItemPurchaseLogByBounty", column 'CID'., SQL state 23000 in SQLExecDirect in C:\xampp\htdocs\clear.php on line 58
Removed the character with CID 32.

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]The DELETE statement conflicted with the REFERENCE constraint "Character_PurchaseItemByBountyHistory_FK20050314". The conflict occurred in database "GunzDB", table "dbo.ItemPurchaseLogByBounty", column 'CID'., SQL state 23000 in SQLExecDirect in C:\xampp\htdocs\clear.php on line 58
Removed the character with CID 103.

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]The DELETE statement conflicted with the REFERENCE constraint "Character_PurchaseItemByBountyHistory_FK20050314". The conflict occurred in database "GunzDB", table "dbo.ItemPurchaseLogByBounty", column 'CID'., SQL state 23000 in SQLExecDirect in C:\xampp\htdocs\clear.php on line 58
Removed the character with CID 144.

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]The DELETE statement conflicted with the REFERENCE constraint "Character_PurchaseItemByBountyHistory_FK20050314". The conflict occurred in database "GunzDB", table "dbo.ItemPurchaseLogByBounty", column 'CID'., SQL state 23000 in SQLExecDirect in C:\xampp\htdocs\clear.php on line 58
Removed the character with CID 172.

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]The DELETE statement conflicted with the REFERENCE constraint "Character_PurchaseItemByBountyHistory_FK20050314". The conflict occurred in database "GunzDB", table "dbo.ItemPurchaseLogByBounty", column 'CID'., SQL state 23000 in SQLExecDirect in C:\xampp\htdocs\clear.php on line 58
Removed the character with CID 251.
5 characters have been totally removed out of the database.
However a lot of NULL characters have been removed, except theres still loads more.
 
If you want to search a few hours to find the right ntwdlib.dll, then config your php.ini to load the mssql extension and then get begged by a lot of noobs that it "doesn't work because of mssql_connect", feel free to use the mssql_connect.

Otherwise, use ODBC like I did. Works faster, smoother.
fasteR? :S mmm well rlly i dont know wich is the diff of conecting the php to mssql with the little .dll than using the ODBC conectors :/ pls help me with that
 
Thanks wizkid <3 :D

Error :


Code:
Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]The DELETE statement conflicted with the REFERENCE constraint "Character_PurchaseItemByBountyHistory_FK20050314". The conflict occurred in database "GunzDB", table "dbo.ItemPurchaseLogByBounty", column 'CID'., SQL state 23000 in SQLExecDirect in C:\xampp\htdocs\clear.php on line 58
Removed the character with CID 32.

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]The DELETE statement conflicted with the REFERENCE constraint "Character_PurchaseItemByBountyHistory_FK20050314". The conflict occurred in database "GunzDB", table "dbo.ItemPurchaseLogByBounty", column 'CID'., SQL state 23000 in SQLExecDirect in C:\xampp\htdocs\clear.php on line 58
Removed the character with CID 103.

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]The DELETE statement conflicted with the REFERENCE constraint "Character_PurchaseItemByBountyHistory_FK20050314". The conflict occurred in database "GunzDB", table "dbo.ItemPurchaseLogByBounty", column 'CID'., SQL state 23000 in SQLExecDirect in C:\xampp\htdocs\clear.php on line 58
Removed the character with CID 144.

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]The DELETE statement conflicted with the REFERENCE constraint "Character_PurchaseItemByBountyHistory_FK20050314". The conflict occurred in database "GunzDB", table "dbo.ItemPurchaseLogByBounty", column 'CID'., SQL state 23000 in SQLExecDirect in C:\xampp\htdocs\clear.php on line 58
Removed the character with CID 172.

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]The DELETE statement conflicted with the REFERENCE constraint "Character_PurchaseItemByBountyHistory_FK20050314". The conflict occurred in database "GunzDB", table "dbo.ItemPurchaseLogByBounty", column 'CID'., SQL state 23000 in SQLExecDirect in C:\xampp\htdocs\clear.php on line 58
Removed the character with CID 251.
5 characters have been totally removed out of the database.

However a lot of NULL characters have been removed, except theres still loads more.

I Have The Same Problem QQ :'(!
 
Error:

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]The DELETE statement conflicted with the REFERENCE constraint "Character_Friend_FK1". The conflict occurred in database "GunzDB", table "dbo.Friend", column 'CID'., SQL state 23000 in SQLExecDirect in E:\Domains\xxxx\xxx\delChar.php on line 58
 
Error:

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]The DELETE statement conflicted with the REFERENCE constraint "Character_Friend_FK1". The conflict occurred in database "GunzDB", table "dbo.Friend", column 'CID'., SQL state 23000 in SQLExecDirect in E:\Domains\xxxx\xxx\delChar.php on line 58

And DELETE FROM Friend.... and and and.. fill in yourself.
 
Status
Not open for further replies.
Back