[PHP] Help with MSSQL and Stored Procs

2012-08-29 Thread Phillip Baker
I am trying to access a MSSQL DB on another system.
I am having trouble executed a stored proc and debugging the problem./

I have included the code below.
I can connect to the DB just fine.
I also can run regular queries on the DB and get a result set.
We can also run the stored proc manually with the data in $xmlstring and
that runs fine.

However the mssql_execute is failing.
I am getting the Execute failed die message however I am not getting
anything for mssql_get_last_message

So I have no idea what is happening.
And ideas for solutions or at least to get more debugging information would
be awesome.

I know SQLSRV is a more recent option however we do not have it installed
on the server and will likely not get that to happen so I need to get this
debugged.

$link = mssql_connect($myServer, $myUser, $myPass)
or die(Couldn't connect to SQL Server on $myServer);
mssql_select_db($myDB, $link)
or die(Couldn't select database $myDB);
if(!$link){
die('Error connecting to MSSQL database at '.$myServer);
} else {
$version = mssql_query('SELECT @@VERSION');
$row = mssql_fetch_array($version);
mssql_free_result($version);

echo $row[0].'br /br /';
}
$storedproc = Sp_DialerValidLead;
$param = ValidLeadText;

$stmt = mssql_init('Sp_DialerValidLead', $link)
or die(Unable to initialize);

mssql_bind($stmt, @.$param, $xmlstring, SQLVARCHAR)
or die(Unable to bind
@ValidLeadText:$storedprocbr.mssql_get_last_message());

$result = mssql_execute($stmt)
or die (Execute failed. Message:.mssql_get_last_message());

var_dump($result);


Blessed Be

Phillip

In the Jim Crow South, for example, government failed and indeed refused
to protect blacks from extra-legal violence. Given our history, it's
stunning we fail to question those who would force upon us a total reliance
on the state for defense.
-- Robert J. Cottrol


[PHP] MSSQL Stored Proc

2012-08-28 Thread Phillip Baker
Greetings all,

I am having some trouble with running a stored proc on an MSSQL DB.
I am new to using MSSQL.



$link = mssql_connect($server, $db, $password);



if(!$link){

die('Error connecting to MSSQL database at '.$server);

} else {
$storedproc = SP_DialerValidLead;

$param = ValidLeadText;



$stmt = mssql_init($storedproc, $link)

or die(Unable to initialize);



mssql_bind($stmt, @.$param, $xmlstring, SQLTEXT, FALSE)

or die(Unable to bind
$param:$storedprocbr.mssql_get_last_message());



$result = mssql_execute($stmt);



var_dump($result);
mssql_close($link);

}


Apparently there is no data getting passed to the stored proc.

The $xmlstring is a valid xml string and the variable is properly set in
the code above.

Is there something obvious in how I am trying to call the stored proc with
the PHP code?
Any ideas or further questions?

Blessed Be

Phillip

In the Jim Crow South, for example, government failed and indeed refused
to protect blacks from extra-legal violence. Given our history, it's
stunning we fail to question those who would force upon us a total reliance
on the state for defense.
-- Robert J. Cottrol


[PHP] XML/PHP web service

2012-08-08 Thread Phillip Baker
Greetings all,

I am looking for some options here.

I am in need of creating a service on our web server that will always be
available and automated.
It will accept an XML file.

I will be checking to see if the XML file is valid and then passing it on
to another server.
But I need to accept this file without using a submit form.
I have never done anything like this and looking for ideas.

I am using a lamp environment and looking for suggestions.

I am looking to set this up so that our vendors can set up scripts to
automatically post XML files to our servers.

Blessed Be

Phillip

In the Jim Crow South, for example, government failed and indeed refused
to protect blacks from extra-legal violence. Given our history, it's
stunning we fail to question those who would force upon us a total reliance
on the state for defense.
-- Robert J. Cottrol


Re: [PHP] XML/PHP web service

2012-08-08 Thread Phillip Baker
I was wondering how that would work and if it might be that simple.
How would I inform the client to hit the page (script)?

Blessed Be

Phillip

In the Jim Crow South, for example, government failed and indeed refused
to protect blacks from extra-legal violence. Given our history, it's
stunning we fail to question those who would force upon us a total reliance
on the state for defense.
-- Robert J. Cottrol



On Wed, Aug 8, 2012 at 4:27 PM, Ashley Sheridan 
a...@ashleysheridan.co.ukwrote:



 Phillip Baker phil...@freewolf.net wrote:

 Greetings all,
 
 I am looking for some options here.
 
 I am in need of creating a service on our web server that will always
 be
 available and automated.
 It will accept an XML file.
 
 I will be checking to see if the XML file is valid and then passing it
 on
 to another server.
 But I need to accept this file without using a submit form.
 I have never done anything like this and looking for ideas.
 
 I am using a lamp environment and looking for suggestions.
 
 I am looking to set this up so that our vendors can set up scripts to
 automatically post XML files to our servers.
 
 Blessed Be
 
 Phillip
 
 In the Jim Crow South, for example, government failed and indeed
 refused
 to protect blacks from extra-legal violence. Given our history, it's
 stunning we fail to question those who would force upon us a total
 reliance
 on the state for defense.
 -- Robert J. Cottrol

 Just set up your php script as if it were accepting input from a form
 submission. All you're doing is not showing the form. Imagine it like a
 form set up on someone else's server with the action attribute pointing to
 your script.

 Ashley  Sheridan
 http://www.ashleysheridan.co.uk

 --
 Sent from my Android phone with K-9 Mail. Please excuse my brevity.



[PHP] Looking for a little MySQL help as well

2010-07-12 Thread Phillip Baker
Hey All,

I am looking for a little MySQL Query help as well.
I am not getting any response form the MySQl Email list to my query.
And knowing there are some SQL wizards on this list I thought I would as for
help as well.

I have one table with products that many have one or more categories.
I am using an index table and am having trouble getting a proper result set.

Table 1
Product_id  |  Product_Name
1|  Product A
2|  Product B
3|  Product C

Table 2
Category_id  |  Category_Name
1 |   Admin
2 |   Marketing
3 |   Support
4 |   IT


Table 3
Product_id  |  Category_id
1|  1
1|  3
2|  2
3|  3
3|  4

Result would look like
Product A, Admin, Support
Product B, Marketing
Product C, Support, IT

I believe this is a one to many using an index table?
I appreciate any help.
Thanks.

Blessed Be

Phillip

If you try to protect idiots from themselves, even if you succeed, you just
wind up filling the world with idiots.
   - - Doug Casey


Re: [PHP] Looking for a little MySQL help as well

2010-07-12 Thread Phillip Baker
Thanks Jim,

This outputs 2 results.
Is there a way to get the one result set per product regardless of the
number of categories associated with the product, yet displaying all the
categories associated with said prodcut?

Blessed Be

Phillip

If you try to protect idiots from themselves, even if you succeed, you just
wind up filling the world with idiots.
   - - Doug Casey


On Mon, Jul 12, 2010 at 12:21 PM, Jim Lucas li...@cmsws.com wrote:

 Phillip Baker wrote:
  Hey All,
 
  I am looking for a little MySQL Query help as well.
  I am not getting any response form the MySQl Email list to my query.
  And knowing there are some SQL wizards on this list I thought I would as
 for
  help as well.
 
  I have one table with products that many have one or more categories.
  I am using an index table and am having trouble getting a proper result
 set.
 
  Table 1
  Product_id  |  Product_Name
  1|  Product A
  2|  Product B
  3|  Product C
 
  Table 2
  Category_id  |  Category_Name
  1 |   Admin
  2 |   Marketing
  3 |   Support
  4 |   IT
 
 
  Table 3
  Product_id  |  Category_id
  1|  1
  1|  3
  2|  2
  3|  3
  3|  4
 
  Result would look like
  Product A, Admin, Support
  Product B, Marketing
  Product C, Support, IT
 
  I believe this is a one to many using an index table?
  I appreciate any help.
  Thanks.
 
  Blessed Be
 
  Phillip
 
  If you try to protect idiots from themselves, even if you succeed, you
 just
  wind up filling the world with idiots.
 - - Doug Casey
 


 SELECT
  products.Product_Name,
  categories.Category_Name
 FROM
  products,
  categories,
  p2c_map
 WHERE
  products.Product_ID = p2c_map.Product_ID
 AND
  categories.Category_ID = p2c_map.Category_ID

 Gives the results that you are looking for.  Once you get the data, you
 must
 concat things your self, but it is everything that you are looking for.

 To search for Categories of a given product, you would add this to the
 WHERE section

 AND
  products.Product_Name = 'Product A'

 of, if you were looking for all the products in a given category, you would
 add this

 AND
  categories.Category_Name = 'Category 1'


 The following is the table structure that I am using with mock data.

 CREATE TABLE IF NOT EXISTS `categories` (
  `Category_ID` int(11) NOT NULL auto_increment,
  `Category_Name` varchar(16) collate latin1_bin NOT NULL,
  PRIMARY KEY  (`Category_ID`)
 ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_bin AUTO_INCREMENT=5
 ;

 INSERT INTO `categories` (`Category_ID`, `Category_Name`) VALUES
 (1, 'Category 1'),(2, 'Category 2'),(3, 'Category 3'),(4, 'Category 4');

 CREATE TABLE IF NOT EXISTS `p2c_map` (
  `Product_id` int(11) NOT NULL,
  `Category_ID` int(11) NOT NULL,
  PRIMARY KEY  (`Product_id`,`Category_ID`)
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_bin;

 INSERT INTO `p2c_map` (`Product_id`, `Category_ID`) VALUES
 (1, 1),(1, 2),(1, 4),(2, 2),(2, 3),(3, 4),(4, 1),(4, 4);

 CREATE TABLE IF NOT EXISTS `products` (
  `Product_ID` int(11) NOT NULL auto_increment,
  `Product_Name` varchar(16) collate latin1_bin NOT NULL,
  PRIMARY KEY  (`Product_ID`)
 ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_bin AUTO_INCREMENT=5
 ;

 INSERT INTO `products` (`Product_ID`, `Product_Name`) VALUES
 (1, 'Product A'),(2, 'Product B'),(3, 'Product C'),(4, 'Product D');

 --
 Jim Lucas

 A: Maybe because some people are too annoyed by top-posting.
 Q: Why do I not get an answer to my question(s)?
 A: Because it messes up the order in which people normally read text.
 Q: Why is top-posting such a bad thing?



Re: [PHP] Looking for a little MySQL help as well

2010-07-12 Thread Phillip Baker
Thanks Tommy,

Damn.
I was hoping to avoid that and get all the information in one query rather
than running a ton of queries. :-(
But might be why I am having trouble finding an answer for this on the net.

Blessed Be

Phillip

If you try to protect idiots from themselves, even if you succeed, you just
wind up filling the world with idiots.
   - - Doug Casey


On Mon, Jul 12, 2010 at 1:37 PM, Tommy Pham tommy...@gmail.com wrote:

  -Original Message-
  From: Phillip Baker [mailto:phil...@freewolf.net]
  Sent: Monday, July 12, 2010 11:36 AM
  To: Jim Lucas
  Cc: PHP General List
  Subject: Re: [PHP] Looking for a little MySQL help as well
 
  Thanks Jim,
 
  This outputs 2 results.
  Is there a way to get the one result set per product regardless of the
 number
  of categories associated with the product, yet displaying all the
 categories
  associated with said prodcut?
 
  Blessed Be
 
  Phillip
 
 snip

 Phillip,

 What you're asking for requires the use of (IIRC) 'cursors'.  I don't know
 if MySQL's meaning/usage of 'cursors' is the same as MSSQL.  Either way,
 you'll need to write some serious (read pain in the a**) Stored Procedure
 (SP).  You're better off implementing that in PHP loop containing 'if'
 since
 you're not a DBA ;).

 Regards,
 Tommy


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




[PHP] IIS, PHP and HTML

2010-06-23 Thread Phillip Baker
Greetings All,

I am at a new Gig.
So this is the existing setup so changing it at least in the short term is
not an option.

We are in an IIS shop.
We have a bunch of files that are html, and in need of php functionality.
And that would be a BUNCH of files.

I am interested in setting if I can set up IIS to use the php interpreter on
HTML files.
And then just start using the html files as php.

There are just so many html files I would prefer to not do 301 redirects,
not header redirects and blot the server with empty files (nearly empty).
My preference is to use the existing files.

Is there a way to make this happen?
Are there any pitfalls in making this happen that I will need to be aware
of?

Blessed Be

Phillip


[PHP] Pulling Data From a Page

2006-11-06 Thread Phillip Baker

Greetings All,

Have something that I am sure is easy to do, just never done it before and
would like some guidance here.

I need to pull treasure yield percentage rates into a loan site I am working
on.

So basically I want to hit a page from another site.
Grab the HTML file.
Parse it for the values I am looking for.
And then plug it into variables for use on my site.

Any ideas on the best way to do this??

--
Blessed Be

Phillip


[PHP] Months between two dates

2006-09-15 Thread Phillip Baker

Greetings Gents,

I want to take two dates formatted as
11/1/1998
10/1/2008

And find out how many months have elapsed between them.
I was wondering if there was a quick and dirty way to do this without a for
loop.

--
Blessed Be

Phillip

The House has passed a law that would abandon the Internet's First Amendment
-- a principle called Network Neutrality that prevents companies like ATT,
Verizon and Comcast from deciding which Web sites work best for you -- based
on what site pays them the most. If the public doesn't speak up now, our
elected officials will cave to a multi-million dollar lobbying campaign.
Please contaxct your Senators to defeat this bill in the Senate.
http://www.savetheinternet.com
http://www.coanews.org/tiki-read_article.php?articleId=995
http://www.coanews.org/internetfreedom.html?page=netfreedom
http://www.gnn.tv/headlines/9484/
http://www.dearaol.com/


[PHP] Formating a Double

2006-09-06 Thread Phillip Baker

Greetings All,

I am trying to format a double to use thousands seperators and such.
number_format does not appear to be working properly for this.
My guess is cause I am trying to format a double rather than a string.
Is there anything out there that will allow me to format a double to include
a comma as a thousands seperator.
Thanks.

--
Blessed Be

Phillip

The House has passed a law that would abandon the Internet's First Amendment
-- a principle called Network Neutrality that prevents companies like ATT,
Verizon and Comcast from deciding which Web sites work best for you -- based
on what site pays them the most. If the public doesn't speak up now, our
elected officials will cave to a multi-million dollar lobbying campaign.
Please contaxct your Senators to defeat this bill in the Senate.
http://www.savetheinternet.com
http://www.coanews.org/tiki-read_article.php?articleId=995
http://www.coanews.org/internetfreedom.html?page=netfreedom
http://www.gnn.tv/headlines/9484/
http://www.dearaol.com/