Re: [PHP-DB] Creating temp tables in MSSQL

2003-12-17 Thread John Krewson
Thanks for your response Frank, but this is still driving me nuts and 
making me look like a moron at the same time (-:

This simplified query:
$query = SELECT distinct convert(varchar(36),a.traineeID) INTO #tempdata1;
$query .= FROM tblSignIn_trainee a;
$queryresult = MSSQL_QUERY($query,$cn) or die (Error in query: $query. 
 .mssql_get_last_message());

does not work.

The databases connection which I am using connects with db_datareader 
rights to SQL Server - from what I understand no special rights are 
needed to create a temporary table.

Using mssql_get_last_message()  gives me the message:Changed database 
context to 'thedatabasenameisprintedhere'.

What the heck is going on here?





Frank M. Kromann wrote:

Hi,

Any table that starts with # is a temp table. You can use

create table #mytemp (...) or you should be able to use the query you
suggest. You just have to make sure you have enough space in tempdb (a
system database)
- Frank

 

Hi all,

I've been handed a query which I'm trying to get to work.  I'm using PHP
   

 

to talk to MSSQL 7.

My question is this:  Can I create temp tables with mssql without 
executing the code in a stored procedure? 

The simplified version of the query is as follows:
$query = SELECT distinct convert(varchar(36),traineeID);
$query.= INTO #tempdata1;
$query.= FROMtblSignIn_trainee a;
Later on I could make a stored procedure, but at the moment I would like
   

 

to just work with the query directly in the code if at all possible.

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





 

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


[PHP-DB] Creating temp tables in MSSQL

2003-12-16 Thread John Krewson
Hi all,

I've been handed a query which I'm trying to get to work.  I'm using PHP 
to talk to MSSQL 7.

My question is this:  Can I create temp tables with mssql without 
executing the code in a stored procedure? 

The simplified version of the query is as follows:
$query = SELECT distinct convert(varchar(36),traineeID);
$query.= INTO #tempdata1;
$query.= FROMtblSignIn_trainee a;
Later on I could make a stored procedure, but at the moment I would like 
to just work with the query directly in the code if at all possible.

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


Re: [PHP-DB] Fake BDD

2003-12-02 Thread John Krewson
Perhaps this is what you were referring to?
http://www.c-worker.ch/txtdbapi/index_eng.php
Then there is SQLite, http://php.net/manual/en/ref.sqlite.php.  I've 
seen several tutorials out there regarding using SQLite, and it will 
probably become quite popular after PHP 5+ becomes everyone's favorite 
version.

Or, one could retrieve data from a remote mysql/postgresql database as well.

Perhaps someone has used either/both of my first two suggestions?  I'm 
rather curious about how easy PHP-TextDB API is to work with.

Best of luck,
John
BENARD Jean-philippe wrote:

Hi,

We use ORACLE DataBase for all our projects and we can't install
mysql/postgresql on our server. A new project needs a little database (only
1 table). I heard about something like an API in order to use text files in
place of real database system and that we could use SQL query to return
results. Does someone know this tool and could help us?
Many thanks in advance.

   (o_   BENARD Jean-Philippe - Consultant STERIA Infogérance
(o_   (o_   //\ RENAULT DTSI/ODPS/[EMAIL PROTECTED] * ALO * API : MLB 02C 1 14
(/)_  (\)_  V_/_   2 Av du vieil étang * 78181 MONTIGNY-LE-BRETONNEUX
  Tél : +33 1-30-03-47-83 * Fax : +33 1-30-03-42-10
 

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


Re: [PHP-DB] Extracting values from an array (I think)

2003-11-24 Thread John Krewson
If you have to assign 24 unique variables rather than storing this data 
in an array, then you could apply some variable variable action.  Here 
is a code sample that assumes you are looping through a result set from 
a database:

query =SELECT  short_label  FROM  config  ORDER BY  meter_num;
$result= @MSSQL_QUERY($query)
	or die(Can't connect or something painfully obscure);
while($row = mysql_fetch_assoc($result)) 
{
	${$short_label}=$row[short_label];
}

That will, I believe, give you a list of variables/values such as:
$short_label_1 = short_label_1
$short_label_2 = short_label_2
You can also adjust the variable name to your liking, such as:

${$short_label._counterPerhaps}=$row[short_label];

The above should be correct, but I do admit that I don't use this technique daily.

To bad you cannot just throw your values into an associative array and pluck them when 
needed
using $key = $value type of combinations.


-John

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


Re: [PHP-DB] LIMIT problem MSSQL

2003-02-19 Thread John Krewson
The title suggests MSSQL, which if I am correct doesn't support Limit 
like MySQL.

I'm working on the same thing right now so I don't have a quick and 
dirty working example, although it doesn't look to be too difficult to 
use server side cursors in MSSQL.

Here is a related a link to a similar question at phpbuilder:
http://www.phpbuilder.com/mail/php-db/2001062/0055.php

Snijders, Mark wrote:
$start = 10;

$numbers_to_show = 25;

$sql = SELECT * FROM bla Limit $start, $numbers_to_show;

or just go to mysql.com and use the manual :)

-Original Message-
From: Noam Giladi [mailto:[EMAIL PROTECTED]]
Sent: woensdag 19 februari 2003 16:00
To: [EMAIL PROTECTED]
Subject: [PHP-DB] LIMIT problem MSSQL


I'm trying to split results into different pages and number the pages
accordingly.  I've been able to build a fairly intelligent page numbering
system which knows which rows it should pull (at least by numbering each row
numerically) but I don't know how to construct a SQL query to pull 10
results starting at a certain number.

please  did anyone wrote a proc that do it?.






--
John Krewson
Programmer - SWORPS


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




Re: [PHP-DB] Date format in MySQL

2003-02-03 Thread John Krewson
strftime()

offers a lot of formatting options for dates.

Hope it helps.

RUBANOWICZ Lisa wrote:

Hi All, I have a date format of -MM-DD in MySQL and am showing it on a PHP page.  However I want to show it as 
2 February, 2003
or 2 February
Can someone please help me.  The date will not necessarily be todays date (I looked at the datetime() function and the getdate() function but couldn't work it out for these)
Thanks for your support
All the best
Lisa

Lisa Rubanowicz
CNH Ireland
Tel: +353 46 77663
Email:  mailto:[EMAIL PROTECTED] [EMAIL PROTECTED]

 

 


--
John Krewson
Programmer - SWORPS


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




Re: [PHP-DB] what does % mean?

2003-01-31 Thread John Krewson
It's a wildcard

Example:  I'm looking for the value A1 in a column that has values
A1-1, A1-2, A1-3

select count(*) from table where column like '%A1%'
will give me a count of three


Mignon Hunter wrote:

Hello list,

I am trying to decipher some code written by someone else.  In it there
is a query:

$query = select description from $prodtable where description like '%'
or type like '%' group by description;

I've seen it used as mathematical modulos, but not sure how it's used
here.  

Thx


--
John Krewson
Programmer - SWORPS


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




Re: [PHP-DB] MySQL Error

2003-01-28 Thread John Krewson

Just a shot in the dark, but be sure the socket and port settings are 
correct for your setup (whatever that might be since you did not include 
that info in your post) and that mysql is actually running.

Be sure to scour 
http://www.mysql.com/documentation/mysql/bychapter/index.html
especially the section regarding running MySQL on windows.

Sounds like a MySQL setup problem unrelated to PHP.




JordanW wrote:

I'm getting this error message when I try the following code:

$link = mysql_connect(localhost)
or die(Could not connect);
print (Connected successfully);
mysql_close($link);

The scripts outputs:

Warning: Can't create TCP/IP socket (10106) in
C:\Projects\WebServer\admin.php on line 3

Warning: MySQL Connection Failed: Can't create TCP/IP socket (10106) in
C:\Projects\WebServer\admin.php on line 3
Could not connect

Any ideas?

Thanks





--
John Krewson
Programmer - SWORPS


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




Re: [PHP-DB] too many connections?

2003-01-27 Thread John Krewson

This would make a whole lot more sense within a context...such as how 
busy is your application, what kind of connection you are using 
(pconnect vs. connect) and so on.

A quick search on MySQL's web site resulted in:

http://www.mysql.com/doc/en/Too_many_connections.html

Be sure to check out general messages in the mailing list archives as 
well and Google.

Good luck.


Addison Ellis wrote:

hello and thank you.
any idea what this means? i have not touched or changed my
config.php file since i put it up the first time... it contains my db
connect info. also, i just downloaded it from the server to see if it
had been modified and it had not. thanks again and best, addison

Warning: Too many connections in
/users/infoserv/web/register/ca/admin/config.php on line 5

Warning: MySQL Connection Failed: Too many connections in
/users/infoserv/web/register/ca/admin/config.php on line 5



--
John Krewson
Programmer - SWORPS


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




Re: [PHP-DB] using Flat File

2003-01-22 Thread John Krewson
Check to see if $PHP_AUTH_USER exists by echoing it to the browser,
and make sure you have permissions to the txt file you are trying to read.

That's all I can think of given the lack of information such as error 
messages, where it breaks, etc.


web man wrote:

Hi,

I have posted my question to this list before but I did not get a help 
that I was expected.

All I wanted to do is to give access for the users to view a page in 
which the below code is embedded. The user will enter his/her username 
and password.

But the code is not working.

I don't know what to think.

I need your help guys. Don't let me die on this code

$auth = false;
if (isset( $PHP_AUTH_USER )   isset($PHP_AUTH_PW)) {


$filename = 'c:\\php_data\\file.txt';
$f = @fopen($filename, r);
 if ($f != FALSE)
 {$a = @fread($f, filesize($filename));
fclose($f);
 }
 else
 {
  echo Could not open file;
 }



$lines = explode ( \n, $file_contents );



foreach ( $lines as $line ) {

list( $username, $password ) = explode( ':', $line );

if ( ( $username == $PHP_AUTH_USER ) 
 ( $password == $PHP_AUTH_PW ) ) {




$auth = true;
break;

}
}

}

if ( ! $auth ) {

header( 'WWW-Authenticate: Basic realm=Private' );
header( 'HTTP/1.0 401 Unauthorized' );
echo 'Authorization Required.';
exit;

} else {

echo '

You are authorized!

';
}

?






-
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now


--
John Krewson
Programmer - SWORPS


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




Re: [PHP-DB] Mail() and replies

2003-01-15 Thread John Krewson
I would say this can be done (-:

Run a quck search on freshmeat.net, sourceforge.net,
of course the manual http://www.php.net/manual/en/ref.mail.php,
and http://www.hotscripts.com/, just to name a few places to start.  Or 
just search for mailing list php on Google.

There are a ton of mailing list managers out there - check them out and 
then decide if you need to roll your own.  Many are free to use, and 
would at least offer some idea of where to start.




Baumgartner Jeffrey wrote:

Is there any way to receive mail via PHP?

What I am interested in doing is creating a double opt-in e-mail list
whereby someone can subscribe to an e-mail service via an on-line 
form. Upon
doing so, they would get a confirmation e-mail. Replying to this e-mail
would confirm the subscription and add the sender's e-mail address to the
database (MySQL).

Doable?

Thanks,

Jeffrey Baumgartner

eBusiness Consultant - ITP Europe
http://www.itp-europe.com
[EMAIL PROTECTED]
+32 2 721 51 00



--
John Krewson
Programmer - SWORPS


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




Re: [PHP-DB] HELP!! Warning: mysql_pconnect:

2002-12-13 Thread John Krewson
Try mysql_connect instead.  Doesn't sound as if you are at the stage at 
which you would realize any gains from a persistent connection.  I've 
just seen a  lot of comments regarding strange happenings with pconnect 
- which I have no doubt will be addressed later.


Don Briggs wrote:

While viewing web pages, we sometimes get the following error: Warning:
mysql_pconnect: Link to server lost, unable to reconnect in
/home/dratner/includes/common.inc on line 26 . The offending line is this
code:
if (!$db = mysql_pconnect(db1, diadba,
c0s3mST));

This line is in our common include file. It is supposed to create a
connection to the database and return an error if the connection fails. It
usually works, but sometimes we get the above error. Refreshing the page
makes the error go away, but that is not a very good solution, and we need
to figure it out before we lauch our site.

Configuration:

We are running 4.3.0RC2 and MySQL 3.23.53A on Linux 8.0. Our PHP server is
connected directly to the MySQL server via a cross-connect cable. So these
two machines have a private 100Mb connection used exclusivly for database
communication. We are currently developing an auction.

Since we are currently in development there are only two or three people
accessing the site. We are worried that the problem will get worse when the
we launch our application and we have a real work load on the server.
I would greatly appreciate any help that anyone could offer. I just can't
figure out why we sometimes have trouble connecting, especially with the
load on two large servers being so tiny.

   Don! Briggs

   [EMAIL PROTECTED]



 



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




Re: [PHP-DB] Linux+php+remote MS SQL

2002-12-13 Thread John Krewson
We are currently running two report generation applications where PHP is 
running on Linux machines and queries data from Windows NT servers 
running MSSQL 7.0

We have reports that deal with millions of records, and whether they run 
for 4 minutes or 20, I have only seen robust results from the PHP/MSSQL 
combination. (I know, 20 minutes is a long time...I didn't say that all 
of my SQL statements were robust (-:  )

Regarding remote access to SQL server 7, as far as I know the only way 
to access SQL Server remotely is from another machine also running SQL 
server.  From SQL Server Enterprise Manager you can add databases to 
access, setting the login properties to either use Windows 
authentication or SQL server authentication.   SQL Server has great 
documentation, their Books Online, and is, I believe, a pretty easy app 
to figure out.  Remotely you can add databases, change users, run 
queries, etc...again the only downside is that you need to be on windows 
running SQL Server on the client.  I've looked for a remote SQL Server 
tool that could run on OSX or Linux, but have not yet found one that 
meets all my needs...anyone?

You asked if your setup will slow down the application.  I have to ask, 
is the DB server going to be behind a firewall?  I'm no networking guru, 
but we had some speed issues initially when our DB server was behine the 
firewall and the apache server was not.  It seemed to me that there was 
time spent moving data back and forth, as now that we have both machines 
behind the firewall things have speeded up considerably. The real lesson 
I learned, however, was to make every connection count, as in get as 
much data as possible per query and lean on the Linux box to process, 
sort, count, etc if I could rather than getting a small chunk of data, 
going back to the DB, etc etc.  Considering how easy it is to remotely 
administer a Linux machine, it's too bad you can't have it with the DB 
machine.

I'm not quite sure what you mean by your last question regarding PHP's 
mssql functions vs. ODBC.   I do not and have never used ODBC to connect 
PHP to SQL Server,  although in our situation I think it would add a 
layer of complexity and possibly slow things down a bit, but that's just 
a guess.  I'm assuming you were asking if using connecting via ODBC is 
slower.

See:
http://www.php.net/manual/en/function.mssql-connect.php
http://www.phpbuilder.net/columns/alberto2919.php3

for more specific info regarding setup and mssql libraries.

Hope this was helpful.  Once you get started you should be able to find 
plenty of info in the php-db mailing list archive regarding how to make 
this setup work.



Ruth Zhai wrote:

Hi Everyone,
I have spent a few hours searching on the internet, but still can not get the information I need.  So I turn to you for help.

I will be doing a web site which has a lot of data from a remote mssql server.  The scripts will be in php and run on Linux.  As requirements, the mssql will stay at the client's internal network, and linux server will be right here with me.  For your information, we are considering using broad band connection for the web server although this has not been finalized.  The web site will initially have 3000 clients, and the db will be updated on daily basis.  For me, this is challenge because this is the first time for me to use remote db server, first time to use mssql server and first time to use combination of open source and MS products.  Forgive me if I don't ask proper questions.  The followings are my questions:

1. Will this combination cause a lot of problems?  Will it be stable enough?
2. Because the db server is not connected to the internet, I am not sure what options I have in terms of connection to the db.  Would some one point me a direction or tutorial about this?
3. Will remote access slow down the application a lot?
3. PHP has functions for mssql.  Does any one know how those compare with ODBC?

I would appreciate if you could share your experience with me or give me your opinion on the above issues.

Thank you very much in advance.

Ruth

 



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




Re: [PHP-DB] MSSQL Problems

2002-12-05 Thread John Krewson
mssql_pconnect cannot be closed as you mentioned:
http://www.php.he.net/manual/en/function.mssql-pconnect.php

I am using this as well, calling MSSQL on a Windows box from PHP/Apache 
on Linux, and I am also getting some of the results you mentioned, 
although it behaves differently at different times so I'm sticking with 
it to tinker.

My advice would be to simply drop using mssql_pconnect and use 
mssql_connect.  You don't gain much in the way of speed by using 
mssql_pconnect and I have seen several people come away with varied 
results.  Your sys admin (or you if you do double duty) should be able 
to see if this is actually the case through SQL Server Enterprise 
Manager.  It should show the calling server, the PHP version, and that 
the connections are sleeping.  


Tim Evans wrote:

I've written a script that works perfectly for almost ten times, and then
stops being able to connect to the MSSQL server.  I imagine this has
something to do with me not properly closing my connection, and the server
having a maximum # of connections.

I'm calling both mssql_free_result() and mssql_close() after every query.
I'm using mssql_pconnect.

I would include sample code, but it does this whether I use code ripped
right from examples and docs or I write it myself.  It doesn't seem to
matter what database, or the type or amount of information I'm requesting.

Thanks for any help I get on this problem, it's driving me nuts.



 



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




Re: [PHP-DB] Re: Get Last ID Inserted

2002-11-21 Thread John Krewson
Please don't ban more for this example using VB, but this is how I did 
it a while ago in VB/ASP, generating and setting the RecID in one 
stroke.  I assume you could just wrap this in PHP and it would work just 
as well.

   strSQL=Select newid()
   RecID = objConn.Execute(strSQL)(0).value



Ryan Marrs wrote:

I do see that picking up the incorrect ID, which is why we created a stored
procedure which returned the affected row.


-Original Message-
From: Adam Voigt [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, November 21, 2002 11:13 AM
To: David Elliott
Cc: Adam Voigt on PHP-DB
Subject: Re: [PHP-DB] Re: Get Last ID Inserted

But if there are heavy operations on the site, will this not also pick
up a different last inserted id, if in the split milisecond between the
insert and the next mssql_query which has the @@identity say, another
user does an insert?

On Thu, 2002-11-21 at 11:03, David Elliott wrote:
 

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello Adam

On 21 November 2002 at 10:47:15 -0500 (which was 15:47 where I live) Adam
Voigt wrote

   

Using Microsoft SQL does anyone know how to get the id of the row that
you just inserted without clumsily trying to select the id back based on
the same criteria of your insert (which might be overlapping)?
 

select @@identity

- --
Cheers,   ___
 David   |David  Elliott|   Software Engineer
   

|
 

_| [EMAIL PROTECTED] | PGP Key ID 0x650F4534
   

|
 

| No dinner with Mel Gibson?! - Dot Warner
   

|
 

-BEGIN PGP SIGNATURE-
Version: 6.5.8ckt http://www.ipgpp.com/

iQA/AwUBPd0DwfmK8eZlD0U0EQI3fACgsv52o5AvhuroJIVYblYXTnkiDZYAn2Ao
y1AeA+bR4KPOwZhZTAa2x7kr
=f/lr
-END PGP SIGNATURE-


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

   



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




Re: [PHP-DB] Fastest, easiest Flatfile DB with PHP

2002-11-18 Thread John Krewson
For one, I don't see how it would be beneficial to store large quantities
of data in a non-database type of format.
As far as reducing the overhead of using MySQL, there are many methods one
can use to reduce the number of queries to a database.  For instance, if
you are worried about making many small queries, you might want to look
into creating large arrays of data from few queries, and then breaking out
those arrays into the pieces you need throughout your program.  I just
revamped some code I did a
while back and did the very same thing, making one db call to create a big
array, and passing sections of that array that I had broken into
multi-dimensional arrays to various functions.  This change cut the
processing time in half.

Another option is using reduced data sets for certain tasks, if you can
tell from the beginning  of the program that only certain groups of data
will be needed, such as per date entered, age, etc.


| John Krewson   |
| 865-974-3263   |
| [EMAIL PROTECTED]|   
|Senior Programmer/Analyst   |
 Social Work Office of Research and Public Service

The true art of memory is the art of attention.
Samuel Johnson

On Mon, 18 Nov 2002, Teemu Pentinsaari wrote:

 hi,
 
 Maybe someone here can point me the way ...
 I'm looking for a fast and easy to use flatfile database working with PHP.
 The amount of stored data, the frequency and number of queries are really
 massive so I'm hoping to be able to skip MySql and build this service with
 some alternative technique. Anyone ?
 
 thanks
 
 Teemu
 
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 



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




Re: [PHP-DB] Best reporting Tool

2002-11-14 Thread John KRewson

I have recently been creating reports using PHP's pdf libraries. 
Somewhat time consuming to develop them from scratch and the client has 
to have the acrobat reader, but they look slick, I must say.  Another 
option is to create RTF or PDF templates and simply replace certain 
areas with your data.

This might not be what you are looking for, but a couple of places to start:
http://zope1.devshed.com/zope.devshed.com/Server_Side/PHP/PDF/page1.html
http://www.phpbuilder.com/columns/perugini20001026.php3

One nice thing about this is that quite a few people seem to be 
developing classes for this kind of reporting.


Mohammad Saad wrote:

Hi, I wanted to ask a question, Whats the best way of developing reports in
PHP. I mean in case of ASP, developers use Crystal Reports but apparently
PHP doesn't support Crystal Reports. so is there any other tool for me? or
should I use conventional method of writing database queries, PHP paging and
HTML table formatting to generate reports. The reason I am asking is this,
that for a particular project I need to come up with around 175 reports,
Although am sure some of the reports formats will be the same so I can just
switch queries in those. but still is there any other better way out, are
Oracle Reports supported in PHP?

Thanks in Advance
Saad


 



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