[PHP-DB] A text file include ?

2002-03-25 Thread Dave Carrera

Hi All,

 

I know how to include the contents of a test file into my app.

 

But at the moment I have to type in p/p tags to make in render
properly.

 

Is there a way of reading the contents and dynamically creating
paragraph breaks or line breaks?

 

 

 

Dave Carrera

Php Developer

http://davecarrera.freelancers.net

http://www.davecarrera.com

 

 




Re: [PHP-DB] A text file include ?

2002-03-25 Thread Marius Ursache



Dave Carrera a écrit :

 Hi All,



 I know how to include the contents of a test file into my app.



 But at the moment I have to type in p/p tags to make in render
 properly.



 Is there a way of reading the contents and dynamically creating
 paragraph breaks or line breaks?




yes

ereg_replace/preg_replace. searcg for \t (tab) \n (enter) and so on...






 Dave Carrera

 Php Developer

 http://davecarrera.freelancers.net

 http://www.davecarrera.com





--
  Marius Ursache (3563 || 3494)

   \|/  \|/
   '/ ,. \`
   /_| \__/ |_\
  \__U_/



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




[PHP-DB] Comparing Strings

2002-03-25 Thread John Fishworld

Whats the best way to compare 2 strings (city names - one in db one user
entry)
At the moment I'm thinking to do the following ;

strip spaces
convert to lower
and then compare !

Has anyone got any better/other suggestions ??

regards
John



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




[PHP-DB] HELP ME PLEASE: php not run on IIS 4.0

2002-03-25 Thread Berlina

Hi,

Im trying to install PHP 4.1.2 under Windows 2000 Server and IIS 4.0

* If I configure PHP as a MODULE, all run but SESSIONS DON'T WORK
* If I configure PHP as a CGI, SESSIONS WORK but ORACLE MODULE for PHP not
load

Any ideas?
Anybody can help me?

Advanced thanks,
Berli

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




Re: [PHP-DB] Comparing Strings

2002-03-25 Thread Henrique Flach Latorre Moreno

You could use the eregi() using regular expression,
it's probably the best way

see how 2 use in the http://www.php.net
At 11:59 25/03/02 +0100, you wrote:
Whats the best way to compare 2 strings (city names - one in db one user
entry)
At the moment I'm thinking to do the following ;

strip spaces
convert to lower
and then compare !

Has anyone got any better/other suggestions ??

regards
John



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

Henrique Flach Latorre Moreno
Smart Tech Consulting
www.smartech.com.br
Av. Rio Branco 181, 1005
Centro - Rio de Janeiro - RJ
Tels : (21) 2532-6335


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




Re: [PHP-DB] Comparing Strings

2002-03-25 Thread Andrey Hristov

If using mysql then the string comparison of fields is case insensitive except if the 
(var)char column is BINARY.
AFAIK mysql has support for RegEx-es. If you decide to use PHP, then use 
preg_match/replace but with 'i' modifier. This will make
the search case-insensitivi and will be faster than eregi().



Regards,
Andrey Hristov
- Original Message -
From: John Fishworld [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, March 25, 2002 12:59 PM
Subject: [PHP-DB] Comparing Strings


 Whats the best way to compare 2 strings (city names - one in db one user
 entry)
 At the moment I'm thinking to do the following ;

 strip spaces
 convert to lower
 and then compare !

 Has anyone got any better/other suggestions ??

 regards
 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] 2 related ?'s email users

2002-03-25 Thread Dave Carrera

Hi All

 

I hope you can shed some light on the logic behind these 2 issues.

 

1)   How do I make an email verify type of thing? So user enter
there email address as part of the sign up process and we send an email
to that address. That bit I've got. But how do you check the reply to
the address stored and then activate the account. It's a for online
support manager im writing hence the importance of a verified email
address.

2)   Suggest a Username? I have seen some places that when you put
in an onscreen name and click send it checks against the list of
usernames already stored and if it matches it comes back an error saying
that username already exists but how about this one, which is the name
you chose plus a incremental number. So visitor puts in say Fred but
Fred exists and so does Fred up to Fred19. How do I check this and offer
Fred20 as a suggestion.

 

I hope someone can help with this.

 

As always I thank you in advance of any help, code samples or pointers.

 

 

Dave Carrera

Php Developer

http://davecarrera.freelancers.net

http://www.davecarrera.com

 

 




RE: [PHP-DB] 2 related ?'s email users

2002-03-25 Thread Rick Emery

There's a bunch of ways to accomplish what you request.  Therefore, I'll
offer what I would do.   Other folks, more brilliant than, will provide
better ideas.

1.  Do you have access to the mail server?  For instance, I run qmail on my
SOHO system and, therefore, have full sys-admin rights.  If you do, you can
include a unique identifier in the return address.  When the newly-signed
user responds to the email, your mail server could send the email to the
authentication program which would then update the database to reflect a
valid user.

2.  I would search for all users name Fred%:
SELECT username FROM mytable WHERE username LIKE Fred% ORDER BY username;

in your PHP program:
$base = Fred; //you've set $base from the submitted form
$query = SELECT username FROM mytable WHERE username LIKE $base% ORDER BY
username;
$result = mysql_query($query) or die(...);
if( mysql_num_rows($result) == 0 )
{
... this is a unique name...
}
else
{
$i = 0; $validname = $base.1;
while( list($uname) = mysql_fetch_array($result) )
{
if( ! strcmp($uname, $validname ) { $i++; $ validname =
$base${i}; }
}
}

Therefore, $validname holds the unused user name to suggest.

-Original Message-
From: Dave Carrera [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 25, 2002 8:15 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] 2 related ?'s email  users


Hi All

 

I hope you can shed some light on the logic behind these 2 issues.

 

1)   How do I make an email verify type of thing? So user enter
there email address as part of the sign up process and we send an email
to that address. That bit I've got. But how do you check the reply to
the address stored and then activate the account. It's a for online
support manager im writing hence the importance of a verified email
address.

2)   Suggest a Username? I have seen some places that when you put
in an onscreen name and click send it checks against the list of
usernames already stored and if it matches it comes back an error saying
that username already exists but how about this one, which is the name
you chose plus a incremental number. So visitor puts in say Fred but
Fred exists and so does Fred up to Fred19. How do I check this and offer
Fred20 as a suggestion.

 

I hope someone can help with this.

 

As always I thank you in advance of any help, code samples or pointers.

 

 

Dave Carrera

Php Developer

http://davecarrera.freelancers.net

http://www.davecarrera.com

 

 


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




[PHP-DB] oracle 8.1.7 and php 4.1.2 problems

2002-03-25 Thread V.T.Marvin

Hi,

can somebody help me with my problem? I am out of  any ideas right now /
after two days of trying...

Compiling PHP 4.1.2 with oracle support (8.1.7.0.1) on Debian Linux
(potato 2.2r5)
already compiled Apache 1.3.24 with DSO support...
when compiled without oci8 PHP runs fine
when compiled with oci8 (it compiles without any error) it just won't
run / apache won't start.
It says no errors on stdout nor in apache error.log

Oracle installation looks fine (works for other programs / including my
own progs compiled with oracle support libraries)

these are configs I use to compile apache and php:
./configure --prefix=/usr/local/apache --enable-module=so
--sysconfdir=/etc/apache
./configure --without-mysql --with-oci8
--with-apxs=/usr/local/apache/bin/apxs --with-config-file-path=/etc/php4

(i used --enable-sigchild also but with same result)

it (libphp4.so) has all libs it needs to run (according to ldd)

I tried it many times with slight different configs (mysql support
disabled etc.) but same with result.

Does anybody know the  solution?

Thanx for any help

Mar[vt]in




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




RE: [PHP-DB] ODBC -- Setting ApplicationID

2002-03-25 Thread Andrew Hill

Bruce,

I'm not sure what you are trying to do - could you clarify?
You may be able to simply use the OpenLink Rules Book to set role-based
authentication on domain, ip, application, etc.

Also, the ODBC Driver version (1.5) you are using is _very_ old and
unsupported.
I suggest you upgrade to 4.2

Best regards,
Andrew Hill
Director of Technology Evangelism
OpenLink Software  http://www.openlinksw.com
Universal Data Access  Data Integration Technology Providers


 -Original Message-
 From: Bruce S. Garlock [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, March 21, 2002 11:02 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] ODBC -- Setting ApplicationID


 I am trying to set the ApplicationID, when connecting to an ODBC
 datasource.  I have tried:

 odbc_setoption ($conn, 1, 1053, PHPAPP);

 And get a:

 SQL error: [iODBC][Driver Manager]Option type out of range, SQL state
 S1092 in SetConnectOption

 Basically, I want my PHP script to pass the application name to the ODBC
 server, so that I can set up a mapping on the server that allows write
 access when a certain application string is sent.

 PHP 4.06 (with file-upload patch)
 Openlink ODBC 1.5
 Linux Client
 SCO Informix 5 server


 TIA-

 Bruce




 --
 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] ODBC -- Setting ApplicationID

2002-03-25 Thread Bruce S. Garlock

Sure, I'm simply trying to have PHP pass an ApplicationID to the ODBC server.
When a PHP script access the ODBC database, it does not set the application:

10:46:04   connectopts= user=webuser opsys=unix machine=linux application=

As you can see, application= is NULL.  I would like the script to pass
something, so that my mapping rules on the server would allow write access to
the db, if the PHP application sends a certain name.  Currently our Win32
applications, like MS Access, send application names.  e.g. Access, sends:
application=MSACCESS.

Thanks for your help,

Bruce

Andrew Hill wrote:

 Bruce,

 I'm not sure what you are trying to do - could you clarify?
 You may be able to simply use the OpenLink Rules Book to set role-based
 authentication on domain, ip, application, etc.

 Also, the ODBC Driver version (1.5) you are using is _very_ old and
 unsupported.
 I suggest you upgrade to 4.2

 Best regards,
 Andrew Hill
 Director of Technology Evangelism
 OpenLink Software  http://www.openlinksw.com
 Universal Data Access  Data Integration Technology Providers

  -Original Message-
  From: Bruce S. Garlock [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, March 21, 2002 11:02 AM
  To: [EMAIL PROTECTED]
  Subject: [PHP-DB] ODBC -- Setting ApplicationID
 
 
  I am trying to set the ApplicationID, when connecting to an ODBC
  datasource.  I have tried:
 
  odbc_setoption ($conn, 1, 1053, PHPAPP);
 
  And get a:
 
  SQL error: [iODBC][Driver Manager]Option type out of range, SQL state
  S1092 in SetConnectOption
 
  Basically, I want my PHP script to pass the application name to the ODBC
  server, so that I can set up a mapping on the server that allows write
  access when a certain application string is sent.
 
  PHP 4.06 (with file-upload patch)
  Openlink ODBC 1.5
  Linux Client
  SCO Informix 5 server
 
 
  TIA-
 
  Bruce
 
 
 
 
  --
  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] ODBC -- Setting ApplicationID

2002-03-25 Thread Andrew Hill

Hi Bruce,

The setoption error is being thrown because you cannot use
SQLSetConnectOption that way.
Passing arbitrary info to be used by your application isn't really what this
is for, but instead can be used to modify parameters in the ODBC API.

This means you can modify things like SQL_ACCESS_MODE, SQL_AUTOCOMMIT,
SQL_ODBC_CURSORS, etc., (check the 2.x spec - there are several metadata
items that you can control with this API call.)

I'd recommend you just pass a variable to your PHP script, and perhaps
change the username to a read-only/read-write user with  a case statement or
somesuch, based on the application.

Again, I'd strongly recommend you upgrade the OpenLink UDA version as well;
1.5 is something like 5 years old or more.

Best regards,
Andrew Hill
Director of Technology Evangelism
http://www.openlinksw.com/virtuoso/whatis.htm
OpenLink Virtuoso Internet Data Integration Server



 -Original Message-
 From: Bruce S. Garlock [mailto:[EMAIL PROTECTED]]
 Sent: Monday, March 25, 2002 10:48 AM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] ODBC -- Setting ApplicationID


 Sure, I'm simply trying to have PHP pass an ApplicationID to the
 ODBC server.
 When a PHP script access the ODBC database, it does not set the
 application:

 10:46:04   connectopts= user=webuser opsys=unix machine=linux application=

 As you can see, application= is NULL.  I would like the script to pass
 something, so that my mapping rules on the server would allow
 write access to
 the db, if the PHP application sends a certain name.  Currently our Win32
 applications, like MS Access, send application names.  e.g. Access, sends:
 application=MSACCESS.

 Thanks for your help,

 Bruce

 Andrew Hill wrote:

  Bruce,
 
  I'm not sure what you are trying to do - could you clarify?
  You may be able to simply use the OpenLink Rules Book to set role-based
  authentication on domain, ip, application, etc.
 
  Also, the ODBC Driver version (1.5) you are using is _very_ old and
  unsupported.
  I suggest you upgrade to 4.2
 
  Best regards,
  Andrew Hill
  Director of Technology Evangelism
  OpenLink Software  http://www.openlinksw.com
  Universal Data Access  Data Integration Technology Providers
 
   -Original Message-
   From: Bruce S. Garlock [mailto:[EMAIL PROTECTED]]
   Sent: Thursday, March 21, 2002 11:02 AM
   To: [EMAIL PROTECTED]
   Subject: [PHP-DB] ODBC -- Setting ApplicationID
  
  
   I am trying to set the ApplicationID, when connecting to an ODBC
   datasource.  I have tried:
  
   odbc_setoption ($conn, 1, 1053, PHPAPP);
  
   And get a:
  
   SQL error: [iODBC][Driver Manager]Option type out of range, SQL state
   S1092 in SetConnectOption
  
   Basically, I want my PHP script to pass the application name
 to the ODBC
   server, so that I can set up a mapping on the server that allows write
   access when a certain application string is sent.
  
   PHP 4.06 (with file-upload patch)
   Openlink ODBC 1.5
   Linux Client
   SCO Informix 5 server
  
  
   TIA-
  
   Bruce
  
  
  
  
   --
   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 Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] ODBC -- Setting ApplicationID

2002-03-25 Thread Bruce S. Garlock

I was thinking of using the usernames, but as people come and go, that might
mean messing around with the oplrqb.ini file too much.  I'd really like to do
this based on application.  What variable do I pass with the PHP script?  ( I'm
not sure what you mean ).  Can I use a variable in PHP that passes the
application name to the server?

Thanks,

Bruce



Andrew Hill wrote:

 Hi Bruce,

 The setoption error is being thrown because you cannot use
 SQLSetConnectOption that way.
 Passing arbitrary info to be used by your application isn't really what this
 is for, but instead can be used to modify parameters in the ODBC API.

 This means you can modify things like SQL_ACCESS_MODE, SQL_AUTOCOMMIT,
 SQL_ODBC_CURSORS, etc., (check the 2.x spec - there are several metadata
 items that you can control with this API call.)

 I'd recommend you just pass a variable to your PHP script, and perhaps
 change the username to a read-only/read-write user with  a case statement or
 somesuch, based on the application.

 Again, I'd strongly recommend you upgrade the OpenLink UDA version as well;
 1.5 is something like 5 years old or more.

 Best regards,
 Andrew Hill
 Director of Technology Evangelism
 http://www.openlinksw.com/virtuoso/whatis.htm
 OpenLink Virtuoso Internet Data Integration Server

  -Original Message-
  From: Bruce S. Garlock [mailto:[EMAIL PROTECTED]]
  Sent: Monday, March 25, 2002 10:48 AM
  To: [EMAIL PROTECTED]
  Subject: Re: [PHP-DB] ODBC -- Setting ApplicationID
 
 
  Sure, I'm simply trying to have PHP pass an ApplicationID to the
  ODBC server.
  When a PHP script access the ODBC database, it does not set the
  application:
 
  10:46:04   connectopts= user=webuser opsys=unix machine=linux application=
 
  As you can see, application= is NULL.  I would like the script to pass
  something, so that my mapping rules on the server would allow
  write access to
  the db, if the PHP application sends a certain name.  Currently our Win32
  applications, like MS Access, send application names.  e.g. Access, sends:
  application=MSACCESS.
 
  Thanks for your help,
 
  Bruce
 
  Andrew Hill wrote:
 
   Bruce,
  
   I'm not sure what you are trying to do - could you clarify?
   You may be able to simply use the OpenLink Rules Book to set role-based
   authentication on domain, ip, application, etc.
  
   Also, the ODBC Driver version (1.5) you are using is _very_ old and
   unsupported.
   I suggest you upgrade to 4.2
  
   Best regards,
   Andrew Hill
   Director of Technology Evangelism
   OpenLink Software  http://www.openlinksw.com
   Universal Data Access  Data Integration Technology Providers
  
-Original Message-
From: Bruce S. Garlock [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 21, 2002 11:02 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] ODBC -- Setting ApplicationID
   
   
I am trying to set the ApplicationID, when connecting to an ODBC
datasource.  I have tried:
   
odbc_setoption ($conn, 1, 1053, PHPAPP);
   
And get a:
   
SQL error: [iODBC][Driver Manager]Option type out of range, SQL state
S1092 in SetConnectOption
   
Basically, I want my PHP script to pass the application name
  to the ODBC
server, so that I can set up a mapping on the server that allows write
access when a certain application string is sent.
   
PHP 4.06 (with file-upload patch)
Openlink ODBC 1.5
Linux Client
SCO Informix 5 server
   
   
TIA-
   
Bruce
   
   
   
   
--
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 Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] RE: Creating a good search engine

2002-03-25 Thread Andrew Chase

You might want to check out this article on Webmonkey:

http://hotwired.lycos.com/webmonkey/97/16/index2a.html?tw=programming

The article uses Perl, but the concepts are easy enough to translate to PHP.
:)

-Andy

 -Original Message-
 From: Mike de Libero [mailto:[EMAIL PROTECTED]]
 Sent: Friday, March 22, 2002 6:54 AM
 To: [EMAIL PROTECTED]
 Subject: Creating a good search engine


 Hi Guys,

 I need to create a search engine that catalogs data from
 about 4 separate tables, and then of course is searchable from
 use input.  I'm having a brain fart on how I should go about
 doing this.  This is what I think I should do so far tell me if
 I'm right or at least going in the right direction.


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




[PHP-DB] MSSQL and cyrilic symbols ...

2002-03-25 Thread Nikolay Todorov

I have this problem
mssql_query - returns DOS format strings and this changes my cyrilic data
result from text fields.
with mysql_query - no prolem (on MySQL DB of cource)

--
Nikolay Todorov



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




[PHP-DB] delete statement question

2002-03-25 Thread Andrés Felipe Hernández

Hi, I hope you can help me with this:

I have these 3 tables.

exam (
exam_id
)

questions (
question_id
exam_id
)

answers (
answer_id
question_id
)

I am wondering if i can delete all the rows for answers linked to a given
exam using only one delete statement.

Thanks in advance,

andres


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




Re: [PHP-DB] delete statement question

2002-03-25 Thread Bill Morrow

On Mon, Mar 25, 2002 at 02:42:08PM -0800, Andr?s Felipe Hern?ndez wrote:
 Hi, I hope you can help me with this:
 
 I have these 3 tables.
 
 exam (
 exam_id
 )
 
 questions (
 question_id
 exam_id
 )
 
 answers (
 answer_id
 question_id
 )
 
 I am wondering if i can delete all the rows for answers linked to a given
 exam using only one delete statement.
 
 Thanks in advance,
 
 andres
 

delete answers 
where question_id in (select question_id from questions where exam_id=X)

I assume there isn't a one-to-one relationship between questions and
answers? If there is, your database is overnormalized.

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




RE: [PHP-DB] delete statement question

2002-03-25 Thread Rick Emery

if you are using mysql 4.x, you might try:

DELETE answers FROM exam e, questions q, answers a WHERE
a.question_id=q.question_id  q.exam_id=e.exam_id;

I've not tested this, though.

-Original Message-
From: Andrés Felipe Hernández [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 25, 2002 4:42 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] delete statement question


Hi, I hope you can help me with this:

I have these 3 tables.

exam (
exam_id
)

questions (
question_id
exam_id
)

answers (
answer_id
question_id
)

I am wondering if i can delete all the rows for answers linked to a given
exam using only one delete statement.

Thanks in advance,

andres


-- 
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] delete statement question

2002-03-25 Thread Rick Emery

this solution will not work for mysql databases, as mysql does not support
sub-selects

-Original Message-
From: Bill Morrow [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 25, 2002 2:02 PM
To: Andr?s Felipe Hern?ndez
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] delete statement question


On Mon, Mar 25, 2002 at 02:42:08PM -0800, Andr?s Felipe Hern?ndez wrote:
 Hi, I hope you can help me with this:
 
 I have these 3 tables.
 
 exam (
 exam_id
 )
 
 questions (
 question_id
 exam_id
 )
 
 answers (
 answer_id
 question_id
 )
 
 I am wondering if i can delete all the rows for answers linked to a given
 exam using only one delete statement.
 
 Thanks in advance,
 
 andres
 

delete answers 
where question_id in (select question_id from questions where exam_id=X)

I assume there isn't a one-to-one relationship between questions and
answers? If there is, your database is overnormalized.

-- 
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] I have been trying to introduce data in a MySQL database but I don't achieve it.

2002-03-25 Thread Sergio Cornejo

Hi.

I have been trying to introduce data in a MySQL database but I don't achieve
it.

I work with MySQL 3.23.47 for windows 98, Apache 1.3.23 for windows and
PHP4.

The form code:

form name=frm_Registro method=post action=tievir/regMay.php
  table width=91% border=0 name=tbl_login bgcolor=#33CCFF
tr
  td width=18% height=27font color=#99 face=Verdana,
Arial, Helvetica, sans-serifNombre:/font/td
  td height=27 colspan=2font face=Verdana, Arial, Helvetica,
sans-serif color=#99
input type=text name=Cli_Nombre maxlength=50 size=50
/font /td
/tr
tr
  td width=18%font color=#99 face=Verdana, Arial, Helvetica,
sans-serifEmpresa:/font/td
  td colspan=2 font color=#99 face=Verdana, Arial,
Helvetica, sans-serif
font size=-1
input type=text name=Cli_Empresa maxlength=50 size=50
br
Si no pertenece a alguna empresa coloque
quot;Independientequot;/font/font/td
/tr
tr
  td width=18%
pfont color=#99 face=Verdana, Arial, Helvetica,
sans-serifDireccioacute;n:/font/p
  /td
  td colspan=2font color=#99 face=Verdana, Arial, Helvetica,
sans-serif
input type=text name=Cli_Direccion maxlength=60
size=60/font/td
/tr
tr
  td width=18%font color=#99 face=Verdana, Arial, Helvetica,
sans-serifTeleacute;fono:/font/td
  td colspan=2font color=#99 face=Verdana, Arial, Helvetica,
sans-serif
input type=text name=Cli_Telefono maxlength=7 size=10
/font/td
/tr
tr
  td width=18%font color=#99 face=Verdana, Arial, Helvetica,
sans-serifCiudad:/font/td
  td colspan=2font color=#99 face=Verdana, Arial, Helvetica,
sans-serif
input type=text name=Cli_Ciudad maxlength=25 size=25
/font/td
/tr
tr
  td width=18%font color=#99 face=Verdana, Arial, Helvetica,
sans-serifDepartamento:/font/td
  td colspan=2font color=#99 face=Verdana, Arial, Helvetica,
sans-serif
input type=text name=Cli_Departamento maxlength=25 size=25
/font/td
/tr
tr
  td width=18%font color=#99 face=Verdana, Arial, Helvetica,
sans-serifPais:/font/td
  td colspan=2font color=#99 face=Verdana, Arial, Helvetica,
sans-serif
input type=text name=Cli_Pais maxlength=25 size=25
/font/td
/tr
tr
  td height=19 width=18%font color=#99 face=Verdana,
Arial, Helvetica, sans-serife-mail:/font/td
  td height=19 colspan=2font color=#99 face=Verdana,
Arial, Helvetica, sans-serif
input type=text name=Cli_Email maxlength=60 size=60
/font/td
/tr
tr
  td height=19 width=18%font color=#99 face=Verdana,
Arial, Helvetica, sans-serifUsuario:/font/td
  td height=19 width=16%font color=#99 face=Verdana,
Arial, Helvetica, sans-serif
input type=text name=Cli_Usuario maxlength=15 size=17
nbsp;nbsp;/font/td
  td height=19 width=66%font color=#99 face=Verdana,
Arial, Helvetica, sans-serif size=-1Debe
ser de miacute;nimo 8 y maacute;ximo 15 caracteres. Solo acepta
caracteres
entre la A..Z y nuacute;meros del 0..9./font/td
/tr
tr
  td height=19 width=18%font color=#99 face=Verdana,
Arial, Helvetica, sans-serifPassword:/font/td
  td height=19font color=#99 face=Verdana, Arial, Helvetica,
sans-serif
input type=password name=Cli_Password1 maxlength=8 size=10
/font/td
  td height=19font color=#99 face=Verdana, Arial, Helvetica,
sans-serif size=-1Debe
ser de miacute;nimo 5 y maacute;ximo 8 caracteres. Solo acepta
caracteres
entre la A..Z y nuacute;meros del 0..9./font/td
/tr
tr
  td height=19 width=18%
pfont color=#99 face=Verdana, Arial, Helvetica,
sans-serifConfirmacioacute;nbr
  del Password:/font/p
  /td
  td height=19font color=#99 face=Verdana, Arial, Helvetica,
sans-serif
input type=password name=Cli_Password2 maxlength=8 size=10
/font/td
  td height=19font color=#99 face=Verdana, Arial, Helvetica,
sans-serif size=-1Vuelva
a digitar el password exactamente igual que el anterior./font/td
/tr
tr
  td height=18 width=18%font color=#99 face=Verdana,
Arial, Helvetica, sans-serifRespuesta Clave:/font/td
  td height=18 colspan=2font color=#99 face=Verdana,
Arial, Helvetica, sans-serif
input type=text name=Cli_RespClave maxlength=60 size=60
br
font size=-1Esta frase se le pediraacute; en caso de que olvide
su
password./font/font/td
/tr
  /table
  div align=centerbr
input type=submit name=btn_enviar value=Enviar
input type=reset name=btn_resetF value=Borrar Formulario
  /div
/form

and the regMay.PHP code

html
body
?
$link = mysql_connect(localhost, indicol,159753);
mysql_select_db(telcellco, $link);
$result=mysql_query(SELECT USU_USUARIO,USU_NOMBRE FROM USUARIO WHERE
USU_USUARIO=$Cli_Usuario);
$existe=mysql_num_rows($result);

RE: [PHP-DB] I have been trying to introduce data in a MySQL database but I don't achieve it.

2002-03-25 Thread Rick Emery

First:  what error are you getting?
Second, make your code more readable and easier to debug:

$query = INSERT INTO usuario (USU_USUARIO, USU_CLAVE, USU_NOMBRE,
USU_EMPRESA, USU_DIRECCION, USU_TELEFONO, USU_CIUDAD, USU_DEPARTAMENTO,
USU_PAIS, USU_EMAIL, USU_REPCLAVE, USU_TIPCLIENTE).
VALUES ('$Cli_usuario','$Cli_Password1','$Cli_Nombre','$Cli_Empresa', .
'$Cli_Direccion','$Cli_Telefono','$Cli_Ciudad','$Cli_Departamento','$Cli_Pa
is','$Cli_Email','$Cli_RespClave', 'M');

print $query;  //do this to ensure you are sending the command you are
expecting to send

$result = mysql_query($query) or die(Error: .mysql_error());

-Original Message-
From: Sergio Cornejo [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 25, 2002 2:29 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] I have been trying to introduce data in a MySQL
database but I don't achieve it.


Hi.

I have been trying to introduce data in a MySQL database but I don't achieve
it.

I work with MySQL 3.23.47 for windows 98, Apache 1.3.23 for windows and
PHP4.

The form code:

form name=frm_Registro method=post action=tievir/regMay.php
  table width=91% border=0 name=tbl_login bgcolor=#33CCFF
tr
  td width=18% height=27font color=#99 face=Verdana,
Arial, Helvetica, sans-serifNombre:/font/td
  td height=27 colspan=2font face=Verdana, Arial, Helvetica,
sans-serif color=#99
input type=text name=Cli_Nombre maxlength=50 size=50
/font /td
/tr
tr
  td width=18%font color=#99 face=Verdana, Arial, Helvetica,
sans-serifEmpresa:/font/td
  td colspan=2 font color=#99 face=Verdana, Arial,
Helvetica, sans-serif
font size=-1
input type=text name=Cli_Empresa maxlength=50 size=50
br
Si no pertenece a alguna empresa coloque
quot;Independientequot;/font/font/td
/tr
tr
  td width=18%
pfont color=#99 face=Verdana, Arial, Helvetica,
sans-serifDireccioacute;n:/font/p
  /td
  td colspan=2font color=#99 face=Verdana, Arial, Helvetica,
sans-serif
input type=text name=Cli_Direccion maxlength=60
size=60/font/td
/tr
tr
  td width=18%font color=#99 face=Verdana, Arial, Helvetica,
sans-serifTeleacute;fono:/font/td
  td colspan=2font color=#99 face=Verdana, Arial, Helvetica,
sans-serif
input type=text name=Cli_Telefono maxlength=7 size=10
/font/td
/tr
tr
  td width=18%font color=#99 face=Verdana, Arial, Helvetica,
sans-serifCiudad:/font/td
  td colspan=2font color=#99 face=Verdana, Arial, Helvetica,
sans-serif
input type=text name=Cli_Ciudad maxlength=25 size=25
/font/td
/tr
tr
  td width=18%font color=#99 face=Verdana, Arial, Helvetica,
sans-serifDepartamento:/font/td
  td colspan=2font color=#99 face=Verdana, Arial, Helvetica,
sans-serif
input type=text name=Cli_Departamento maxlength=25 size=25
/font/td
/tr
tr
  td width=18%font color=#99 face=Verdana, Arial, Helvetica,
sans-serifPais:/font/td
  td colspan=2font color=#99 face=Verdana, Arial, Helvetica,
sans-serif
input type=text name=Cli_Pais maxlength=25 size=25
/font/td
/tr
tr
  td height=19 width=18%font color=#99 face=Verdana,
Arial, Helvetica, sans-serife-mail:/font/td
  td height=19 colspan=2font color=#99 face=Verdana,
Arial, Helvetica, sans-serif
input type=text name=Cli_Email maxlength=60 size=60
/font/td
/tr
tr
  td height=19 width=18%font color=#99 face=Verdana,
Arial, Helvetica, sans-serifUsuario:/font/td
  td height=19 width=16%font color=#99 face=Verdana,
Arial, Helvetica, sans-serif
input type=text name=Cli_Usuario maxlength=15 size=17
nbsp;nbsp;/font/td
  td height=19 width=66%font color=#99 face=Verdana,
Arial, Helvetica, sans-serif size=-1Debe
ser de miacute;nimo 8 y maacute;ximo 15 caracteres. Solo acepta
caracteres
entre la A..Z y nuacute;meros del 0..9./font/td
/tr
tr
  td height=19 width=18%font color=#99 face=Verdana,
Arial, Helvetica, sans-serifPassword:/font/td
  td height=19font color=#99 face=Verdana, Arial, Helvetica,
sans-serif
input type=password name=Cli_Password1 maxlength=8 size=10
/font/td
  td height=19font color=#99 face=Verdana, Arial, Helvetica,
sans-serif size=-1Debe
ser de miacute;nimo 5 y maacute;ximo 8 caracteres. Solo acepta
caracteres
entre la A..Z y nuacute;meros del 0..9./font/td
/tr
tr
  td height=19 width=18%
pfont color=#99 face=Verdana, Arial, Helvetica,
sans-serifConfirmacioacute;nbr
  del Password:/font/p
  /td
  td height=19font color=#99 face=Verdana, Arial, Helvetica,
sans-serif
input type=password name=Cli_Password2 maxlength=8 size=10
/font/td
  td height=19font color=#99 face=Verdana, Arial, Helvetica,
sans-serif size=-1Vuelva
a digitar el 

Re: [PHP-DB] delete statement question

2002-03-25 Thread Andrés Felipe Hernández

Rick, thanks for the idea but actually it wouldnt work :(

take a look:

mysql delete answers
- from exam e, questions q, answers a
- where a.question_id=q.question_id and q.exam_id=e.exam_id;
ERROR 1064: You have an error in your SQL syntax near 'answers
from exam e, questions q, exam_an' at line 1

so i think the problem is that you cant do DELETE something FROM...  i
think the solution is more like the one Bill Morrow proposed, even though he
is using a subselect and i am using my sql.

Any ideas?

thanks for the help so far,

andres


- Original Message -
From: Rick Emery [EMAIL PROTECTED]
To: Andr?s Felipe Hern?ndez [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Monday, March 25, 2002 12:03 PM
Subject: RE: [PHP-DB] delete statement question


 this solution will not work for mysql databases, as mysql does not support
 sub-selects

 -Original Message-
 From: Bill Morrow [mailto:[EMAIL PROTECTED]]
 Sent: Monday, March 25, 2002 2:02 PM
 To: Andr?s Felipe Hern?ndez
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] delete statement question


 On Mon, Mar 25, 2002 at 02:42:08PM -0800, Andr?s Felipe Hern?ndez wrote:
  Hi, I hope you can help me with this:
 
  I have these 3 tables.
 
  exam (
  exam_id
  )
 
  questions (
  question_id
  exam_id
  )
 
  answers (
  answer_id
  question_id
  )
 
  I am wondering if i can delete all the rows for answers linked to a
given
  exam using only one delete statement.
 
  Thanks in advance,
 
  andres
 

 delete answers
 where question_id in (select question_id from questions where exam_id=X)

 I assume there isn't a one-to-one relationship between questions and
 answers? If there is, your database is overnormalized.

 --
 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 Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] delete statement question

2002-03-25 Thread Rick Emery

Per my original email; you must be running MYSQL 4.0 or later.

If you are runnig version 3.x, as it appears you are, then this suggestion
will NOT work


-Original Message-
From: Andrés Felipe Hernández [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 25, 2002 5:59 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] delete statement question


Rick, thanks for the idea but actually it wouldnt work :(

take a look:

mysql delete answers
- from exam e, questions q, answers a
- where a.question_id=q.question_id and q.exam_id=e.exam_id;
ERROR 1064: You have an error in your SQL syntax near 'answers
from exam e, questions q, exam_an' at line 1

so i think the problem is that you cant do DELETE something FROM...  i
think the solution is more like the one Bill Morrow proposed, even though he
is using a subselect and i am using my sql.

Any ideas?

thanks for the help so far,

andres


- Original Message -
From: Rick Emery [EMAIL PROTECTED]
To: Andr?s Felipe Hern?ndez [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Monday, March 25, 2002 12:03 PM
Subject: RE: [PHP-DB] delete statement question


 this solution will not work for mysql databases, as mysql does not support
 sub-selects

 -Original Message-
 From: Bill Morrow [mailto:[EMAIL PROTECTED]]
 Sent: Monday, March 25, 2002 2:02 PM
 To: Andr?s Felipe Hern?ndez
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] delete statement question


 On Mon, Mar 25, 2002 at 02:42:08PM -0800, Andr?s Felipe Hern?ndez wrote:
  Hi, I hope you can help me with this:
 
  I have these 3 tables.
 
  exam (
  exam_id
  )
 
  questions (
  question_id
  exam_id
  )
 
  answers (
  answer_id
  question_id
  )
 
  I am wondering if i can delete all the rows for answers linked to a
given
  exam using only one delete statement.
 
  Thanks in advance,
 
  andres
 

 delete answers
 where question_id in (select question_id from questions where exam_id=X)

 I assume there isn't a one-to-one relationship between questions and
 answers? If there is, your database is overnormalized.

 --
 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 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] Re: Speed Up Code?

2002-03-25 Thread Lutz Brückner

Hi Jeff,

the most important rule you should follow: don't query the database
in a loop to avoid a join! The following lines (maybe some changes
are necesary) will do the same job as your code, but considerable faster. 
Especially if 'id' is an index in both tables.

Lutz


$sql = 'SELECT u.id, u.username, u.album_title,'
.' date_format(MAX(f.date), '%b. %D, %Y') as date1,'
.' COUNT(*) AS cnt'
   .' FROM Chart_Users AS u'
  .' INNER JOIN Chart_Files AS f USING (id)'
  .' GROUP BY f.id'
  .' ORDER BY u.album_title ASC';

$result = @mysql_query($sql,$connection) or die( Couldn't execute query.);

while ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$username = $row['username'];
$title1 = $row['album_title'];
$title = stripslashes($title1);
$date1 = $row['date1'];

$display_block .= trtd nowrap align=\left\ba 
$href=\display_album.php?id=$id\$titlenbsp;/a/b/tdtd 
align=\left\$cnt/tdtd align=\right\ nowrap$date1/td/tr;
}


[EMAIL PROTECTED] (Jeff Oien) writes:

 Here is some code I have for an index page of people who post
 charts on the Web, kind of like Yahoo Photos or something.
 It displays the album title, number of images and date of last
 upload. The page takes about 5-6 seconds to load which is all
 in the queries I'm sure. Is there a way I can make this more efficient?
 http://www.webdesigns1.com/temp/code.txt
 Jeff
 
 --
 
 $table_name = Chart_Users;
 $sql = SELECT * FROM $table_name order by album_title;
 $result = @mysql_query($sql,$connection) or die( Couldn't execute query.);
 //if(! $result = mysql_query($sql,$connection)) {
   //  print(ERROR .mysql_errno().: 
.mysql_error().br\n$sqlbr\n);
   //  }
 
   while ($row = mysql_fetch_array($result)) {
   $id = $row['id'];
   $username = $row['username'];
   $title1 = $row['album_title'];
   $title = stripslashes($title1);
 
   $sql1 = SELECT COUNT(*) FROM Chart_Files where id = '$id';
   $result1 = @mysql_query($sql1,$connection) or die( Couldn't execute 
query.);
   //if(! $result = mysql_query($sql1,$connection)) {
   //print(ERROR .mysql_errno().: .mysql_error().br\n$sqlbr\n);
   //}
   $count = mysql_result($result1,0,count(*));
 
   $sql2 = SELECT date_format(date, '%b. %D, %Y') as 
date1 FROM Chart_Files where
 id = '$id' order by photoid desc limit 1;
   $result2 = @mysql_query($sql2,$connection) or die( 
Couldn't execute query.);
   $row = mysql_fetch_array($result2);
   $date1 = $row['date1'];
 
   if ($count  0) {
 
   $display_block .= trtd nowrap align=\left\ba
   href=\display_album.php?id=$id\$titlenbsp;/a/b/tdtd
 align=\left\$count/tdtd align=\right\ nowrap$date1/td/tr;
   }
   }

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




[PHP-DB] Looking for Experienced PHP Programmers

2002-03-25 Thread Jeffrey Cleary

Hi all.

My apologies if this is the wrong list.

My company, JeffreyCo, Inc., is looking for one or two experienced PHP
Programmers familiar with MySQL and a Linux environment for short term
project work.

Qualified candidates should send their resume, complete with links to any
current applications on the web to [EMAIL PROTECTED]  Please include your
current hourly rate in your email.

We have several exciting short and long term projects available and new ones
showing up all the time.

Qualified candidates should have a demonstrative working knowledge of the
latest versions of PHP, MySQL and Linux Administration, along with prior PHP
application success.

Only replies with their resume and hourly rate will be considered.

Please post to another list if this is the wrong one.

Thanks,
Jeffrey Cleary
JeffreyCo, Inc.


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




RE: [PHP-DB] Re: Speed Up Code?

2002-03-25 Thread Jeff Oien

Fantastic! I'm going to have to study the code more to really understand
it. Thanks for the help. I had to change the code just a little for it to work:

$sql = SELECT u.id, u.username, u.album_title, 
date_format(MAX(f.date), '%b %D, %Y') as date1, 
COUNT(*) AS cnt FROM Chart_Users AS u
INNER JOIN Chart_Files AS f USING (id) 
GROUP BY f.id ORDER BY u.album_title ASC;

$result = @mysql_query($sql,$connection) 
or die( Couldn't execute query.);

while ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$username = $row['username'];
$title1 = $row['album_title'];
$title = stripslashes($title1);
$date1 = $row['date1'];
$cnt = $row['cnt'];

$display_block .= trtd nowrap align=\left\
ba href=\display_album.php?id=$id\$titlenbsp;/a/b/td
td align=\left\$cnt/tdtd align=\right\ nowrap$date1/td/tr;
}

 Hi Jeff,
 
 the most important rule you should follow: don't query the database
 in a loop to avoid a join! The following lines (maybe some changes
 are necesary) will do the same job as your code, but considerable faster. 
 Especially if 'id' is an index in both tables.
 
 Lutz
 
 
 $sql = 'SELECT u.id, u.username, u.album_title,'
 .' date_format(MAX(f.date), '%b. %D, %Y') as date1,'
 .' COUNT(*) AS cnt'
.' FROM Chart_Users AS u'
   .' INNER JOIN Chart_Files AS f USING (id)'
   .' GROUP BY f.id'
   .' ORDER BY u.album_title ASC';
 
 $result = @mysql_query($sql,$connection) or die( Couldn't execute query.);
 
 while ($row = mysql_fetch_array($result)) {
 $id = $row['id'];
 $username = $row['username'];
 $title1 = $row['album_title'];
 $title = stripslashes($title1);
 $date1 = $row['date1'];
 
 $display_block .= trtd nowrap align=\left\ba 
 $href=\display_album.php?id=$id\$titlenbsp;/a/b/tdtd 
 align=\left\$cnt/tdtd align=\right\ nowrap$date1/td/tr;
 }
 
 
 [EMAIL PROTECTED] (Jeff Oien) writes:
 
  Here is some code I have for an index page of people who post
  charts on the Web, kind of like Yahoo Photos or something.
  It displays the album title, number of images and date of last
  upload. The page takes about 5-6 seconds to load which is all
  in the queries I'm sure. Is there a way I can make this more efficient?
  http://www.webdesigns1.com/temp/code.txt
  Jeff
  
  --
  
  $table_name = Chart_Users;
  $sql = SELECT * FROM $table_name order by album_title;
  $result = @mysql_query($sql,$connection) or die( Couldn't execute query.);
  //if(! $result = mysql_query($sql,$connection)) {
//print(ERROR .mysql_errno().: 
 .mysql_error().br\n$sqlbr\n);
  //  }
  
  while ($row = mysql_fetch_array($result)) {
  $id = $row['id'];
  $username = $row['username'];
  $title1 = $row['album_title'];
  $title = stripslashes($title1);
  
  $sql1 = SELECT COUNT(*) FROM Chart_Files where id = '$id';
  $result1 = @mysql_query($sql1,$connection) or die( Couldn't 
 execute query.);
  //if(! $result = mysql_query($sql1,$connection)) {
  //print(ERROR .mysql_errno().: 
 .mysql_error().br\n$sqlbr\n);
  //}
  $count = mysql_result($result1,0,count(*));
  
  $sql2 = SELECT date_format(date, '%b. %D, 
 %Y') as date1 FROM Chart_Files where
  id = '$id' order by photoid desc limit 1;
  $result2 = @mysql_query($sql2,$connection) 
 or die( Couldn't execute query.);
  $row = mysql_fetch_array($result2);
  $date1 = $row['date1'];
  
  if ($count  0) {
  
  $display_block .= trtd nowrap align=\left\ba
  href=\display_album.php?id=$id\$titlenbsp;/a/b/tdtd
  align=\left\$count/tdtd align=\right\ nowrap$date1/td/tr;
  }
  }
 
 -- 
 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] procedures?

2002-03-25 Thread Chris Payne

Hi there,

Where can I find information in PLAIN terms about how to use procedures in MySQL?  
More importantly I want to be able to write my own so I don't have to keep re-using 
the same code in the way that I do now to access, delete etc  from db's.

Thank you :-)

Chris



RE: [PHP-DB] ODBC -- Setting ApplicationID

2002-03-25 Thread Andrew Hill

Bruce,

It looks like you were on the right track initially, the problem is that PHP
has a major bug - odbc_setoption is coded specific to ODBC statement handle
(connection id), which means that trying to use odbc_setoption the way you
want attempts to set a SQLSetConnectOption AFTER the connection is open -
which is bogus and will give you ODBC function sequence errors.

On the other hand, the error message you were getting is a bit misleading;
we are fixing that now.

So... you can unfortunately not do this via Application ID, but since you
are using the OpenLink Rules Book, you can still affect Session-based
connection management with any of the other connection criteria:

Here is one way to do it:
--
Setup your session attributes by configuring the Session Rules Book Aliases
section of the Multi-Tier OpenLink Admin Assistant.
(http://servername:8000).

You can configure session rules for any combination of Domain, Database,
User, Operating System, Client Machine, Client Application, etc., and can
control any connection options at the server side based on the session.

Using Database as an example, add a Database Alias with a new database
name and configure a session mapping rule to point to the original database
name, but change the connection attributes from Read / Write to Read
Only in the options for the  connection session.

On the PHP side, simply choose between two DSN's in the odbc.ini - one is
the normal DSN, with default settings, and one will have an alternate
database name, name_readonly or somesuch, that will cause the oplrqb to
instantiate the appropriate connection attributes.

If you run into problems, you should probably open a support case at
http://www.openlinksw.com/support/suppindx.htm, as this is getting somewhat
off-topic for PHP.

Hope this helps!

Best regards,
Andrew Hill
Director of Technology Evangelism
OpenLink Software  http://www.openlinksw.com
Universal Data Access  Data Integration Technology Providers





I was thinking of using the usernames, but as people come and go, that might
mean messing around with the oplrqb.ini file too much.  I'd really like to
do
this based on application.  What variable do I pass with the PHP script?
( I'm
not sure what you mean ).  Can I use a variable in PHP that passes the
application name to the server?

Thanks,

Bruce

Andrew Hill wrote:

 Hi Bruce,

 The setoption error is being thrown because you cannot use
 SQLSetConnectOption that way.
 Passing arbitrary info to be used by your application isn't really what
this
 is for, but instead can be used to modify parameters in the ODBC API.

 This means you can modify things like SQL_ACCESS_MODE, SQL_AUTOCOMMIT,
 SQL_ODBC_CURSORS, etc., (check the 2.x spec - there are several metadata
 items that you can control with this API call.)

 I'd recommend you just pass a variable to your PHP script, and perhaps
 change the username to a read-only/read-write user with  a case statement
or
 somesuch, based on the application.

 Again, I'd strongly recommend you upgrade the OpenLink UDA version as
well;
 1.5 is something like 5 years old or more.

 Best regards,
 Andrew Hill
 Director of Technology Evangelism
 http://www.openlinksw.com/virtuoso/whatis.htm
 OpenLink Virtuoso Internet Data Integration Server

  -Original Message-
  From: Bruce S. Garlock [mailto:[EMAIL PROTECTED]]
  Sent: Monday, March 25, 2002 10:48 AM
  To: [EMAIL PROTECTED]
  Subject: Re: [PHP-DB] ODBC -- Setting ApplicationID
 
 
  Sure, I'm simply trying to have PHP pass an ApplicationID to the
  ODBC server.
  When a PHP script access the ODBC database, it does not set the
  application:
 
  10:46:04   connectopts= user=webuser opsys=unix machine=linux
application=
 
  As you can see, application= is NULL.  I would like the script to pass
  something, so that my mapping rules on the server would allow
  write access to
  the db, if the PHP application sends a certain name.  Currently our
Win32
  applications, like MS Access, send application names.  e.g. Access,
sends:
  application=MSACCESS.
 
  Thanks for your help,
 
  Bruce
 
  Andrew Hill wrote:
 
   Bruce,
  
   I'm not sure what you are trying to do - could you clarify?
   You may be able to simply use the OpenLink Rules Book to set
role-based
   authentication on domain, ip, application, etc.
  
   Also, the ODBC Driver version (1.5) you are using is _very_ old and
   unsupported.
   I suggest you upgrade to 4.2
  
   Best regards,
   Andrew Hill
   Director of Technology Evangelism
   OpenLink Software  http://www.openlinksw.com
   Universal Data Access  Data Integration Technology Providers
  
-Original Message-
From: Bruce S. Garlock [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 21, 2002 11:02 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] ODBC -- Setting ApplicationID
   
   
I am trying to set the ApplicationID, when connecting to an ODBC
datasource.  I have tried:
   
odbc_setoption 

[PHP-DB] File Upload

2002-03-25 Thread David McInnis

I wrote s script to upload a file.  The script works, but when I point
my browser to the file it downloads, but I can no longer open the file
in MS Word.  What is happening to my file?  My client is Windows and the
server is Linux.

David McInnis




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




[PHP-DB] If else Question

2002-03-25 Thread Jennifer Downey

Hi all,

I have a table called pets, here is a partial dump:
At this time this is all I am working with.


uid int(10) NOT NULL default '0',
num_pet tinyint(1) NOT NULL default '1',

There are three steps to adding the pet into the db

Step 1 create the record, this is in create.php. And yes believe it or not
this does work.

$query_update = INSERT INTO pets (uid) SELECT uid FROM users WHERE
uid={$session[uid]};
$result = mysql_query($query_update)
 or die(Unable to insert into the database);

Step 2 Check to see if there is already a pet record this is in process.php.

$query=SELECT  num_pet FROM pets WHERE uid={$session[uid]};
$ret = mysql_query($query);
while(list($num_pet)=
mysql_fetch_row($ret))

// echo  the number in the db, it should = 1 until submit button clicked
echo $num_pet

$number_pet = $num_pet;

   if($number_pet == 0 ) {
   print (Sorry you can't add another pet);
   }else{ this does all the updating of the record

?
form action=petdata.php method=post
Click to continueBR
INPUT TYPE=submit VALUE=Submit NAME=submit
/form
?
}

Step three update num_pet after submit is clicked, this is in petdata.php

$db = update pets set num_pet = 0 where uid={$session[uid]};
   $ret = mysql_query($db) or die(db_error());

Now here is my question, If the submit button is clicked and num_pets is
updated to 0 and you try to add another record shouldn't this print- Sorry
you can't add another pet?

I am at a loss as to why it will keep adding records. Anyone want to take a
stab at it?

TIA
Jen



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




[PHP-DB] Suscribtion

2002-03-25 Thread David JURAS

I'd like to suscribe with [EMAIL PROTECTED] , and your confirmation e-mail 
doesn't seem to work.

Thanks,

David