php-windows Digest 14 Oct 2006 10:44:52 -0000 Issue 3057
Topics (messages 27236 through 27242):
Re: Checking for result of call to mssql_query()
27236 by: Alf Stockton
27237 by: Alf Stockton
27238 by: Alf Stockton
Re: @mssql_connect() versus mssql_connect()
27239 by: Bill Bolte
27241 by: tg-php.gryffyndevelopment.com
PHP Fatal error: Cannot redeclare class - high traffic.
27240 by: iestyn lloyd
Re: Unicode data w/ PDO DBLIB, MSSQL
27242 by: Alex Turner
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
Niel Archer wrote:
> Hi Alf
>
> You'd be better off asking this type of question in the database list.
> I'm not familiar with MS-SQL, the syntax doesn't look much different to
> the MySQL flavour.
>
> When you say " whether the query works or not" do you mean the query is
> failing with an error, or it simply returns no data? I'd suggest you
> test for TRUE first to determine if the query suceeded, but returned no
> data. If that fails, test for FALSE.
>
>
The problem is that the code if ($Reply == FALSE) does what I expect
with mysql but not with mssql.
I will test the other way around and see what happens.
i.e. if (!$Reply) {
........error message.......
}
--
Regards,
Alf Stockton www.stockton.co.za
Q: "What is the burning question on the mind of every dyslexic
existentialist?"
A: "Is there a dog?"
My email disclaimer is available at www.stockton.co.za/disclaimer.html
--- End Message ---
--- Begin Message ---
Alf Stockton wrote:
> Niel Archer wrote:
>
>> Hi Alf
>>
>> You'd be better off asking this type of question in the database list.
>> I'm not familiar with MS-SQL, the syntax doesn't look much different to
>> the MySQL flavour.
>>
>> When you say " whether the query works or not" do you mean the query is
>> failing with an error, or it simply returns no data? I'd suggest you
>> test for TRUE first to determine if the query suceeded, but returned no
>> data. If that fails, test for FALSE.
>>
>>
>>
> The problem is that the code if ($Reply == FALSE) does what I expect
> with mysql but not with mssql.
> I will test the other way around and see what happens.
> i.e. if (!$Reply) {
> ........error message.......
> }
>
>
Nope I get the same result......:-(
--
Regards,
Alf Stockton www.stockton.co.za
Your lover will never wish to leave you.
My email disclaimer is available at www.stockton.co.za/disclaimer.html
--- End Message ---
--- Begin Message ---
Alf Stockton wrote:
> Niel Archer wrote:
>
>> Hi Alf
>>
>> You'd be better off asking this type of question in the database list.
>> I'm not familiar with MS-SQL, the syntax doesn't look much different to
>> the MySQL flavour.
>>
>>
I do not believe that I am misunderstanding MSSQL. What I am not
understanding is the PHP function, mssql_query(). MSSQL is doing exactly
what I want.
--
Regards,
Alf Stockton www.stockton.co.za
Your lover will never wish to leave you.
My email disclaimer is available at www.stockton.co.za/disclaimer.html
--- End Message ---
--- Begin Message ---
The @ is for error suppression
-----Original Message-----
From: Alf Stockton [mailto:[EMAIL PROTECTED]
Sent: Friday, October 13, 2006 12:00 AM
To: php-windows
Subject: [PHP-WIN] @mssql_connect() versus mssql_connect()
What is the difference between @mssql_connect() and mssql_connect()?
i.e. What is the relevance of the prefixed @?
--
Regards,
Alf Stockton www.stockton.co.za
You may my glories and my state dispose, But not my griefs; still am I
king of those.
-- William Shakespeare, "Richard II"
My email disclaimer is available at www.stockton.co.za/disclaimer.html
--
PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
As mentioned, the @ suppresses any errors, warnings, notices, etc that the
command will give. This is typically considered really bad programming
practice.
If you resort to using an @ to suppress, one of two things is an issue:
1. Either error reporting is set to high and you're getting warnings and
notices when you don't want to... in which case you can just turn down the
error reporting a bit.
2. Or there's an error and instead of trying to fix the error and program
correctly, the programmer choses to just bury the error. Which isn't so good.
The only time I've ever had to use @ to suppress an error was with an fgets()
call that produced the following error:
"Warning: fgets(): SSL: fatal protocol error in /var/www/secure/scriptname.php"
I didn't save the link to the bug, but it's apparently a bug in PHP and the
only solution I found was to suppress the error and everything works fine
(despite the warning).
-TG
= = = Original message = = =
The @ is for error suppression
-----Original Message-----
From: Alf Stockton [mailto:[EMAIL PROTECTED]
Sent: Friday, October 13, 2006 12:00 AM
To: php-windows
Subject: [PHP-WIN] @mssql_connect() versus mssql_connect()
What is the difference between @mssql_connect() and mssql_connect()?
i.e. What is the relevance of the prefixed @?
--
Regards,
Alf Stockton~~www.stockton.co.za
You may my glories and my state dispose, But not my griefs; still am I
king of those.
~~-- William Shakespeare, "Richard II"
My email disclaimer is available at www.stockton.co.za/disclaimer.html
--
PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.
--- End Message ---
--- Begin Message ---
Hi List,
First post, hope this is alright :)
I'm running: Windows Server 2003, IIS 6.0, PHP 5.1.4 (ISAPI), AMFPHP
1.2.5, MySQL 5.0.24.
The box is getting a *lot* of hits. A gateway PHP file is being called
about 1,000,000 times per day.
I've got error logging enabled, and I find there's a lot of:
"PHP Fatal error: Cannot redeclare class encrypt" This is not the
gateway, but another file that is called a lot.
I've been assured by the coder, who has checked the code time and time
again that it is *not* a problem with his code.
The problem only seems to occur when the server is at peak load, with
the file perhaps being called 40 times a second.
Has anyone encountered this on a similar setup?
I'm also getting quite a few " PHP Fatal error: Maximum execution
time of 60 seconds exceeded " on mysql_connect statements, but this
appears to be a separate issue, which i'm also looking into.
Thanks for any advice,
cheers
iestyn
--- End Message ---
--- Begin Message ---
Mike Matz wrote:
Is there currently any way to retrieve Unicode data from SQL Server?
I'm working with SQL Server Express 2005, on a database that's been
restored from an old SQL Server 2000 database. I'm writing a PHP script
that imports data from the MSSQL database, processes it, and adds it to
a MySQL database with a different schema. So far I've been unable to do
this reliably, as there is a lot of multilingual, Unicode data in the
MSSQL database. I'm trying to use the PDO method of database access,
but could fall back on another method if this is impossible. I'm able
to connect to my database using either ODBC or DBLIB MSSQL drivers.
When using DBLIB, I get an error:
$db = new PDO('mssql:host=\\\\.\pipe\sql\query;dbname=my_db', $user,
$pass);
$sth = $db->execute("SELECT * FROM Products");
$sth->execute();
print_r($sth->fetchAll());
gives me this exception:
Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[HY000]: General error: 10007 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. [10007] (severity 5) [(null)]'
When using ODBC, I get very strange results. There are no errors or
exceptions, but in every row, all columns following the first
text/unicode column will be empty. For example, if I SELECT Product_ID,
Short_Description, Product_Season (Short_Description being TEXT,
possibly with unicode), Product_Season will be empty. However, if I
SELECT Product_ID, Product_Season, Short_Description -- I'll get the
Product_Season. Short_Description is empty in both cases (even if it's
not empty when viewing with SQL Query Analyzer).
Has anyone seen this behavior or have any ideas as to what I should try?
Thanks,
Mike
Mike,
The ODBC issue is probably due to C thinking the 0's in the unicode mean
'end of string'.
My suggestion is to pass that data to SQLServer as binary and convert it
to nchar or nvarchar on the fly in the SQL engine its self using a
convert statement.
I come across trouble like this all the time :-( The trick is generally
to avoid using strings to handle mixed language data, pass it around as
binary all the time and life gets a lot easier.
Also - I would highly recommend using ADODB to talk to SQL server not
ODBC or the php specific stuff. For example, here is how to connect to
a server
$obj=new COM('ADODB.connection');
if(!$obj->pinned())
{
$obj->open("Provider=SQLOLEDB.1;Server=$server;Database=$database;UID=$username;PWD=$password;");
$obj->pin();
}
and to get a result set
/** This function returns a connected ADODB.RecordSet given a
* connection and some SQL.
*/
function ExecuteQuery($sql,&$connection)
{
$recordsAffected=0;
return $connection->Execute($sql, $recordsAffected, 8);
}
finally, to turn a PHP string to hex example:
$datum='0x'.bin2hex($datum);
$sql=
"
IF EXISTS(SELECT RowId FROM T_Data WHERE RowId=$id)
BEGIN
UPDATE T_Data SET Datum=$datum WHERE RowId=$id
END
ELSE
BEGIN
INSERT INTO T_Data (RowId,Datum) VALUES ($id,$datum)
END
";
ADODB::Execute($sql,$this->connection);
Please note that PHP strings can hold unicode but not all php string
functions work with unicode data because some assume strings to be 0
terminated.
Good luck
AJ
--
www.deployview.com
www.nerds-central.com
www.funkifunctions.com
www.project-network.com
--- End Message ---