~ overflow ~

Archive for July, 2009

MSSQL+PHP = Issues

by z3n on Jul.21, 2009, under Coding

Problem:

On a simple MSSQL (Microsoft SQL Server) with PHP you get this error:

Warning: mssql_query() [function.mssql-query]: message: Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier. (severity 16)

and the best, it dosen’t matter if you convert the data to a different type.P>

Solution:

It looks like that mssql library at php can’t handle the ntext objects right, or at least the way you’re calling it is not right, the ONG>wrong way is:

function _connect_mssql() {
global $_msql,$_msql_id;
if (!$_msql_id) {
if ($_msql=mssql_connect(dbserver,dbuser,dbpass)) {
mssql_select_db(db,$_msql) or die("Unable to select database: ".db);
$_msql_id=1;
} else {
die("Couldn’t connect to database");R> }
$_msql_id=1;
}
}
function _qm($sql) {
global $res,$_msql,$_msql_id;
if (!$_msql_id) { _connect_mssql(); }
$res=mssql_query($sql,$_msql);
if (!$res) { die("Error on query: ".$sql); }
}

Those are simple functions to call it without using a class or too much paraphernalia. And it doesn’t work when the table has a ntext column on it, now a function that works with any type of table:P>

function _connect_mssql() {
global $_msql,$_msql_id;
if (!$_msql_id) {
$_msql=new COM("ADODB.Connection");
$_msql->Open("Provider=SQLOLEDB.1;Password=".dbpass.";Persist Security Info=True;User ID=".dbuser.";Initial Catalog=".db.";Data Source=".dbserver);
$_msql_id=1;
}
}
function _qm($sql) {
global $res,$_msql,$_msql_id;
if (!$_msql_id) { _connect_mssql(); }
$res=$_msql->Execute($sql);
if (!$res) { die("Error on query: ".$sql); }
}

$_msql="";$_msql_id=0;

Note that I used a class and ADODB connection instead, this works prefectly.

Leave a Comment :, , , , more...

Linux Nice/Renice Note

by z3n on Jul.16, 2009, under Linux Happyness, Notes

It’s odd, but I though that the higher the nice number was higher was the priority of a process, turns out that I was wrong, it’s the inverse.

Example: Priority 20 is the default lowest priority, while 0 is the normal priority. There’s also negative values to force a higher priority.

Besides the priority values, I haven’t found anything about cpu affinity, however, I didn’t tried hard, since the machine I’m running linux is single core anyway.

Leave a Comment :, , more...

MySQL Procedures Not Working

by z3n on Jul.14, 2009, under Tips & Hints

Problem:

Somehow a procedure that works on MySQL 5.0.77 don’t work on a 5.1.32, when inserted it simply gives an error without specifying anything.

Solution:

As stated on here, you need to run mysql_upgrade in order to have it working right. Not stated clearly on mysql documentation or whatever, good thing i came across this posting :)

Leave a Comment :, , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!