RE: [PHP] NULL Problem

2012-04-24 Thread David Stoltz

Serge,

We don't use MSSQL for much, mostly use MySQL...

But I don't want to switch out all the drivers for this one issue, which is now 
resolved (thanks Matijn)


-Original Message-
From: Serge Fonville [mailto:serge.fonvi...@gmail.com] 
Sent: Tuesday, April 24, 2012 1:45 PM
To: Matijn Woudt
Cc: David Stoltz; php-general@lists.php.net
Subject: Re: [PHP] NULL Problem

Have you considered the PHP MSSQL driver?
http://www.microsoft.com/download/en/details.aspx?id=20098

Kind regards/met vriendelijke groet,

Serge Fonville

http://www.sergefonville.nl

Convince Google!!
They need to add GAL support on Android (star to agree)
http://code.google.com/p/android/issues/detail?id=4602


2012/4/24 Matijn Woudt :
> On Tue, Apr 24, 2012 at 7:29 PM, David Stoltz  wrote:
>> Here's my code (using MSSQL):
>>
>> $conn = new COM ("ADODB.Connection")or die("Cannot start ADO");
>> $conn->open($connStr);
>> $query = "SELECT * FROM TABLE WHERE id = ".$id;
>> $rs = $conn->execute($query);
>>
>> This code works fine, and I retrieve the values like this:
>>
>> $tmp1 = $rs->fields("column1");
>> $tmp2 = $rs->fields("column2");
>> Etc...
>>
>>
>> Here's the problem - I'm trying to get a date column that I know is
>> NULL, but I can't seem to get my code right:
>>
>> $tmp = $rs->fields("followup_on");
>> if(is_null($tmp)){
>>        $followup = "";
>> }else{
>>        $followup = $rs->fields("followup_on");
>> }
>>
>> //this results in: Catchable fatal error: Object of class variant could
>> not be converted to string
>> //When I try to ECHO the $followup results (and I know the database
>> value is NULL)
>>
>>
>> So confused - any advice?
>>
>
> It's been a long time ago I worked with ADO (Thank god), but shouldn't
> you echo $followup->value instead of $followup?
> If that's not working, try a var_dump($followup), so you can check
> exactly what it is.
>
> - Matijn
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] NULL Problem

2012-04-24 Thread David Stoltz
Matijn - it worked! Geez...

Strange - I don't need the ->value if it actually has a value, only if it's 
NULL...

But it works! Thanks!

-Original Message-
From: Matijn Woudt [mailto:tijn...@gmail.com] 
Sent: Tuesday, April 24, 2012 1:40 PM
To: David Stoltz
Cc: php-general@lists.php.net
Subject: Re: [PHP] NULL Problem

On Tue, Apr 24, 2012 at 7:29 PM, David Stoltz  wrote:
> Here's my code (using MSSQL):
>
> $conn = new COM ("ADODB.Connection")or die("Cannot start ADO");
> $conn->open($connStr);
> $query = "SELECT * FROM TABLE WHERE id = ".$id;
> $rs = $conn->execute($query);
>
> This code works fine, and I retrieve the values like this:
>
> $tmp1 = $rs->fields("column1");
> $tmp2 = $rs->fields("column2");
> Etc...
>
>
> Here's the problem - I'm trying to get a date column that I know is
> NULL, but I can't seem to get my code right:
>
> $tmp = $rs->fields("followup_on");
> if(is_null($tmp)){
>        $followup = "";
> }else{
>        $followup = $rs->fields("followup_on");
> }
>
> //this results in: Catchable fatal error: Object of class variant could
> not be converted to string
> //When I try to ECHO the $followup results (and I know the database
> value is NULL)
>
>
> So confused - any advice?
>

It's been a long time ago I worked with ADO (Thank god), but shouldn't
you echo $followup->value instead of $followup?
If that's not working, try a var_dump($followup), so you can check
exactly what it is.

- Matijn


[PHP] NULL Problem

2012-04-24 Thread David Stoltz
Here's my code (using MSSQL):

$conn = new COM ("ADODB.Connection")or die("Cannot start ADO");
$conn->open($connStr); 
$query = "SELECT * FROM TABLE WHERE id = ".$id;
$rs = $conn->execute($query);

This code works fine, and I retrieve the values like this:

$tmp1 = $rs->fields("column1");
$tmp2 = $rs->fields("column2");
Etc...


Here's the problem - I'm trying to get a date column that I know is
NULL, but I can't seem to get my code right:

$tmp = $rs->fields("followup_on");
if(is_null($tmp)){
$followup = "";
}else{
$followup = $rs->fields("followup_on");
}

//this results in: Catchable fatal error: Object of class variant could
not be converted to string
//When I try to ECHO the $followup results (and I know the database
value is NULL)


So confused - any advice?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] mssql_bind question

2012-04-09 Thread David Stoltz
Folks,

Having a difficult time using mssql_bind with characters greater than
8000...the database field is set to ntext, and I've also tried
varchar(max), both seem to produce the same results:

If I use:
mssql_bind($stmt, '@mgrnotes',$mgrnotes,SQLVARCHAR,false,false,8000);

I get the error:
Warning: mssql_bind() [function.mssql-bind]: Unable to set parameter in
D:\Inetpub\wwwroot\folder\mypage.php on line 105

I discovered changing SQLVARCHAR to SQLTXT, and dropping the length of
8000 helps:
mssql_bind($stmt, '@mgrnotes',$mgrnotes,SQLTEXT,false,false);

I get no error, but the field is truncated to 8000 characters
regardless.

What is the correct way to use mssql_bind with strings of greater than
8000 characters?

Thanks!
Dave

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Returning a Recordset from a Funtion

2010-06-25 Thread David Stoltz
The only reasons are I'm a PHP newbie ;-)

I'm not really familiar with all the ways to hit a MS SQL server, this 
particular way always worked for me. It's not difficult to code, and has been 
working for years, so I've grown accustom to it.

There are only a few instances left to connect to MS MSQL for me, so it's not 
used too often - we're now developing with mySQL.

Thanks for the info.


-Original Message-
From: Andrew Ballard [mailto:aball...@gmail.com] 
Sent: Friday, June 25, 2010 10:38 AM
To: David Stoltz
Cc: php-general@lists.php.net
Subject: Re: [PHP] Returning a Recordset from a Funtion

On Fri, Jun 25, 2010 at 9:55 AM, David Stoltz  wrote:
> Hi Folks,
>
>
>
> Upon occasion, I have the need to hit our MS MSL database from our
> PHP/mySQL server. So I've created a function, but I'm not sure if you
> can return a recordset from a function. My code is below...
>
>
>
> In the calling page I code:
>
> 
> include('../includes/mssql.php');
>
> hitMSSQL("server","database","username","password","SELECT * FROM
> TABLE1");
>
> echo $rs->Fields(1);
>
> ?>
>
>
>
> The mssql.php include file is:
>
> 
> function hitMSSQL($server,$db,$login,$pass,$query){
>
>
>
>                $conn = new COM ("ADODB.Connection")
>
>                  or die("Cannot start ADO");
>
>                $connStr =
> "PROVIDER=SQLOLEDB;SERVER=".$server.",1433;UID=".$login.";PWD=".$pass.";
> DATABASE=".$db;
>
>                $conn->open($connStr);
>
>                $rs = $conn->execute($query);
>
>                return $rs;
>
>
>
> }
>
> ?>
>
>
>
> If I have the echo statement in the function, it works.
>
>
>
> And of course I can return a single value like:
>
> Return $rs-Fields("value");
>
>
>
> But I can't return the whole recordset...
>
>
>
> Does anyone have any good ideas so I can access the recordset in the
> calling page?
>
>
>
> Thanks!
>
>

Is there a reason you need to work with COM/ADODB to get the
information from SQL Server as opposed to one of the PHP libraries? If
your are using COM you must be running under Windows which means you
should be able to use Microsoft's SQL Server Driver for PHP, which is
the best tool I've seen to date for the task. There are also the older
mssql and the newer PDO_MSSQL libraries, or even odbc or PDO_ODBC that
will work OK in many cases as well. Any of these are much simpler to
work with than COM variants in PHP.

Andrew


RE: [PHP] Returning a Recordset from a Funtion

2010-06-25 Thread David Stoltz
Tried that - 

I finally got it - in the function I had to return the actual query execute, 
instead of the recordset.

This did not work:

$rs = $conn->execute($query);
Return $rs;

This DID work:

Return $conn->execute($query);

Thanks for the reply!

-Original Message-
From: Richard Quadling [mailto:rquadl...@gmail.com] 
Sent: Friday, June 25, 2010 9:59 AM
To: David Stoltz
Cc: php-general@lists.php.net
Subject: Re: [PHP] Returning a Recordset from a Funtion

On 25 June 2010 14:55, David Stoltz  wrote:
> 
> include('../includes/mssql.php');
>
> hitMSSQL("server","database","username","password","SELECT * FROM
> TABLE1");
>
> echo $rs->Fields(1);
>
> ?>

You are not catching the result of the hitMSSQL() function.

Try ...

Fields(1);

?>


-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling


[PHP] Returning a Recordset from a Funtion

2010-06-25 Thread David Stoltz
Hi Folks,

 

Upon occasion, I have the need to hit our MS MSL database from our
PHP/mySQL server. So I've created a function, but I'm not sure if you
can return a recordset from a function. My code is below...

 

In the calling page I code:

Fields(1);

?>

 

The mssql.php include file is:

open($connStr);

$rs = $conn->execute($query);

return $rs;



}

?>

 

If I have the echo statement in the function, it works. 

 

And of course I can return a single value like:

Return $rs-Fields("value");

 

But I can't return the whole recordset...

 

Does anyone have any good ideas so I can access the recordset in the
calling page?

 

Thanks!



RE: [PHP] PHP & Active Directory?

2010-06-21 Thread David Stoltz
Lol – ok…I guess it’s comparable to “it’s the bomb”….

 

Thanks ;-)

 

From: Nathan Nobbe [mailto:quickshif...@gmail.com] 
Sent: Monday, June 21, 2010 11:46 AM
To: David Stoltz
Cc: php-general@lists.php.net
Subject: Re: [PHP] PHP & Active Directory?

 

On Mon, Jun 21, 2010 at 9:42 AM, David Stoltz  wrote:

Awesome – thanks – BTW, what does “it’s the chronic” mean?

 

listen to some dr. dre or come visit me in denver, co :)

 

-nathan 



RE: [PHP] PHP & Active Directory?

2010-06-21 Thread David Stoltz
Awesome – thanks – BTW, what does “it’s the chronic” mean?

 

 

From: Nathan Nobbe [mailto:quickshif...@gmail.com] 
Sent: Monday, June 21, 2010 11:27 AM
To: David Stoltz
Cc: php-general@lists.php.net
Subject: Re: [PHP] PHP & Active Directory?

 

On Mon, Jun 21, 2010 at 8:59 AM, David Stoltz  wrote:

Folks,

I'm trying to validate an email address which is entered in a form field
against our Active Directory.

Does anyone have any "good" method of doing this?

 

try the adLDAP class - its the chronic

 

http://adldap.sourceforge.net/

 

-nathan 



[PHP] PHP & Active Directory?

2010-06-21 Thread David Stoltz
Folks,

 

I'm trying to validate an email address which is entered in a form field
against our Active Directory.

 

I'm using some PHP scripting supplied by http://phpad.sunyday.net/ but
it's not working, and the site doesn't seem to be supported anymore.

 

Does anyone have any "good" method of doing this?

 

Thanks for any info.

-Dave



RE: [PHP] Date Conversion Problem

2010-06-18 Thread David Stoltz
No Problem Shreyas,

 

My original PHP code was writing the date like this:

echo date('l jS \of F Y h:i:s A'); //  - Thursday 17th of June 2010
08:58:02 AM

 

I changed it to this:

echo date('n\/j\/Y h:i:s A');//   - 6/17/2010 08:58:02 AM

 

Now that it was writing to the database correctly, I ran the following
script below to update all the rows that were improperly formatted.
After the below script ran, I didn't even have to convert the column to
datetime, since the SQL convert statement would now easily convert the
string to date - although the proper thing to do would be to convert the
column to date/time type. 

 

The below script was written in classic ASP- I've added a commented out
string below each step so you can see the changes being made to the
string:

 

<%

'This script was used to convert invalid php dates into true date
formats in the DB

 

set conn = Server.CreateObject("ADODB.Connection")

conn.open = "My DB Conncetion String"

 

set rs = conn.execute("SELECT id, employee_signed_on FROM TABLE1 WHERE
employee_signed_on is not null")

 

do while not rs.eof

 

id = rs("id")

temp = rs("employee_signed_on")

oldDate = rs("employee_signed_on")

'''''''''''''''''''''''''''''''''''''Thursday 17th of
June 2010 08:58:02 AM

 

oldDate = replace(oldDate,"Monday ","")

oldDate = replace(oldDate,"Tuesday ","")

oldDate = replace(oldDate,"Wednesday ","")

oldDate = replace(oldDate,"Thursday ","")

oldDate = replace(oldDate,"Friday ","")

oldDate = replace(oldDate,"Saturday ","")

oldDate = replace(oldDate,"Sunday ","")

'''''''''''''''''''''''''''''''''''''17th of June 2010
08:58:02 AM



oldDate = replace(oldDate,"th of ","/")

oldDate = replace(oldDate,"nd of ","/")

oldDate = replace(oldDate,"st of ","/")

oldDate = replace(oldDate,"rd of ","/")

'''''''''''''''''''''''''''''''''''''17/June 2010
08:58:02 AM



oldDate = replace(oldDate,"January ","1/")

oldDate = replace(oldDate,"February ","2/")

oldDate = replace(oldDate,"March ","3/")

oldDate = replace(oldDate,"April ","4/")

oldDate = replace(oldDate,"May ","5/")

oldDate = replace(oldDate,"June ","6/")

oldDate = replace(oldDate,"July ","7/")

oldDate = replace(oldDate,"August ","8/")

oldDate = replace(oldDate,"September ","9/")

oldDate = replace(oldDate,"October ","10/")

oldDate = replace(oldDate,"November ","11/")

oldDate = replace(oldDate,"December ","12/")

'''''''''''''''''''''''''''''''''''''17/6/2010 08:58:02
AM



datetemp = split(oldDate,"/")

newMonth = datetemp(1)

newDay = datetemp(0)

    stuff = datetemp(2)



theNewDate = newMonth & "/" & newDay & "/" & stuff

'''''''''''''''''''''''''''''''''''''6/17/2010 08:58:02
AM

    

sql = "UPDATE TABLE1 SET employee_signed_on = '" &
theNewDate & "' WHERE id = " & id

   

RE: [PHP] Date Conversion Problem

2010-06-17 Thread David Stoltz
Thanks all - I've fixed the problem.

I fixed it by updating the php statement to write the date in a true SQL 
date-ready format. Then I updated the invalid rows.

Thanks all!


-Original Message-
From: Richard Quadling [mailto:rquadl...@gmail.com] 
Sent: Thursday, June 17, 2010 8:47 AM
To: David Stoltz
Cc: a...@ashleysheridan.co.uk; php-general@lists.php.net
Subject: Re: [PHP] Date Conversion Problem

On 17 June 2010 13:40, David Stoltz  wrote:
> I would agree with you, but I have no control on inherited web apps.
>
>
>
> I now need to concentrate on trying to fix this.
>
>
>
> From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk]
> Sent: Thursday, June 17, 2010 8:38 AM
> To: David Stoltz
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Date Conversion Problem
>
>
>
> On Thu, 2010-06-17 at 08:35 -0400, David Stoltz wrote:
>
>
> PHP newbie here...
>
>
>
> I have some PHP code writing the date/time into a MS SQL 2000 database
> like this:
>
>
>
> date('l jS \of F Y h:i:s A')
>
>
>
> So the text it writes into the DB is like: Thursday 15th of April 2010
> 10:13:42 AM
>
>
>
> The database field is defined as varchar, not datetime...so it's a
> string essentially...
>
>
>
> How in the world do I do a date conversion on this? I've tried things
> like:
>
>
>
> select * from table where convert(datetime,fieldname) >= '6/10/2010'
>
> (where fieldname is the string in question)
>
>
>
> Which results in "Syntax error converting datetime from character
> string."
>
>
>
> So I guess I have two questions:
>
>
>
> 1)      Can I write a SQL query that will convert this properly into a
> datetime?
>
> 2)      If not, I guess I'll need to change the code to write the date
> differently into the system, how should this statement be changed to
> allow for proper conversion? date('l jS \of F Y h:i:s A')
>
>
>
> Thanks for any help!
>
>
>
> It's best to store the date as a date rather than a string, as it avoids the 
> sorts of problems you're seeing now.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
>
>
>

The "fix" is most likely to be ...

1 - Convert the string date using PHP's strtotime() function to
populate a new column on the DB.
2 - Find the code that inserts/updates the date string and add the new
column to the insert/update statement.

That will preserve the current app and allow you to have the new
column for new work.

Just remember, if _YOU_ update the new column, you must also update
the original date string also.

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling


RE: [PHP] Date Conversion Problem

2010-06-17 Thread David Stoltz
Here's my approach to this problem, and how I am planning on fixing this - tell 
me what you think if this will work...

I need the format in the database to be "1/14/2010 3:25:58 PM"

There's not a ton of records that need to be updated, so I was going to:

1) Change the PHP function that is writing the date format incorrectly to the 
above format
2) Then manually go through the records and update the incorrect dates
3) Then change the datatype in the DB for that column from varchar to datetime

Far as I can see, this should work. 

This is why I hate inheriting other people's stuff...not to mention I'm a 
newbie, so that doesn't help ;-)

Thanks!


-Original Message-
From: Richard Quadling [mailto:rquadl...@gmail.com] 
Sent: Thursday, June 17, 2010 8:47 AM
To: David Stoltz
Cc: a...@ashleysheridan.co.uk; php-general@lists.php.net
Subject: Re: [PHP] Date Conversion Problem

On 17 June 2010 13:40, David Stoltz  wrote:
> I would agree with you, but I have no control on inherited web apps.
>
>
>
> I now need to concentrate on trying to fix this.
>
>
>
> From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk]
> Sent: Thursday, June 17, 2010 8:38 AM
> To: David Stoltz
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Date Conversion Problem
>
>
>
> On Thu, 2010-06-17 at 08:35 -0400, David Stoltz wrote:
>
>
> PHP newbie here...
>
>
>
> I have some PHP code writing the date/time into a MS SQL 2000 database
> like this:
>
>
>
> date('l jS \of F Y h:i:s A')
>
>
>
> So the text it writes into the DB is like: Thursday 15th of April 2010
> 10:13:42 AM
>
>
>
> The database field is defined as varchar, not datetime...so it's a
> string essentially...
>
>
>
> How in the world do I do a date conversion on this? I've tried things
> like:
>
>
>
> select * from table where convert(datetime,fieldname) >= '6/10/2010'
>
> (where fieldname is the string in question)
>
>
>
> Which results in "Syntax error converting datetime from character
> string."
>
>
>
> So I guess I have two questions:
>
>
>
> 1)      Can I write a SQL query that will convert this properly into a
> datetime?
>
> 2)      If not, I guess I'll need to change the code to write the date
> differently into the system, how should this statement be changed to
> allow for proper conversion? date('l jS \of F Y h:i:s A')
>
>
>
> Thanks for any help!
>
>
>
> It's best to store the date as a date rather than a string, as it avoids the 
> sorts of problems you're seeing now.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
>
>
>

The "fix" is most likely to be ...

1 - Convert the string date using PHP's strtotime() function to
populate a new column on the DB.
2 - Find the code that inserts/updates the date string and add the new
column to the insert/update statement.

That will preserve the current app and allow you to have the new
column for new work.

Just remember, if _YOU_ update the new column, you must also update
the original date string also.

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling


RE: [PHP] Date Conversion Problem

2010-06-17 Thread David Stoltz
I would agree with you, but I have no control on inherited web apps.

 

I now need to concentrate on trying to fix this.

 

From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: Thursday, June 17, 2010 8:38 AM
To: David Stoltz
Cc: php-general@lists.php.net
Subject: Re: [PHP] Date Conversion Problem

 

On Thu, 2010-06-17 at 08:35 -0400, David Stoltz wrote: 

 
PHP newbie here...
 
 
 
I have some PHP code writing the date/time into a MS SQL 2000 database
like this:
 
 
 
date('l jS \of F Y h:i:s A')
 
 
 
So the text it writes into the DB is like: Thursday 15th of April 2010
10:13:42 AM
 
 
 
The database field is defined as varchar, not datetime...so it's a
string essentially...
 
 
 
How in the world do I do a date conversion on this? I've tried things
like:
 
 
 
select * from table where convert(datetime,fieldname) >= '6/10/2010' 
 
(where fieldname is the string in question)
 
 
 
Which results in "Syntax error converting datetime from character
string."
 
 
 
So I guess I have two questions:
 
 
 
1)  Can I write a SQL query that will convert this properly into a
datetime?
 
2)  If not, I guess I'll need to change the code to write the date
differently into the system, how should this statement be changed to
allow for proper conversion? date('l jS \of F Y h:i:s A')
 
 
 
Thanks for any help!
 


It's best to store the date as a date rather than a string, as it avoids the 
sorts of problems you're seeing now.

Thanks,
Ash
http://www.ashleysheridan.co.uk



 



[PHP] Date Conversion Problem

2010-06-17 Thread David Stoltz
PHP newbie here...

 

I have some PHP code writing the date/time into a MS SQL 2000 database
like this:

 

date('l jS \of F Y h:i:s A')

 

So the text it writes into the DB is like: Thursday 15th of April 2010
10:13:42 AM

 

The database field is defined as varchar, not datetime...so it's a
string essentially...

 

How in the world do I do a date conversion on this? I've tried things
like:

 

select * from table where convert(datetime,fieldname) >= '6/10/2010' 

(where fieldname is the string in question)

 

Which results in "Syntax error converting datetime from character
string."

 

So I guess I have two questions:

 

1)  Can I write a SQL query that will convert this properly into a
datetime?

2)  If not, I guess I'll need to change the code to write the date
differently into the system, how should this statement be changed to
allow for proper conversion? date('l jS \of F Y h:i:s A')

 

Thanks for any help!



RE: [PHP] Security Issue

2010-06-08 Thread David Stoltz
allow_url_include is (or should be) disabled by default.

http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-
include

I can't think of one good reason to ever enable this, it would be a
security issue no matter how you slice it...

-Original Message-
From: Igor Escobar [mailto:titiolin...@gmail.com] 
Sent: Tuesday, June 08, 2010 10:11 AM
To: richg...@gmail.com
Cc: 
Subject: Re: [PHP] Security Issue

Hey Richard,

I'll find more about this parameter allow_url_include, thank you!


Regards,
Igor Escobar
Systems Analyst & Interface Designer

+ http://blog.igorescobar.com
+ http://www.igorescobar.com
+ @igorescobar (twitter)





On Mon, Jun 7, 2010 at 5:26 PM, richard gray  wrote:

> On 07/06/2010 20:00, Igor Escobar wrote:
>
>> PHP Injection is the technical name given to a security hole in PHP
>> applications. When this gap there is a hacker can do with an external
code
>> that is interpreted as an inner code as if the code included was more
a
>> part
>> of the script.
>>
>> // my code...
>> // my code...
>> include ('http:///externalhackscript.txt');
>> //my code...
>> //my code..
>>
> can you not switch off remote file includes in php.ini?
> This will stop include/require from a remote host..
> i.e. /allow_url_include = Off in php.ini
>
> HTH
> Rich
> /
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Security/Development Question

2010-04-28 Thread David Stoltz
Hi folks,

 

This isn't really a PHP question per se, but could apply to any
language...

 

I have a public facing web server, which we have a software component
that helps protect us from SQL Injection, and the like.

 

We recently have added a very small web application that is vendor
supported. They said it's not working, so I investigated. I found that
our software protection was blocking their pages because they are
actually passing entire SQL queries in their form POSTs. Now, the app is
SSL protected, and they claim the queries are not executed - only
inserted into the database to be used later. They also said it's
protected by the ASP.NET framework authenticationnot sure about any
of that.

 

My concern is passing SQL queries in this way is not best practice - am
I wrong? Please let me know how you would react to this?

 

See below for the stuff they are passing in the POST (obvious things
like table names have been changed):

 

/wEWBQLciq6UBwLEhISFCwLa2223bD3wK3+56LBAKc37iSDEsHMFjpB6o1vHld19wT+Tt3sY
8E&CRITICAL_RESULT&on&Declare @critical varchar (40)

set @critical = (select top 1 code from table where id = 'clr7' and
thename = 'critical')

 

sELECT 

 OPR_SECD.REC USER_REC_NO,

 RESULT.*, 

 (SELECT RESULT_DESC FROM table WHERE code = RESULT.RES_MSTR_CODE)
[DESC], 

 [ORDER].*, 

 (SELECT VALUE FROM table WHERE this_CODE = 'Email' AND USER_REC =
OPR_SECD.RECNUM) MBMD_EMAIL, 

 OPR_SECD.OPR_INITIAL 

 FROM RESULTING LEFT JOIN [ORDER] ON RESULTING.ORDER_REC =
[ORDERBY].RECNUM 

 LEFT JOIN OPR_SECD ON [ORDER].DR_CODE = OPR_SECD.XREF_CODE 

 where (RESULT.FLAG_TEXT) = @critical  AND RESULT.REC = @ID&Save



[PHP] str_replace help

2010-04-02 Thread David Stoltz
Hi folks,
 
In ASP, I would commonly replace string line feeds for HTML output like
this:
 
Var = replace(value,vbcrlf,"")
 
In PHP, the following doesn't seem to work:
$var = str_replace(chr(13),"\n",$value)
 
Neither does:
$var = str_replace(chr(10),"\n",$value)
 
What am I doing wrong?
 
Thanks!


RE: [PHP] Going from IIS6 to WAMP

2010-03-01 Thread David Stoltz
Even if I comment out what's in the include file, it still errors.

It's the actual "include" statement causing the error, not what's in it


-Original Message-
From: Robert Cummings [mailto:rob...@interjinn.com] 
Sent: Monday, March 01, 2010 1:33 PM
To: David Stoltz
Cc: php-general@lists.php.net
Subject: Re: [PHP] Going from IIS6 to WAMP

What does it do? Force the connection to https? if so you need to 
configure Apache to serve over https.




David Stoltz wrote:
> Hi All,
> 
> I have a working application in PHP 5.3 under IIS6. I've created a WAMP 
> server (Windows, Apache, MySQL, PHP) on a dedicated server, and I'm trying to 
> move the application to the new, dedicated server.
> 
> My first problem, the new server doesn't like this line of code in the 
> default.php:
> 
> 
> (It works fine on the current server)
> 
> If I remove the above line, the page shows fine. If the line is there, the 
> page cannot be displayed (not sure how to make it show the actual error, 
> since error logging is on, and error_reporting = E_ALL)
> 
> In the Apache httpd.conf file, I have the following:
> 
> DirectoryIndex default.php
> Options FollowSymLinks Includes
> Allow from all
> 
> 
> I'm assuming this allows "includes"
> 
> Does anyone have any idea?

-- 
http://www.interjinn.com
Application and Templating Framework for PHP


[PHP] Going from IIS6 to WAMP

2010-03-01 Thread David Stoltz
Hi All,

I have a working application in PHP 5.3 under IIS6. I've created a WAMP server 
(Windows, Apache, MySQL, PHP) on a dedicated server, and I'm trying to move the 
application to the new, dedicated server.

My first problem, the new server doesn't like this line of code in the 
default.php:


(It works fine on the current server)

If I remove the above line, the page shows fine. If the line is there, the page 
cannot be displayed (not sure how to make it show the actual error, since error 
logging is on, and error_reporting = E_ALL)

In the Apache httpd.conf file, I have the following:

DirectoryIndex default.php
Options FollowSymLinks Includes
Allow from all


I'm assuming this allows "includes"

Does anyone have any idea?


[PHP] Thread Safe?

2010-02-15 Thread David Stoltz
Hi all, 
 
I'm installing 5.3.1 on my Windows Server with IIS6.
 
Should I choose VC9 x86 Thread Safe or "non-thread safe" ?
 
What is the difference?
 
Thanks!


[PHP] PHP Upgrade Problem

2009-12-08 Thread David Stoltz
Folks,

I upgraded from PHP 5.2.6 to 5.3.1 on my test machine. Pretty easy, just
installed FastCGI for IIS6, installed PHP 5.3.1 and entered the .php ext
stuff into IIS6.

Now I tried it on my production box. No go. Although the web extension
"FastCGI Handler" can be enabled with no problems, PHP doesn't work. I
get an error in the application log:

EventID: 1000
Source: Application Error
Faulting application php-cgi.exe, version 5.3.1.0, faulting module
php5ts.dll, version 5.3.1.0, fault address 0x000f4d40.

Does anyone have any ideas?

Thanks!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] securing php pages

2009-11-20 Thread David Stoltz
You can use either cookies of sessions to maintain security:

Some pseudo code:

Login page:

Login successful? If yes, set session value "LOGIN" = "YES"

Then on all other pages, 1st check session value "LOGIN"if != "YES"
then bump them to the login page.

Make sense?

-Original Message-
From: nitin reddy [mailto:chintu.ni...@gmail.com] 
Sent: Friday, November 20, 2009 10:57 AM
To: php-general@lists.php.net
Subject: [PHP] securing php pages

Hi I am a new user of PHP..in my project i have put login forms and i am
able to login successful but the pages after the login can be accessed
directly by typing the address so if any one can help in this matter.


Thank you,

-- 
Nitin

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Upgrading PHP versions

2009-11-20 Thread David Stoltz
Bob - I checked the changelog - 99% of it are bug fixes

I don't see anything about 5.2.x features not being available as you
suggest.

But thanks for the reply.

-Original Message-
From: Bob McConnell [mailto:r...@cbord.com] 
Sent: Friday, November 20, 2009 10:50 AM
To: David Stoltz; php-general@lists.php.net
Subject: RE: [PHP] Upgrading PHP versions

Assumption 2 is invalid. You need to take a close look at the change
log. Many "features" from 5.2 are no longer available and will break
code that depends on them.

Bob McConnell

-Original Message-----
From: David Stoltz [mailto:dsto...@shh.org] 
Sent: Friday, November 20, 2009 10:50 AM
To: php-general@lists.php.net
Subject: [PHP] Upgrading PHP versions

Hi,

We are currently using PHP version 5.2.6. in production, and I'd like to
upgrade to the latest 5.3.1

My Assumptions:
- I can simply download the Windows binary file, and install it.
- None of the 5.2.6 code will break

Will there be a momentary interruption of web services during the
install? Will the current PHP applications stop working during the
upgrade?

Thanks for any info.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Thread Safe?

2009-11-20 Thread David Stoltz
Forgot to ask:

On the Windows download page, there are options like:

VC9 Thread Safe
VC9 Non-Thread Safe
VC6 Thread Safe
...etc

What is the VC, and what is thread safe?

Thanks!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Upgrading PHP versions

2009-11-20 Thread David Stoltz
Hi,

We are currently using PHP version 5.2.6. in production, and I'd like to
upgrade to the latest 5.3.1

My Assumptions:
- I can simply download the Windows binary file, and install it.
- None of the 5.2.6 code will break

Will there be a momentary interruption of web services during the
install? Will the current PHP applications stop working during the
upgrade?

Thanks for any info.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Date +30 comparison

2009-09-01 Thread David Stoltz
Ok, this is how I finally managed to get it to work - I'm sure there are
other ways, but this works:

//Check to make sure the next eval date is more than 30 days away

$d1 = date('Y-m-d', strtotime($todays_date . '+30 day'));
$d2 = date('Y-m-d', strtotime($nextdate));

if($d1>$d2){

echo "Sorry, your next evaluation date must be at least 30 days
away, Click BACK to continue.";
exit;

}


-Original Message-
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: Tuesday, September 01, 2009 12:43 PM
To: David Stoltz
Cc: php-general@lists.php.net
Subject: Re: [PHP] Date +30 comparison

On Tue, 2009-09-01 at 12:19 -0400, David Stoltz wrote:
> I'm really struggling with dates in PHP. (Yes, I tried reading the
> manual)...
> 
> Can someone provide code that does this:
> 
> Takes current date, assigns it to a variable (let's say $today)
> Then adds 30 days to $today variable
> Takes a string ($nexteval) like '8/26/2009' and compare it to $today.
> 
> The variable $nexteval must be greater than $today (which is today +
30
> days) or a message is echoed.
> 
> I'm finding this difficult to do, but I'm coming from an ASP
background.
> 
> Any help appreciated.
> 

PHP (like all languages I know) treats dates as numbers; and PHP
specifically uses seconds since January 1st 1970 (other languages
sometimes have different start points and can measure in milliseconds
instead). With this in mind, you can compare dates directly as you would
an integer, and the later date will be the higher value.

To add 30 days to a given date, you could use the date_add function
(http://uk2.php.net/manual/en/datetime.add.php ) which has various
formats you can use to add different time units.

Lastly, to turn a date like 8/26/2009, I would probably try to break it
down into it's component parts (maybe using explode('/', $string_date) )
and then using those values as arguments in a mktime() function. PHP
should automatically treat the values as integers if they are strings,
because like ASP, it uses loose typing on variables.

Thanks,
Ash
http://www.ashleysheridan.co.uk




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Date +30 comparison

2009-09-01 Thread David Stoltz
I'm really struggling with dates in PHP. (Yes, I tried reading the
manual)...

Can someone provide code that does this:

Takes current date, assigns it to a variable (let's say $today)
Then adds 30 days to $today variable
Takes a string ($nexteval) like '8/26/2009' and compare it to $today.

The variable $nexteval must be greater than $today (which is today + 30
days) or a message is echoed.

I'm finding this difficult to do, but I'm coming from an ASP background.

Any help appreciated.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Date Comparison

2009-08-28 Thread David Stoltz
Hey Stuart - 

RTFM yourselfI did read it, and obviously misunderstood...

I'm really sorry to bother you. I thought that was what a listserv like this 
was for - to ask questions...

I'll try not to ask questions I should know the answer to next time.


-Original Message-
From: Stuart [mailto:stut...@gmail.com] 
Sent: Friday, August 28, 2009 10:19 AM
To: David Stoltz
Cc: php-general@lists.php.net
Subject: Re: [PHP] Date Comparison

2009/8/28 David Stoltz :
> How to I ensure a variable date is not in the past, compared to the
> current date? Here's how I'm trying, unsuccessfully:
>
> $nextdate = "8/2/2009";
>
> if(strtotime($nextdate)<=getdate()){
>
>        echo "Sorry, your next evaluation date cannot be in the past,
> Click BACK to continue.";
>        exit;
>
> }

RTFM.

The strtotime function will give you a timestamp, getdate will give
you an array, so your comparison is non-sensical. Use the time
function to get the current date/time as a timestamp.

-Stuart

-- 
http://stut.net/


[PHP] Date Comparison

2009-08-28 Thread David Stoltz
How to I ensure a variable date is not in the past, compared to the
current date? Here's how I'm trying, unsuccessfully:

$nextdate = "8/2/2009";

if(strtotime($nextdate)<=getdate()){

echo "Sorry, your next evaluation date cannot be in the past,
Click BACK to continue.";
exit;

}

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Special Characters in a String for Output

2009-08-27 Thread David Stoltz
I have:

$goalString = "Goals Entered By ".$mymanager."On
".$when.":".$mygoal."";

Which outputs in this  tag:



But if there are double or single quotes in any of the $goalString, it
messes up the output.

I know this is a simple fix, but I'm not sure how to fix it since I'm
new to PHP...

I've tried addslashes, etc - but can't get it to work right...

Is there an easy way to escape ALL special characters that would cause
this output to fail?

Thanks!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Re: How to output a NULL field?

2009-08-27 Thread David Stoltz
You're a genius - that works!


-Original Message-
From: Bastien Koert [mailto:phps...@gmail.com] 
Sent: Wednesday, August 26, 2009 2:02 PM
To: Andrew Ballard
Cc: Shawn McKenzie; php-general@lists.php.net; David Stoltz
Subject: Re: [PHP] Re: How to output a NULL field?


One option then, might be to format the result with SQL using a CASE
WHEN THEN statement or ISNULL / IFNULL to set it to empty string

-- 

Bastien

Cat, the other other white meat

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] How to output a NULL field?

2009-08-26 Thread David Stoltz
Looking on Amazon and other book sites, I can't even find a book for
"PHP and MS SQL"...

It's all "PHP and MySQL"...

Should I avoid developing PHP application with MS SQL databases?


-Original Message-
From: Paul M Foster [mailto:pa...@quillandmouse.com] 
Sent: Wednesday, August 26, 2009 12:38 PM
To: php-general@lists.php.net
Subject: Re: [PHP] How to output a NULL field?

On Thu, Aug 27, 2009 at 12:25:35AM +0800, hack988 hack988 wrote:

> I'm sorry for my poor English,what is OP? I don't kown what is OP
mean.

OP = "Original Poster". That's usually the person who first started
(posted) a thread on a list.

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] How to output a NULL field?

2009-08-26 Thread David Stoltz
I'm using COM because I don't know what else to use ;-)

Like I said, I'm new to PHP. Here is another way I communicate with the 
database, let me know if this is a better way (it requires a stored procedure):

//Assign the server connection to a variable
$connect = mssql_connect(SERVER,1433', USER, 'PASSWORD');
 
//Select your database and reference the connection
mssql_select_db('DATABASE', $connect);

// Create a new stored prodecure
$stmt = mssql_init('StoredProcedureName');

// Bind the field names
mssql_bind($stmt, '@category',$cat,SQLINT4,false,false,4);
mssql_bind($stmt, '@userid',$userid,SQLINT4,false,false,4);
mssql_bind($stmt, '@passwordtitle',$pname,SQLVARCHAR,false,false,100);
mssql_bind($stmt, '@password',$encrypted_data,SQLVARCHAR,false,false,1000);
mssql_bind($stmt, '@alt',$alt,SQLVARCHAR,false,false,150);
mssql_bind($stmt, '@desc',$desc,SQLVARCHAR,false,false,100);

// Execute 
mssql_execute($stmt);


-Original Message-
From: hack988 hack988 [mailto:hack...@dev.htwap.com] 
Sent: Wednesday, August 26, 2009 12:18 PM
To: Andrew Ballard
Cc: David Stoltz; php-general@lists.php.net
Subject: Re: [PHP] How to output a NULL field?

Com function is just for Windows,I don't kown why some body like use it.:(

2009/8/27 Andrew Ballard :
> On Wed, Aug 26, 2009 at 9:51 AM, David Stoltz wrote:
>> Sorry - I don't know what you mean by DB class?
>>
>> I'm using Microsoft SQL 2000with this code:
>>
>> > //create an instance of the  ADO connection object
>> $conn = new COM ("ADODB.Connection")
>>  or die("Cannot start ADO");
>> //define connection string, specify database driver
>> $connStr = "PROVIDER=SQLOLEDB;SERVER=;UID=xxx;PWD=;DATABASE=";
>> $conn->open($connStr); //Open the connection to the database
>>
>> $query = "SELECT * FROM eval_evaluations WHERE id = ".$_POST["eval"];
>>
>> $rs = $conn->execute($query);
>>
>> echo $rs->Fields(22); //this is where that particular field is NULL, and 
>> produces the error
>>
>> 
>>
>
> Because you are using COM, you can't use PHP's empty(), isset(), or
> is_null() in your if(...) statement. I've not used COM for much in
> PHP, but I think you'll have to do something like this:
>
> switch (variant_get_type($rs->Fields(22)) {
>    case VT_EMPTY:
>    case VT_NULL:
>        $q4 = '';
>        break;
>
>    case VT_UI1:
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] How to output a NULL field?

2009-08-26 Thread David Stoltz
Wow - thanks for the code, but it's over my head at this point.

I'm a PHP newbieI typically use ASP Classic, but I realize I need to learn 
PHP for ongoing development. Problem is, we don't have MySQL here, so I have to 
fumble my way through with MS SQL.

Thanks!


-Original Message-
From: hack988 hack988 [mailto:hack...@dev.htwap.com] 
Sent: Wednesday, August 26, 2009 10:13 AM
To: a...@ashleysheridan.co.uk
Cc: David Stoltz; php-general@lists.php.net
Subject: Re: [PHP] How to output a NULL field?

My code for mssql
please enable the php's mssql extentions.
it used like so many mysql class that you can find by google
--
4.2.0 disable php's automatic
datetime convert
Class DB {
var $querynum=0;
var $mssql_link;
var $conn_link;
var $sp_link;
var $sp_name='';
var $error_stop=0;
var $show_error=0;
var $dbhost;
var $dbuser;
var $dbpw;
var $dbname;
var $pconnect;
var $var_type=array();
var $fields_name=array();
var $last_error_msg='';
var $phprunversion='';
function DB() {
//define type for sp
$this->var_type['sp_bit']=SQLBIT;
$this->var_type['sp_tinyint']=SQLINT1;
$this->var_type['sp_smallint']=SQLINT2;
$this->var_type['sp_int']=SQLINT4;
$this->var_type['sp_bigint']=SQLVARCHAR;
$this->var_type['sp_real']=SQLFLT4;
$this->var_type['sp_float']=SQLFLT8;
$this->var_type['sp_float-null']=SQLFLTN;
$this->var_type['sp_smallmoney']=SQLFLT8;
$this->var_type['sp_money']=SQLFLT8;
$this->var_type['sp_money-null']=SQLFLT8;
$this->var_type['sp_char']=SQLCHAR;
$this->var_type['sp_varchar']=SQLVARCHAR;
$this->var_type['sp_text']=SQLTEXT;
$this->var_type['sp_datetime']=SQLINT4;
$this->phprunversion=phpversion();
//end
}
/*>=php4.4.1,>=php5.1.1
a new paramate for if use newlink for connect,pconnect
*/
function rconnect($newlink=false){//2007.03.01 by hack988 fix 
phpversion check
if($this->phprunversion >= '4.4.1' && $this->phprunversion < 
'5.0.0'
|| $this->phprunversion >= '5.1.1'){
return $this->rconnect4p($newlink);
}else{
return $this->rconnect3p();
}
}
function rconnect3p(){
$this->mssql_link = $this->pconnect==0 ?
mssql_connect($this->dbhost, $this->dbuser, $this->dbpw) :
mssql_pconnect($this->dbhost, $this->dbuser, $this->dbpw);
if(!$this->mssql_link){
$this->halt("connect
($this->pconnect)MSSQL($this->dbhost,$this->dbuser)failed!");
return false;
}else{
$this->conn_link=$this->mssql_link;
if($this->dbname) {
if 
(!...@$this->select_db($this->dbname,$this->conn_link)){
$this->halt('can not use database 
'.$this->dbname);
return false;
}else{
return true;
}
}else{
return true;
}
}
}
function rconnect4p($newlink=false){
$this->mssql_link = $this->pconnect==0 ?
mssql_connect($this->dbhost, $this->dbuser, $this->dbpw , $newlink) :
mssql_pconnect($this->dbhost, $this->dbuser, $this->dbpw, $newlink);
if(!$this->mssql_link){

$this->halt("reconect($this->pconnect)MSSQL($this->dbhost,$this->dbuser)failed");
return false;
}else{
$this->conn_link=$this->mssql_link;
if($this->dbname) {
if 
(!...@$this->select_db($this->dbname,$this->conn_link)){
$this->halt('can not use da

RE: [PHP] How to output a NULL field?

2009-08-26 Thread David Stoltz
Sorry - I don't know what you mean by DB class?

I'm using Microsoft SQL 2000with this code:

open($connStr); //Open the connection to the database

$query = "SELECT * FROM eval_evaluations WHERE id = ".$_POST["eval"];

$rs = $conn->execute($query);

echo $rs->Fields(22); //this is where that particular field is NULL, and 
produces the error



-Original Message-
From: hack988 hack988 [mailto:hack...@dev.htwap.com] 
Sent: Wednesday, August 26, 2009 8:08 AM
To: David Stoltz
Cc: php-general@lists.php.net
Subject: Re: [PHP] How to output a NULL field?

Could you post your database's class to here?
I'm use mssql with php for several years and read NULL Fields is never
appear your case.

2009/8/26 David Stoltz :
> I tried that -it's in the first part of my message
>
>
> -Original Message-
> From: hack988 hack988 [mailto:hack...@dev.htwap.com]
> Sent: Wednesday, August 26, 2009 7:39 AM
> To: David Stoltz
> Cc: Paul M Foster; php-general@lists.php.net
> Subject: Re: [PHP] How to output a NULL field?
>
> use is_null() check it
>
> 2009/8/26 David Stoltz :
>> Paul,
>>
>> This all started because when I try this:
>>
>> Fields(22);?>
>>
>> It work fine, as long as there is a non-null value there, otherwise it
>> produces an error.
>>
>> Also, I'm working with a Microsoft SQL 2000 database, not MySQLnot
>> sure if that matters
>>
>> But "echo $rs->Fields(22)" works perfectly for dumping values out of my
>> $rs recordset...that is, unless the value is NULL is the database - then
>> I get:
>>
>> Catchable fatal error: Object of class variant could not be converted to
>> string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 176
>>
>>
>> -Original Message-----
>> From: Paul M Foster [mailto:pa...@quillandmouse.com]
>> Sent: Tuesday, August 25, 2009 4:39 PM
>> To: php-general@lists.php.net
>> Subject: Re: [PHP] How to output a NULL field?
>>
>> On Tue, Aug 25, 2009 at 02:00:04PM -0400, David Stoltz wrote:
>>
>>> $rs->Fields(22) equals a NULL in the database
>>>
>>> My Code:
>>>
>>> if(empty($rs->Fields(22))){
>>>       $q4 = "";
>>> }else{
>>>       $q4 = $rs->Fields(22);
>>> }
>>>
>>> Produces this error:
>>> Fatal error: Can't use method return value in write context in
>>> D:\Inetpub\wwwroot\evaluations\lookup2.php on line 32
>>>
>>> Line 32 is the "if" line...
>>>
>>> If I switch the code to (using is_null):
>>> if(is_null($rs->Fields(22))){
>>>       $q4 = "";
>>> }else{
>>>       $q4 = $rs->Fields(22);
>>> }
>>>
>>> It produces this error:
>>> Catchable fatal error: Object of class variant could not be converted
>> to
>>> string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 196
>>>
>>> Line 196 is: 
>>>
>>> What am I doing wrong?
>>>
>>> Thanks!
>>
>> Just a thought... do you really mean $rs->Fields(22) or do you mean
>> $rs->Fields[22]? The former is a function call and the latter is an
>> array variable.
>>
>> Paul
>>
>> --
>> Paul M. Foster
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] How to output a NULL field?

2009-08-26 Thread David Stoltz
This:
$var = $rs->Fields(22);
var_dump($var);

Produces this:
object(variant)#3 (0) { }

-Original Message-
From: Stuart [mailto:stut...@gmail.com] 
Sent: Wednesday, August 26, 2009 8:47 AM
To: David Stoltz
Cc: Paul M Foster; php-general@lists.php.net
Subject: Re: [PHP] How to output a NULL field?

2009/8/26 David Stoltz :
> Paul,
>
> This all started because when I try this:
>
> Fields(22);?>
>
> It work fine, as long as there is a non-null value there, otherwise it
> produces an error.
>
> Also, I'm working with a Microsoft SQL 2000 database, not MySQLnot
> sure if that matters
>
> But "echo $rs->Fields(22)" works perfectly for dumping values out of my
> $rs recordset...that is, unless the value is NULL is the database - then
> I get:
>
> Catchable fatal error: Object of class variant could not be converted to
> string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 176

That error indicates that you're not getting NULL since NULL is easily
converted to a string.

Try this...

$var = $rs->Fields(22);
var_dump($var);

...and tell us what you get.

-Stuart

-- 
http://stut.net/

> -Original Message-
> From: Paul M Foster [mailto:pa...@quillandmouse.com]
> Sent: Tuesday, August 25, 2009 4:39 PM
> To: php-general@lists.php.net
> Subject: Re: [PHP] How to output a NULL field?
>
> On Tue, Aug 25, 2009 at 02:00:04PM -0400, David Stoltz wrote:
>
>> $rs->Fields(22) equals a NULL in the database
>>
>> My Code:
>>
>> if(empty($rs->Fields(22))){
>>       $q4 = "";
>> }else{
>>       $q4 = $rs->Fields(22);
>> }
>>
>> Produces this error:
>> Fatal error: Can't use method return value in write context in
>> D:\Inetpub\wwwroot\evaluations\lookup2.php on line 32
>>
>> Line 32 is the "if" line...
>>
>> If I switch the code to (using is_null):
>> if(is_null($rs->Fields(22))){
>>       $q4 = "";
>> }else{
>>       $q4 = $rs->Fields(22);
>> }
>>
>> It produces this error:
>> Catchable fatal error: Object of class variant could not be converted
> to
>> string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 196
>>
>> Line 196 is: 
>>
>> What am I doing wrong?
>>
>> Thanks!
>
> Just a thought... do you really mean $rs->Fields(22) or do you mean
> $rs->Fields[22]? The former is a function call and the latter is an
> array variable.
>
> Paul
>
> --
> Paul M. Foster
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


RE: [PHP] How to output a NULL field?

2009-08-26 Thread David Stoltz
I tried that -it's in the first part of my message


-Original Message-
From: hack988 hack988 [mailto:hack...@dev.htwap.com] 
Sent: Wednesday, August 26, 2009 7:39 AM
To: David Stoltz
Cc: Paul M Foster; php-general@lists.php.net
Subject: Re: [PHP] How to output a NULL field?

use is_null() check it

2009/8/26 David Stoltz :
> Paul,
>
> This all started because when I try this:
>
> Fields(22);?>
>
> It work fine, as long as there is a non-null value there, otherwise it
> produces an error.
>
> Also, I'm working with a Microsoft SQL 2000 database, not MySQLnot
> sure if that matters
>
> But "echo $rs->Fields(22)" works perfectly for dumping values out of my
> $rs recordset...that is, unless the value is NULL is the database - then
> I get:
>
> Catchable fatal error: Object of class variant could not be converted to
> string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 176
>
>
> -Original Message-
> From: Paul M Foster [mailto:pa...@quillandmouse.com]
> Sent: Tuesday, August 25, 2009 4:39 PM
> To: php-general@lists.php.net
> Subject: Re: [PHP] How to output a NULL field?
>
> On Tue, Aug 25, 2009 at 02:00:04PM -0400, David Stoltz wrote:
>
>> $rs->Fields(22) equals a NULL in the database
>>
>> My Code:
>>
>> if(empty($rs->Fields(22))){
>>       $q4 = "";
>> }else{
>>       $q4 = $rs->Fields(22);
>> }
>>
>> Produces this error:
>> Fatal error: Can't use method return value in write context in
>> D:\Inetpub\wwwroot\evaluations\lookup2.php on line 32
>>
>> Line 32 is the "if" line...
>>
>> If I switch the code to (using is_null):
>> if(is_null($rs->Fields(22))){
>>       $q4 = "";
>> }else{
>>       $q4 = $rs->Fields(22);
>> }
>>
>> It produces this error:
>> Catchable fatal error: Object of class variant could not be converted
> to
>> string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 196
>>
>> Line 196 is: 
>>
>> What am I doing wrong?
>>
>> Thanks!
>
> Just a thought... do you really mean $rs->Fields(22) or do you mean
> $rs->Fields[22]? The former is a function call and the latter is an
> array variable.
>
> Paul
>
> --
> Paul M. Foster
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] How to output a NULL field?

2009-08-26 Thread David Stoltz
Paul,

This all started because when I try this:

Fields(22);?>

It work fine, as long as there is a non-null value there, otherwise it
produces an error.

Also, I'm working with a Microsoft SQL 2000 database, not MySQLnot
sure if that matters

But "echo $rs->Fields(22)" works perfectly for dumping values out of my
$rs recordset...that is, unless the value is NULL is the database - then
I get:

Catchable fatal error: Object of class variant could not be converted to
string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 176


-Original Message-
From: Paul M Foster [mailto:pa...@quillandmouse.com] 
Sent: Tuesday, August 25, 2009 4:39 PM
To: php-general@lists.php.net
Subject: Re: [PHP] How to output a NULL field?

On Tue, Aug 25, 2009 at 02:00:04PM -0400, David Stoltz wrote:

> $rs->Fields(22) equals a NULL in the database
> 
> My Code:
> 
> if(empty($rs->Fields(22))){
>   $q4 = "";
> }else{
>   $q4 = $rs->Fields(22);
> }
> 
> Produces this error:
> Fatal error: Can't use method return value in write context in
> D:\Inetpub\wwwroot\evaluations\lookup2.php on line 32
> 
> Line 32 is the "if" line...
> 
> If I switch the code to (using is_null):
> if(is_null($rs->Fields(22))){
>   $q4 = "";
> }else{
>   $q4 = $rs->Fields(22);
> }
> 
> It produces this error:
> Catchable fatal error: Object of class variant could not be converted
to
> string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 196
> 
> Line 196 is: 
> 
> What am I doing wrong?
> 
> Thanks!

Just a thought... do you really mean $rs->Fields(22) or do you mean
$rs->Fields[22]? The former is a function call and the latter is an
array variable.

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] How to output a NULL field?

2009-08-25 Thread David Stoltz
if(empty($rs->Fields(22))){
$q4 = '';
}else{
$q4 = ''.$rs->Fields(22);
}  

Still produces errors, whether using "empty" or "is_null"with single 
quotes

???

-Original Message-
From: Bastien Koert [mailto:phps...@gmail.com] 
Sent: Tuesday, August 25, 2009 2:17 PM
To: David Stoltz
Cc: php-general@lists.php.net
Subject: Re: [PHP] How to output a NULL field?

On Tue, Aug 25, 2009 at 2:00 PM, David Stoltz wrote:
> $rs->Fields(22) equals a NULL in the database
>
> My Code:
>
> if(empty($rs->Fields(22))){
>        $q4 = "";
> }else{
>        $q4 = $rs->Fields(22);
> }
>
> Produces this error:
> Fatal error: Can't use method return value in write context in
> D:\Inetpub\wwwroot\evaluations\lookup2.php on line 32
>
> Line 32 is the "if" line...
>
> If I switch the code to (using is_null):
> if(is_null($rs->Fields(22))){
>        $q4 = "";
> }else{
>        $q4 = $rs->Fields(22);
> }
>
> It produces this error:
> Catchable fatal error: Object of class variant could not be converted to
> string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 196
>
> Line 196 is: 
>
> What am I doing wrong?
>
> Thanks!
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


$q4 =  '' . $rs->Fields(22);

Note that it's two single quotes
-- 

Bastien

Cat, the other other white meat

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] How to output a NULL field?

2009-08-25 Thread David Stoltz
$rs->Fields(22) equals a NULL in the database

My Code:

if(empty($rs->Fields(22))){
$q4 = "";
}else{
$q4 = $rs->Fields(22);
}

Produces this error:
Fatal error: Can't use method return value in write context in
D:\Inetpub\wwwroot\evaluations\lookup2.php on line 32

Line 32 is the "if" line...

If I switch the code to (using is_null):
if(is_null($rs->Fields(22))){
$q4 = "";
}else{
$q4 = $rs->Fields(22);
}

It produces this error:
Catchable fatal error: Object of class variant could not be converted to
string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 196

Line 196 is: 

What am I doing wrong?

Thanks!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] mssql_bind Question

2009-08-19 Thread David Stoltz
Code in question:
mssql_bind($stmt,
'@managerName',$managerName,SQLVARCHAR,false,false,50);

For a normal varchar field, the length is obvious, in this case 50.

But for an ntext field, how do I use the mssql_bind statement?

Far as I know, these are the only available "types" to use:
SQLTEXT, SQLVARCHAR, SQLCHAR, SQLINT1, SQLINT2, SQLINT4, SQLBIT,
SQLFLT4, SQLFLT8, SQLFLTN

I need to use which type, and what length to use...?

Thanks for any advice...


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Sub Menu System?

2009-07-16 Thread David Stoltz
Folks,

I'm developing a rather large site in PHP. The main horizontal nav bar
never changes, no matter how deep you are in the site. However, on the
left side is a vertical "sub-menu" system. This menu is proving to be a
real pain to program. I have it limited the menu system to 3 levels:

MAIN:
 |___Secondary pages
   |___Tertiary pages

For each level, and each folder, I have a file called subnav.php, which
contains the links for that page. It has its own code to determine the
page it's on, and highlight the appropriate menu item.

The problem is when I need to move pages, or add pages, it's proving to
be a REAL PAIN to maintain this type of structure.

Does anyone know of any off-the-shelf product that can create/maintain a
sub-menu system like this?

I don't mind starting over at this point, but I'm hoping there is
something I can just purchase, so I can concentrate on the rest of the
sitehopefully the menu system would support PHP and ASP.

Thanks for any information!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Programming Question

2009-04-29 Thread David Stoltz
Hi Folks,

I'm a PHP newbie - but this question really isn't about PHP per se',
it's more about programming in general, and how to do something...

I'm redesigning an ASP site with Dreamweaver CS4, so I'll be sticking to
using ASP technology

The site will use horizontal navigation for the MAIN MENU which will be
static, but each page therein will have a vertical sub menu, probably
with 2-3 levels deep - which will need to be dynamic.

I'm trying to figure out a good way to organize and maintain the
submenus. I need each page to "know where it is" so the breadcrumb trail
can be accurate and dynamic. The page/menu will also need to know how to
display the correct submenu/level.hopefully this all can be
dynamic

I also want to avoid query string parameters, such as
page.asp?menu=1&submenu=3 type stuff.

My current thought is to use URL rewriting and a database - but I'm not
sure if this is the best route

Does anyone have any suggestions? HELP!

Thanks!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Select List/Menu

2009-04-17 Thread David Stoltz
If I allow multiple selections in a MENU LIST, in VBSCRIPT it comes
through with each selection being separated by a comma, in the same
variable...ie.:

myVal = request("mySelectmenu")

myVal could equal -> "selection 1, selection 2, selection 3"

But in PHP, I capture it as:

$mySelectMenu = $_POST[mySelectmenu];

But $mySelectMenu only contains the last selection in the menu

How do I capture all the selections?

Thanks!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] What am I doing wrong?

2009-04-17 Thread David Stoltz
Thanks - actually, as I just figured out, there were PHP errors, but I
never saw them because of the redirection header at the end...

If I comment that out, I see that I didn't have execute permissions on
the SP

Thanks for the help!


-Original Message-
From: Jay Blanchard [mailto:jblanch...@pocket.com] 
Sent: Friday, April 17, 2009 12:17 PM
To: David Stoltz; php-general@lists.php.net
Subject: RE: [PHP] What am I doing wrong?

[snip]
I can't seem to understand PHP error trapping...I have it turned on in
php.ini, and on the page in question, I have "error_reporting(E_ALL);"
on the page in question below - the following code does NOT generate any
errors, but it doesn't perform the insert eitherthe stored procedure
exists, but even if I purposely misspell the stored procedure name, no
errors are raised...any advice?


[/snip]

No PHP error occurs that is why you do not get an error. Insert this

http://us.php.net/manual/en/function.mssql-get-last-message.php 

after the execute and you should get a message back from SQL Server

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] What am I doing wrong?

2009-04-17 Thread David Stoltz
I can't seem to understand PHP error trapping...I have it turned on in
php.ini, and on the page in question, I have "error_reporting(E_ALL);"
on the page in question below - the following code does NOT generate any
errors, but it doesn't perform the insert eitherthe stored procedure
exists, but even if I purposely misspell the stored procedure name, no
errors are raised...any advice?



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] MSSQL_CONNECT problem

2008-12-10 Thread David Stoltz
It's fixed WOO HOO - I'm going to get teary-eyedDan - special
thanks to you for helping me so much...

What fixed this? I put the DLL for SQL 2005 PHP Driver in the PHP/EXT
directory, and added the extension to the php.ini.

Restarted IIS, and BAM! Everything works

The only thing I did notice was I had to go back in my ADO code, and
specify a port in my connection object (which wasn't needed before)...

And now mssql_connect works!

Thanks everyone for your help!

-Dave 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] MSSQL_CONNECT problem

2008-12-10 Thread David Stoltz
From: Dan Shirah [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 10, 2008 9:42 AM
To: David Stoltz
Cc: Daniel Brown; Bastien Koert; php-general@lists.php.net
Subject: Re: [PHP] MSSQL_CONNECT problem
 
Is INTRA_SQL your instance name or database name?  If it is the
instance
name, is that instance setup to use 1433 as the port?  I know
1433 is
the
default port for MSSQL, but the majority of people change that.


Correct - intra_sql is the instance, yes, it's using default
port 1433
(which is also specified in the php.ini file)I've tried
connecting
with and without specifying the port - but both ways don't
work
 
Perhaps you have a different version of PHP than me...but nowhere in the
php.ini file have I had to put in a port number for a MSSQL Server.
 
That seems like a problem since PHP could need to connect to any number
of SQL Servers with any port number.
 
>From your PHP server, open a command prompt and ping your SQL server.
Try pinging by IP address and by server name.  See if you get a response
from both.
 
NOTE: Are you running PHP and MSSQL Server on the same box?
 
 
Yes - I get a response with both IP and hostname - like I said before, I
can connect to the SQL server (which IS a different box) from PHP but
only if I use ADO. Once I try and connect using mssql_connect, it
fails
 
I guess I can continue to use ADO - but the whole idea was to use
mssql_bind so I can use parameterized queries. Currently, my ADO queries
are vulnerable to SQL Injection
 
So yes - my WEB/PHP box can "see" the SQL server if I use ADO.
 
Perhaps I should try to install the SQL 2005 PHP driver - even though
I'm using SQL 2000maybe that will help? 
 
 
 


RE: [PHP] MSSQL_CONNECT problem

2008-12-10 Thread David Stoltz
-Original Message-
From: Dan Shirah [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 10, 2008 8:46 AM
To: David Stoltz
Cc: Daniel Brown; Bastien Koert; php-general@lists.php.net
Subject: Re: [PHP] MSSQL_CONNECT problem

>
> Try something like this:
>
>
>
> $dbhost=SERVER\\INSTANCE_NAME,PORT;
> $dbuser="USERNAME";
> $dbpass="PASSWORD";
> $db_connect=mssql_connect($dbhost,$dbuser,$dbpass) or die ('Server
> connection failed');
>
>
>
> $mssql_database = mssql_select_db("DATABASE", $db_connect) or die ('DB
> selection failed');
>
>
>
>  Same thing:
>
>
>
> Warning: mssql_connect() [function.mssql-connect]: Unable to connect
to
> server: \\10.10.103.222\INTRA_SQL,1433 in
> D:\Inetpub\wwwroot\cratos\test.php on line 5
>
> Server connection failed
>
Is INTRA_SQL your instance name or database name?  If it is the instance
name, is that instance setup to use 1433 as the port?  I know 1433 is
the
default port for MSSQL, but the majority of people change that.


Correct - intra_sql is the instance, yes, it's using default port 1433
(which is also specified in the php.ini file)I've tried connecting
with and without specifying the port - but both ways don't work


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] MSSQL_CONNECT problem

2008-12-10 Thread David Stoltz
From: Dan Shirah [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 10, 2008 8:10 AM
To: David Stoltz
Cc: Daniel Brown; Bastien Koert; php-general@lists.php.net
Subject: Re: [PHP] MSSQL_CONNECT problem
 
Sorry for "top posting", that's how my email client sets up the
reply...

Anyway, I don't know what CLI is? I see the error on the
web. As for
a DSN, I didn't think I need one connecting this way. That is
why the
uname, password, database is supplied, no? This should be a
"dsn-less"
connection

Either way - I tried adding a DNS on the web server, that points
to the
SQL database, and that connection works...but the code I'm using
from
the web page still does not

If I use the code you gave me, this is what I get:

Warning: mssql_connect() [function.mssql-connect]: Unable to
connect to
server: INTRA_SQL,1433 in D:\Inetpub\wwwroot\cratos\test.php on
line 2

Fatal error: Call to undefined function mssql_error() in
D:\Inetpub\wwwroot\cratos\test.php on line 2

Please advise...
 
Try something like this:
 
$dbhost=SERVER\\INSTANCE_NAME,PORT;
$dbuser="USERNAME";
$dbpass="PASSWORD";
$db_connect=mssql_connect($dbhost,$dbuser,$dbpass) or die ('Server
connection failed');
 
$mssql_database = mssql_select_db("DATABASE", $db_connect) or die ('DB
selection failed');
 
 
 
 
Same thing:
 
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to
server: \\10.10.103.222\INTRA_SQL,1433 in
D:\Inetpub\wwwroot\cratos\test.php on line 5
Server connection failed


RE: [PHP] MSSQL_CONNECT problem

2008-12-10 Thread David Stoltz
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Daniel
Brown
Sent: Tuesday, December 09, 2008 3:49 PM
To: David Stoltz
Cc: Bastien Koert; Dan Shirah; php-general@lists.php.net
Subject: Re: [PHP] MSSQL_CONNECT problem

On Tue, Dec 9, 2008 at 3:41 PM, David Stoltz <[EMAIL PROTECTED]> wrote:
>
> Do you have any other thoughts?

When posting to the list, please don't top-post.

Dave, are you seeing that error from both the CLI and the web?
Have you properly configured your DSN?  What's the output from the
following?



-- 

http://www.parasane.net/
[EMAIL PROTECTED] || [EMAIL PROTECTED]
50% Off Hosting! http://www.pilotpig.net/specials.php



Sorry for "top posting", that's how my email client sets up the reply...

Anyway, I don't know what CLI is? I see the error on the web. As for
a DSN, I didn't think I need one connecting this way. That is why the
uname, password, database is supplied, no? This should be a "dsn-less"
connection

Either way - I tried adding a DNS on the web server, that points to the
SQL database, and that connection works...but the code I'm using from
the web page still does not

If I use the code you gave me, this is what I get:

Warning: mssql_connect() [function.mssql-connect]: Unable to connect to
server: INTRA_SQL,1433 in D:\Inetpub\wwwroot\cratos\test.php on line 2

Fatal error: Call to undefined function mssql_error() in
D:\Inetpub\wwwroot\cratos\test.php on line 2

Please advise

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] MSSQL_CONNECT problem

2008-12-09 Thread David Stoltz
Bastien - I'm getting desperate,

Yes, I'm using a valid SQL account. I've tried putting both versions of 
"ntwdblib.dll" in the php directory, and the system32 directory (not at once of 
course), and I get the same error.

I've pretty much tried everything I've readthe kicker is I can access the 
SQL Server fine by using ADO in PHP. It's only when I try mssql_connect that 
the connection fails

The whole reason I don't use ADO is because the queries don't stand up to SQL 
injection...So I wanted to use mssql_connect with "mssql_bind" so I can do 
parameterized queries

Do you have any other thoughts?

Thanks!


From: Bastien Koert [mailto:[EMAIL PROTECTED] 
Sent: Monday, December 08, 2008 10:02 AM
To: Dan Shirah
Cc: David Stoltz; php-general@lists.php.net
Subject: Re: [PHP] MSSQL_CONNECT problem


On Mon, Dec 8, 2008 at 9:45 AM, Dan Shirah <[EMAIL PROTECTED]> wrote:
>
> Can't seem to connect with MSSQL_CONNECT. The function IS available. I'm
> in a Windows environment, connecting to a SQL 2000 instance. My code:
>
> mssql_connect('INTRA_SQL,1433', 'uname', 'password');
> mssql_select_db('database');
>
> I've tried leaving the port out, tried using server IP address, all to
> no avail. I've copied the "ntwdblib.dll" from my SQL 2000 box to my PHP
> directory on the web server - no go. (this was suggested on the php
> site).
>
> mssql.secure_connection = off (in the php.ini file)
> extension=php_mssql.dll (is also included in the ini file)
>
> Keep getting error message: Unable to connect to server
>
> Does anyone have any ideas?
>
> Thanks!
> Dave

Dave,

For my connection I didn't copy the ntwdblib.dll file from the SQL Server
and paste it onto the PHP server...I believe there was an older version of
the ntwdblib.dll that I had to download...the file had a modification date
of I think 11/2003.

Things to check.

extension=php_mssql.dll uncommented in your PHP.ini

See if your PHP server can talk to your SQL Server.  I would assume they are
both inside the DMZ and that your DNS resolves the server names, correct?

When making your connection try doing it like this:

//Assign the server connection to a variable
$connect = mssql_connect('SERVERNAME, 'USERNAME', 'PASSWORD');

//Select your database and reference the connection
mssql_select_db('DATABASE', $connection);
Have you created a mssql account to allow connetion from whereever you are 
coming from?


-- 

Bastien

Cat, the other other white meat

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] MSSQL_CONNECT problem

2008-12-08 Thread David Stoltz
Hi Dan,

Yes, I have:
extension=php_mssql.dll uncommented

I am using dll version "2000.80.194.0" which seems to be recommended for 
connection problems like this...

And yes - this web server talks to the SQL server on other pages using 
ASPit seems to just be a PHP connection problem.


Still stuck..


From: Dan Shirah [mailto:[EMAIL PROTECTED] 
Sent: Monday, December 08, 2008 9:46 AM
To: David Stoltz
Cc: php-general@lists.php.net
Subject: Re: [PHP] MSSQL_CONNECT problem

Can't seem to connect with MSSQL_CONNECT. The function IS available. I'm
in a Windows environment, connecting to a SQL 2000 instance. My code:

mssql_connect('INTRA_SQL,1433', 'uname', 'password');
mssql_select_db('database');

I've tried leaving the port out, tried using server IP address, all to
no avail. I've copied the "ntwdblib.dll" from my SQL 2000 box to my PHP
directory on the web server - no go. (this was suggested on the php
site).

mssql.secure_connection = off (in the php.ini file)
extension=php_mssql.dll (is also included in the ini file)

Keep getting error message: Unable to connect to server

Does anyone have any ideas?

Thanks!
Dave
 
Dave,
 
For my connection I didn't copy the ntwdblib.dll file from the SQL Server and 
paste it onto the PHP server...I believe there was an older version of the 
ntwdblib.dll that I had to download...the file had a modification date of I 
think 11/2003.
 
Things to check.
 
extension=php_mssql.dll uncommented in your PHP.ini
 
See if your PHP server can talk to your SQL Server.  I would assume they are 
both inside the DMZ and that your DNS resolves the server names, correct?
 
When making your connection try doing it like this:
 
//Assign the server connection to a variable
$connect = mssql_connect('SERVERNAME, 'USERNAME', 'PASSWORD');
 
//Select your database and reference the connection
mssql_select_db('DATABASE', $connection);

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] MSSQL_CONNECT problem

2008-12-08 Thread David Stoltz
Folks,

Can't seem to connect with MSSQL_CONNECT. The function IS available. I'm
in a Windows environment, connecting to a SQL 2000 instance. My code:

mssql_connect('INTRA_SQL,1433', 'uname', 'password');
mssql_select_db('database');

I've tried leaving the port out, tried using server IP address, all to
no avail. I've copied the "ntwdblib.dll" from my SQL 2000 box to my PHP
directory on the web server - no go. (this was suggested on the php
site).

mssql.secure_connection = off (in the php.ini file)
extension=php_mssql.dll (is also included in the ini file)

Keep getting error message: Unable to connect to server

Does anyone have any ideas?

Thanks!
Dave

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Help with IF ELSE

2008-12-05 Thread David Stoltz
WOO HOO - addslashes baby!

Thank you!

-Original Message-
From: Sándor Tamás (HostWare Kft.) [mailto:[EMAIL PROTECTED] 
Sent: Friday, December 05, 2008 7:26 AM
To: php-general@lists.php.net
Subject: Re: [PHP] Help with IF ELSE

The solution is addslashes(). This function adds a backslash before special 
characters in a string.

http://php.net/manual/en/function.addslashes.php

SanTa

- Original Message - 
From: "David Stoltz" <[EMAIL PROTECTED]>
To: 
Sent: Friday, December 05, 2008 1:19 PM
Subject: RE: [PHP] Help with IF ELSE


> The problem turned out to be, since I'm using the MCRYPT function to 
> encrypt the password, once in a while the encrypted password will have a 
> bad character:
>
> ßt¦?rDþž’Q…ß±–
>
> For example, the above has ’
>
> This stops the PHP processing cold when executing the query to insert that 
> string - no errors at all - just stops processing - and I do have 
> display_errors turned on.
>
> So then, how does one store this type of string? I can't do a string 
> replacebut there must be a way...
>
> If anyone has come across this, please let me know...
>
> Thanks!
>
> -Original Message-
> From: Sándor Tamás (HostWare Kft.) [mailto:[EMAIL PROTECTED]
> Sent: Friday, December 05, 2008 6:59 AM
> To: php-general@lists.php.net
> Subject: Re: [PHP] Help with IF ELSE
>
> You should check if php.ini has display_error off. This can prevent all
> error message to be shown.
>
> SanTa
>
> - Original Message - 
> From: "David Stoltz" <[EMAIL PROTECTED]>
> To: "Richard Heyes" <[EMAIL PROTECTED]>
> Cc: 
> Sent: Friday, December 05, 2008 12:42 PM
> Subject: RE: [PHP] Help with IF ELSE
>
>
> I turned on error reporting (ALL) as you suggested. Nothing is being
> sent to the browserstill doesn't work if the recordset isn't empty.
>
> I'm wondering, is there any other way to do a redirect in PHP?
>
> Thanks
>
>
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
> Of Richard Heyes
> Sent: Thursday, December 04, 2008 3:17 PM
> To: David Stoltz
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Help with IF ELSE
>
>> I'm new to PHP - I'm trying to figure out what is wrong with a simple
> IF
>> ELSE block I have...if the recordset $rs is empty (login fails), the
> 1st
>> part of the block works, and redirects the user to default.php - but
> if
>> the login works, and $rs is not empty, the 2nd "else" part does not
>> work, and does not redirect to menu.php - I just get  a blank white
>> screen on the login.php page (where this code is)
>
> You could try setting error_reporting() to full before you do
> anything, it may help, and it's always prudent to use it that way:
>
> error_reporting(E_ALL);
> ?>
>
> Additionally, redirects fail when you've sent output to the browser,
> even if its just whitespace. Your code looks OK, but check for it. The
> error reporting thang may help you with that.
>
> -- 
> Richard Heyes
>
> HTML5 Graphing for FF, Chrome, Opera and Safari:
> http://www.rgraph.org (Updated November 29th)
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Help with IF ELSE

2008-12-05 Thread David Stoltz
The problem turned out to be, since I'm using the MCRYPT function to encrypt 
the password, once in a while the encrypted password will have a bad character:

ßt¦?rDþž’Q…ß±–

For example, the above has ’

This stops the PHP processing cold when executing the query to insert that 
string - no errors at all - just stops processing - and I do have 
display_errors turned on.

So then, how does one store this type of string? I can't do a string 
replacebut there must be a way...

If anyone has come across this, please let me know...

Thanks!

-Original Message-
From: Sándor Tamás (HostWare Kft.) [mailto:[EMAIL PROTECTED] 
Sent: Friday, December 05, 2008 6:59 AM
To: php-general@lists.php.net
Subject: Re: [PHP] Help with IF ELSE

You should check if php.ini has display_error off. This can prevent all 
error message to be shown.

SanTa

- Original Message - 
From: "David Stoltz" <[EMAIL PROTECTED]>
To: "Richard Heyes" <[EMAIL PROTECTED]>
Cc: 
Sent: Friday, December 05, 2008 12:42 PM
Subject: RE: [PHP] Help with IF ELSE


I turned on error reporting (ALL) as you suggested. Nothing is being
sent to the browserstill doesn't work if the recordset isn't empty.

I'm wondering, is there any other way to do a redirect in PHP?

Thanks


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Richard Heyes
Sent: Thursday, December 04, 2008 3:17 PM
To: David Stoltz
Cc: php-general@lists.php.net
Subject: Re: [PHP] Help with IF ELSE

> I'm new to PHP - I'm trying to figure out what is wrong with a simple
IF
> ELSE block I have...if the recordset $rs is empty (login fails), the
1st
> part of the block works, and redirects the user to default.php - but
if
> the login works, and $rs is not empty, the 2nd "else" part does not
> work, and does not redirect to menu.php - I just get  a blank white
> screen on the login.php page (where this code is)

You could try setting error_reporting() to full before you do
anything, it may help, and it's always prudent to use it that way:



Additionally, redirects fail when you've sent output to the browser,
even if its just whitespace. Your code looks OK, but check for it. The
error reporting thang may help you with that.

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated November 29th)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Help with IF ELSE

2008-12-05 Thread David Stoltz
I turned on error reporting (ALL) as you suggested. Nothing is being
sent to the browserstill doesn't work if the recordset isn't empty.

I'm wondering, is there any other way to do a redirect in PHP?

Thanks


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Richard Heyes
Sent: Thursday, December 04, 2008 3:17 PM
To: David Stoltz
Cc: php-general@lists.php.net
Subject: Re: [PHP] Help with IF ELSE

> I'm new to PHP - I'm trying to figure out what is wrong with a simple
IF
> ELSE block I have...if the recordset $rs is empty (login fails), the
1st
> part of the block works, and redirects the user to default.php - but
if
> the login works, and $rs is not empty, the 2nd "else" part does not
> work, and does not redirect to menu.php - I just get  a blank white
> screen on the login.php page (where this code is)

You could try setting error_reporting() to full before you do
anything, it may help, and it's always prudent to use it that way:



Additionally, redirects fail when you've sent output to the browser,
even if its just whitespace. Your code looks OK, but check for it. The
error reporting thang may help you with that.

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated November 29th)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Help with IF ELSE

2008-12-04 Thread David Stoltz
Hi All,

I'm new to PHP - I'm trying to figure out what is wrong with a simple IF
ELSE block I have...if the recordset $rs is empty (login fails), the 1st
part of the block works, and redirects the user to default.php - but if
the login works, and $rs is not empty, the 2nd "else" part does not
work, and does not redirect to menu.php - I just get  a blank white
screen on the login.php page (where this code is)

Any ideas? What is the proper way to detect an empty recordset?

Thanks!

Below is the code:

...
$query = "SELECT user_id FROM users WHERE username = '$uname' AND
password = '$pword'";

$rs = $conn->execute($query);

if($rs->EOF)
{
$rs->Close();
$conn->Close();
$rs = null;
$conn = null;
header("Location: default.php?err=Invalid%20Login%20Attempt");
exit;
}
else
{
$rs->Close();
$conn->Close();
$rs = null;
$conn = null;
header("Location: menu.php");
exit;
}

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php