[PHP-DB] generating sequence without AUTO_INCREMENT

2003-06-26 Thread anders thoresson
Hi,
I'm working on a web based article planning system for a news paper, based 
on PHP and MySQL. One vital table in the setup will contain release date 
and number for each issue. It's a simple table with just three columns:
id, which is the primary key and AUTO_INCREMENT
date, which is the release date for each issue
issue_number
I need help with a solution to automatically create the issue_number. The 
conditions is as follow:
1. The paper is published every Monday to Friday, except for national 
holidays, so issue_number isn't the same as the day number
2. The first issue each year should be number 1, and then the rest should 
follow in sequence
The first condition is taken care of manually, where one of the editors 
will input a start date and an end date between which the newspaper will be 
released Mondays to Fridays. That way I'll handle the national holidays, 
for each year the editors have to enter a couple of date sequences to 
fence out the holidays.
But keeping track of each and every issue_number manually isn't practical. 
I've looked at the MySQL manual, but all I find is LAST_INSERT_ID(). But 
from what I've understood, that function is only useful when it's the same 
value that is being updated, and this isn't the case in my problem.
So I guess I'll have to write my own function. The solution I think of 
right now is adding new issues in two steps: First adding the date for the 
new issue to the table, then checking the issue_number for the date before, 
and then adding the issue_number next in turn to the new issue, or, if the 
year differs start over from 1 again.
Is there a smarter way of doing this?

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


[PHP-DB] MSSQL VIRTUAL TABLES

2003-06-26 Thread LOUD, Mark
Hi,

I am trying to do the following query in a MSSQL 2000 database:

SELECT Order_Details.Qref, Order_Header.AgentRef
FROM Order_Details, Order_Header
WHERE Order_Details.Qref = Order_Header.Qref AND Order_Header.AgentRef =
48976

I get the following error:

Syntax error converting the varchar value 'I7502203' to a column of data
type int.

Now this value 'I7502203' is in the Order_Header table in the AgentRef
column (which is a varchar column). Obviously when the query is run the
results will be put in a virtual table but why is it creating the virtual
field of Order_Header.AgentRef as an int when in the original table it is a
varchar? Can this be pre-set in the query?

Any ideas would be handy

Mark Loud




CONFIDENTIALITY NOTICE 
The information contained in this e-mail is intended only for the
confidential use of the above named recipient. If you are not the intended
recipient or person responsible for delivering it to the intended recipient,
you have received this communication in error and must not distribute or
copy it.  Please accept the sender's apologies, notify the sender
immediately by return e-mail and delete this communication.  Thank you. 

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



Re: [PHP-DB] MSSQL VIRTUAL TABLES

2003-06-26 Thread mustafa ocak
Hi

I think the problem is in the where part of your SQL

if AgentRef is a varchar column then you should rewrite the where part  as
WHERE Order_Details.Qref = Order_Header.Qref AND Order_Header.AgentRef  like
'48976'

or

WHERE Order_Details.Qref = Order_Header.Qref AND Order_Header.AgentRef
='48976'

HTH

Mustafa

- Original Message -
From: LOUD, Mark [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, June 26, 2003 10:29 AM
Subject: [PHP-DB] MSSQL VIRTUAL TABLES


 Hi,

 I am trying to do the following query in a MSSQL 2000 database:

 SELECT Order_Details.Qref, Order_Header.AgentRef
 FROM Order_Details, Order_Header
 WHERE Order_Details.Qref = Order_Header.Qref AND Order_Header.AgentRef =
 48976

 I get the following error:

 Syntax error converting the varchar value 'I7502203' to a column of data
 type int.

 Now this value 'I7502203' is in the Order_Header table in the AgentRef
 column (which is a varchar column). Obviously when the query is run the
 results will be put in a virtual table but why is it creating the virtual
 field of Order_Header.AgentRef as an int when in the original table it is
a
 varchar? Can this be pre-set in the query?

 Any ideas would be handy

 Mark Loud




 CONFIDENTIALITY NOTICE
 The information contained in this e-mail is intended only for the
 confidential use of the above named recipient. If you are not the intended
 recipient or person responsible for delivering it to the intended
recipient,
 you have received this communication in error and must not distribute or
 copy it.  Please accept the sender's apologies, notify the sender
 immediately by return e-mail and delete this communication.  Thank you.

 --
 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] checking a string for numbers

2003-06-26 Thread Jamie Saunders
Hi,

I'm trying to find a way of simply checking a string for numbers.

e.g.

if ($myVar contains a number)
{
 //numbers present
}
else
{
 //no numbers present
}

Thanks,

-- 
Jamie Saunders
Media Architect
[EMAIL PROTECTED]



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



Re: [PHP-DB] generating sequence without AUTO_INCREMENT

2003-06-26 Thread Doug Thompson
Maybe it's because I'm not fully awake yet that the problem seems less complex than it 
is.

What is wrong with using a seperate table for each year?

Doug

On Thu, 26 Jun 2003 08:43:17 +0200, anders thoresson wrote:

Hi,
 I'm working on a web based article planning system for a news paper, based 
on PHP and MySQL. One vital table in the setup will contain release date 
and number for each issue. It's a simple table with just three columns:
 id, which is the primary key and AUTO_INCREMENT
 date, which is the release date for each issue
 issue_number
 I need help with a solution to automatically create the issue_number. The 
conditions is as follow:
 1. The paper is published every Monday to Friday, except for national 
holidays, so issue_number isn't the same as the day number
 2. The first issue each year should be number 1, and then the rest should 
follow in sequence
 The first condition is taken care of manually, where one of the editors 
will input a start date and an end date between which the newspaper will be 
released Mondays to Fridays. That way I'll handle the national holidays, 
for each year the editors have to enter a couple of date sequences to 
fence out the holidays.
 But keeping track of each and every issue_number manually isn't practical. 
I've looked at the MySQL manual, but all I find is LAST_INSERT_ID(). But 
from what I've understood, that function is only useful when it's the same 
value that is being updated, and this isn't the case in my problem.
 So I guess I'll have to write my own function. The solution I think of 
right now is adding new issues in two steps: First adding the date for the 
new issue to the table, then checking the issue_number for the date before, 
and then adding the issue_number next in turn to the new issue, or, if the 
year differs start over from 1 again.
 Is there a smarter way of doing this?

-- 
anders thoresson

-- 
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] BACKUP/RESTORE - file rights

2003-06-26 Thread Armand Turpel
Hi,

Doing a backup of db tables under mysql using

$sql = '
   BACKUP TABLE
   test_table
   TO
   backup
   '; 
give the backup files the rights of the mysql server. I my environemt 
this is:
user: mysql
group: daemon

If the apache isn't a member of the daemon group, php can not do some 
work on this files, ex.: file compression.

Question:
Is this the case, that the mysql and the apache server where members of 
the same group in most server environements?

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


Re: [PHP-DB] checking a string for numbers

2003-06-26 Thread Ignatius Reilly
$extract = preg_replace( /[^0-9]/, , $str ) 
// will extract the figures from your string

HTH
Ignatius
_
- Original Message - 
From: Jamie Saunders [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, June 26, 2003 1:04 PM
Subject: [PHP-DB] checking a string for numbers


 Hi,
 
 I'm trying to find a way of simply checking a string for numbers.
 
 e.g.
 
 if ($myVar contains a number)
 {
  //numbers present
 }
 else
 {
  //no numbers present
 }
 
 Thanks,
 
 -- 
 Jamie Saunders
 Media Architect
 [EMAIL PROTECTED]
 
 
 
 -- 
 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] MySQL Backup, final script !!!

2003-06-26 Thread Nabil
I have been searching inside the mailing lists regarding the a PHP code that
dump all or a selected databases from MySQL ...
and haven't managed to get a script like PhpMyAdmin does... please any ready
script or idea ...

?php exec(mysqldump -u root -ppassword -A  backup.sql); ?
//Because it didn't work with me (on windows by example).

All what I am thinking to do is a script that retrieved the database names
then retrieve the tables names, then fields names and dump the data in an
schema like mysqldump does

any suggestions??

Cheers...
Nabil



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



Re: [PHP-DB] checking a string for numbers

2003-06-26 Thread CPT John W. Holmes
From: Jamie Saunders [EMAIL PROTECTED]
 I'm trying to find a way of simply checking a string for numbers.
 
 e.g.
 
 if ($myVar contains a number)
 {
  //numbers present
 }
 else
 {
  //no numbers present
 }

if(preg_match('/[0-9]/',$myVar))
{
  //number present
}
else
{
  //no numbers present
}

---John Holmes...

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



Re: [PHP-DB] MySQL Backup, final script !!!

2003-06-26 Thread Armand Turpel
Hi,

You have only to modify it to your environement
It works with mysql = 3.23.52
// Get all table names of the database
   //
   $sql = '
   SHOW TABLES
   FROM
  test_db
   ;  
   $db-query($sql);
  
  
   while($row  = $db-fetchRow( 'DB_GETMODE_NUM'))
   {

   $sql = '
   BACKUP TABLE
   '.$row[0].'
   TO
   /db_backup
   '; 
   $db-query($sql);
   }

Armand



Nabil wrote:

I have been searching inside the mailing lists regarding the a PHP code that
dump all or a selected databases from MySQL ...
and haven't managed to get a script like PhpMyAdmin does... please any ready
script or idea ...
?php exec(mysqldump -u root -ppassword -A  backup.sql); ?
//Because it didn't work with me (on windows by example).
All what I am thinking to do is a script that retrieved the database names
then retrieve the tables names, then fields names and dump the data in an
schema like mysqldump does
any suggestions??

Cheers...
Nabil


 



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


Re: [PHP-DB] checking a string for numbers

2003-06-26 Thread Marco Tabini
On Thu, 2003-06-26 at 08:09, CPT John W. Holmes wrote:
 if(preg_match('/[0-9]/',$myVar))

Same thing, fewer characters:

if (preg_match('/\d/', $myVar))



Marco


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



Re: [PHP-DB] MySQL Backup, final script !!!

2003-06-26 Thread Armand Turpel
I use an db abstraction class. You have to replace this by yours. Of 
course you got a Fatal error: Call to a member function on a 
non-object because such an object dosen't exist in your script. First 
you have to connect to a database using mysql_connect() and using 
mysql_query and mysql_fetch_row.

Armand

Nabil wrote:

thanks a lot for your response but i got

Fatal error: Call to a member function on a non-object in
c:\inetpub\wwwroot\dump.php on line 3
not that mysql is 3.23.53
my script is :
/
?php
$sql = 'SHOW TABLES FROM chat';
$db-query($sql);
while ($row  = $db - fetchRow ('DB_GETMODE_NUM') )
{
$sql = ' BACKUP TABLE '.$row[0].' TO /db_backup ';
$db-query($sql);
}
?
/
 



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


Re: [PHP-DB] MySQL Backup, final script !!!

2003-06-26 Thread Nabil
thnks, i will give it a shot


Armand Turpel [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I use an db abstraction class. You have to replace this by yours. Of
 course you got a Fatal error: Call to a member function on a
 non-object because such an object dosen't exist in your script. First
 you have to connect to a database using mysql_connect() and using
 mysql_query and mysql_fetch_row.

 Armand

 Nabil wrote:

 thanks a lot for your response but i got
 
 Fatal error: Call to a member function on a non-object in
 c:\inetpub\wwwroot\dump.php on line 3
 not that mysql is 3.23.53
 
 my script is :
 /
 ?php
 $sql = 'SHOW TABLES FROM chat';
 $db-query($sql);
 while ($row  = $db - fetchRow ('DB_GETMODE_NUM') )
 {
 $sql = ' BACKUP TABLE '.$row[0].' TO /db_backup ';
 $db-query($sql);
 }
 ?
 /
 
 




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



[PHP-DB] moving though an array..

2003-06-26 Thread Aaron Wolski
Hi All,
 
Hopefully someone here can point me in the right direction.
 
I need to create a SELECT statement based on some criteria select and
entered into a form.
 
Form variables:
 
$threadsColumn = manufactuer,colour;
$string = n;
 
Code:
 
$columns[] = explode(,,$threadsColumn);
 
$test = (;
 
for ($i=0;$isizeof($columns);$i++) {
 
$test .= $columns[$i]. %$string%;
 
}
 
$test .= );
 
echo $test;
 
What I am attempting to do is create a select statement that would look
like (based on form variables):
 
SELECT * FROM tablename WHERE (manufacturer LIKE %n% OR colour LIKE %n%)
 
The information between ( and ) needs to be written in such a manner
that it scales up or down in options.. depending on what was selected in
the form.
 
ANYONE have some thoughts?
 
Oh.. when I echo the above code I get this: (Array %h%)
 
Thanks!
 
Aaron 
 


Re: [PHP-DB] moving though an array..

2003-06-26 Thread Adam Voigt
One Thing:

Change $columns[] to $colums, example:

$columns = explode(',',$threadsColumn);


On Thu, 2003-06-26 at 10:23, Aaron Wolski wrote:
 Hi All,
  
 Hopefully someone here can point me in the right direction.
  
 I need to create a SELECT statement based on some criteria select and
 entered into a form.
  
 Form variables:
  
 $threadsColumn = manufactuer,colour;
 $string = n;
  
 Code:
  
 $columns[] = explode(,,$threadsColumn);
  
 $test = (;
  
 for ($i=0;$isizeof($columns);$i++) {
  
 $test .= $columns[$i]. %$string%;
  
 }
  
 $test .= );
  
 echo $test;
  
 What I am attempting to do is create a select statement that would look
 like (based on form variables):
  
 SELECT * FROM tablename WHERE (manufacturer LIKE %n% OR colour LIKE %n%)
  
 The information between ( and ) needs to be written in such a manner
 that it scales up or down in options.. depending on what was selected in
 the form.
  
 ANYONE have some thoughts?
  
 Oh.. when I echo the above code I get this: (Array %h%)
  
 Thanks!
  
 Aaron 
  
-- 
Adam Voigt ([EMAIL PROTECTED])
Linux/Unix Network Administrator
The Cryptocomm Group


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



RE: [PHP-DB] moving though an array..SOLVED

2003-06-26 Thread Aaron Wolski
Hi All,

Solved my problem!

Here's the code in case anyone really cares :P

$col = explode(,,$threadsColumn);

$col_search = (;
for ($i=0;$icount($col);$i++) {
$col_search .= $col[$i]. LIKE
'%$threadsName%';
if ($i != (count($col) - 1)) {
$col_search .=  OR ;
 }
}

$col_search .= );

Thanks again Adam for your spelling error notice!

Aaron

-Original Message-
From: Adam Voigt [mailto:[EMAIL PROTECTED] 
Sent: June 26, 2003 10:26 AM
To: Aaron Wolski
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] moving though an array..

One Thing:

Change $columns[] to $colums, example:

$columns = explode(',',$threadsColumn);


On Thu, 2003-06-26 at 10:23, Aaron Wolski wrote:
 Hi All,
  
 Hopefully someone here can point me in the right direction.
  
 I need to create a SELECT statement based on some criteria select and
 entered into a form.
  
 Form variables:
  
 $threadsColumn = manufactuer,colour;
 $string = n;
  
 Code:
  
 $columns[] = explode(,,$threadsColumn);
  
 $test = (;
  
 for ($i=0;$isizeof($columns);$i++) {
  
 $test .= $columns[$i]. %$string%;
  
 }
  
 $test .= );
  
 echo $test;
  
 What I am attempting to do is create a select statement that would
look
 like (based on form variables):
  
 SELECT * FROM tablename WHERE (manufacturer LIKE %n% OR colour LIKE
%n%)
  
 The information between ( and ) needs to be written in such a manner
 that it scales up or down in options.. depending on what was selected
in
 the form.
  
 ANYONE have some thoughts?
  
 Oh.. when I echo the above code I get this: (Array %h%)
  
 Thanks!
  
 Aaron 
  
-- 
Adam Voigt ([EMAIL PROTECTED])
Linux/Unix Network Administrator
The Cryptocomm Group


-- 
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] Related Tables - Capture ID

2003-06-26 Thread Marie Osypian
Hello,

I have three table in which I am inserting records into in one script.  I
need to capture the ID of the second tables record insertion to insert into
a field into a related table in the third.  What would the easiest way to go
about this in php?

Thanks,

MAO



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



Re: [PHP-DB] Related Tables - Capture ID

2003-06-26 Thread Adam Voigt
Do the second query, call the mysql_insert_id function,
and that will give you the id of the row it just inserted.



On Thu, 2003-06-26 at 11:43, Marie Osypian wrote:
 Hello,
 
 I have three table in which I am inserting records into in one script.  I
 need to capture the ID of the second tables record insertion to insert into
 a field into a related table in the third.  What would the easiest way to go
 about this in php?
 
 Thanks,
 
 MAO
-- 
Adam Voigt ([EMAIL PROTECTED])
Linux/Unix Network Administrator
The Cryptocomm Group


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



Re: [PHP-DB] Related Tables - Capture ID

2003-06-26 Thread Volker Augustin
maybe you could solve this like that:
before querying your db, you should have a $created-variable use
microtime() or whatelse you like.
then you have another uniq 'id' you can ask for the id of the tuple you
added to your table before...

im sure there is another, easier way, maybe with mysql-function
(last-affected-row - i dont know) - but im postgres user :) and do it like i
described before also for other reasons (its fine to have a timestamp...).

volker

- Original Message -
From: Marie Osypian [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, June 26, 2003 5:43 PM
Subject: [PHP-DB] Related Tables - Capture ID


 Hello,

 I have three table in which I am inserting records into in one script.  I
 need to capture the ID of the second tables record insertion to insert
into
 a field into a related table in the third.  What would the easiest way to
go
 about this in php?

 Thanks,

 MAO



 --
 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] POSTed form and address

2003-06-26 Thread Dillon, John
I have a simple page saying: if(password is correct){then print the page}
otherwise {print the login form}.  The login form uses the method=post.  But
the page I get back has the form values: login details, in the address line.
I thought get gave you the variables in the address line and with post you
just saw the page's address, without parameters after it, like ?pw=something
etc.  No?

John











































   http://www.cantor.com
CONFIDENTIAL: This e-mail, including its contents and attachments, if any, are 
confidential. If you are not the named recipient please notify the sender and 
immediately delete it. You may not disseminate, distribute, or forward this e-mail 
message or disclose its contents to anybody else. Copyright and any other intellectual 
property rights in its contents are the sole property of Cantor Fitzgerald.
 E-mail transmission cannot be guaranteed to be secure or error-free. The sender 
therefore does not accept liability for any errors or omissions in the contents of 
this message which arise as a result of e-mail transmission.  If verification is 
required please request a hard-copy version.
 Although we routinely screen for viruses, addressees should check this e-mail and 
any attachments for viruses. We make no representation or warranty as to the absence 
of viruses in this e-mail or any attachments. Please note that to ensure regulatory 
compliance and for the protection of our customers and business, we may monitor and 
read e-mails sent to and from our server(s). 

For further important information, please read the  Important Legal Information and 
Legal Statement at http://www.cantor.com/legal_information.html


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



[PHP-DB] Re: POSTed form and address

2003-06-26 Thread Pete Morganic
form action=login.php method=POST - this does not send it on the URL
pete
John Dillon wrote:
I have a simple page saying: if(password is correct){then print the page}
otherwise {print the login form}.  The login form uses the method=post.  But
the page I get back has the form values: login details, in the address line.
I thought get gave you the variables in the address line and with post you
just saw the page's address, without parameters after it, like ?pw=something
etc.  No?
John











































   http://www.cantor.com
CONFIDENTIAL: This e-mail, including its contents and attachments, if any, are confidential. If you are not the named recipient please notify the sender and immediately delete it. You may not disseminate, distribute, or forward this e-mail message or disclose its contents to anybody else. Copyright and any other intellectual property rights in its contents are the sole property of Cantor Fitzgerald.
 E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission.  If verification is required please request a hard-copy version.
 Although we routinely screen for viruses, addressees should check this e-mail and any attachments for viruses. We make no representation or warranty as to the absence of viruses in this e-mail or any attachments. Please note that to ensure regulatory compliance and for the protection of our customers and business, we may monitor and read e-mails sent to and from our server(s). 

For further important information, please read the  Important Legal Information and Legal Statement at http://www.cantor.com/legal_information.html



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


RE: [PHP-DB] moving though an array..SOLVED

2003-06-26 Thread Ford, Mike [LSS]
 -Original Message-
 From: Aaron Wolski [mailto:[EMAIL PROTECTED]
 Sent: 26 June 2003 16:12
 
 Solved my problem!
 
 Here's the code in case anyone really cares :P
 
   $col = explode(,,$threadsColumn);
 
   $col_search = (;
   for ($i=0;$icount($col);$i++) {
   
   $col_search .= $col[$i]. LIKE
 '%$threadsName%';
   if ($i != (count($col) - 1)) {
   $col_search .=  OR ;
}
   }
 
   $col_search .= );

Yes, that's about how I'd do it -- you may, however, be interested in this variation 
on the theme:

$col = explode(,,$threadsColumn);

$col_search = array();

foreach ($col as $col_name) {   
$col_search[] = $col_name LIKE '%$threadsName%';

$col_search = ( . implode(' OR ', $col_search) . );


A completely different approach might be to do it like this:

$col_search = (
 . str_replace(',',
  LIKE '%$threadsName%' OR ,
 $threadsColumn)
 .  LIKE '%$threadsName%'
 . );

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



[PHP-DB] RE: POSTed form and address

2003-06-26 Thread Dillon, John
Sorry people.  My page was not refreshing properly.  In future, I'll use
version numbers to know what I'm looking at.

-Original Message-
From: Dillon, John 
Sent: 26 June 2003 17:29
To: [EMAIL PROTECTED]
Subject: POSTed form and address


I have a simple page saying: if(password is correct){then print the page}
otherwise {print the login form}.  The login form uses the method=post.  But
the page I get back has the form values: login details, in the address line.
I thought get gave you the variables in the address line and with post you
just saw the page's address, without parameters after it, like ?pw=something
etc.  No?

John











































   http://www.cantor.com
CONFIDENTIAL: This e-mail, including its contents and attachments, if any, are 
confidential. If you are not the named recipient please notify the sender and 
immediately delete it. You may not disseminate, distribute, or forward this e-mail 
message or disclose its contents to anybody else. Copyright and any other intellectual 
property rights in its contents are the sole property of Cantor Fitzgerald.
 E-mail transmission cannot be guaranteed to be secure or error-free. The sender 
therefore does not accept liability for any errors or omissions in the contents of 
this message which arise as a result of e-mail transmission.  If verification is 
required please request a hard-copy version.
 Although we routinely screen for viruses, addressees should check this e-mail and 
any attachments for viruses. We make no representation or warranty as to the absence 
of viruses in this e-mail or any attachments. Please note that to ensure regulatory 
compliance and for the protection of our customers and business, we may monitor and 
read e-mails sent to and from our server(s). 

For further important information, please read the  Important Legal Information and 
Legal Statement at http://www.cantor.com/legal_information.html


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



[PHP-DB] Undefined Index error when trying to insert data from a form into a db

2003-06-26 Thread Christopher McCourt
Hello to all:
 
I am getting the following error message when trying to insert data from
an html form into a MYSQL database that I recently created.  Can someone
take a look at the errors and corresponding code and suggest some
alternatives?
 
Thank you very much in advance for your assistance.
 
Regards,
Chris McCourt


 
Error Message:
 
Notice: Undefined index: Store_ID in c:\program files\apache
group\apache\htdocs\insertdata.php on line 9

Notice: Undefined index: Postal_Code in c:\program files\apache
group\apache\htdocs\insertdata.php on line 14

Notice: Undefined index: Cert_Org in c:\program files\apache
group\apache\htdocs\insertdata.php on line 17

Notice: Undefined index: Cert_Level_ID in c:\program files\apache
group\apache\htdocs\insertdata.php on line 18

Notice: Undefined index: Cert_Date in c:\program files\apache
group\apache\htdocs\insertdata.php on line 19

Notice: Undefined index: Emerg_Contact_Name in c:\program files\apache
group\apache\htdocs\insertdata.php on line 20

Notice: Undefined index: Emerg_Contact_Phone in c:\program files\apache
group\apache\htdocs\insertdata.php on line 21
Error: Unable to execute insertion query.
 
+++
 
Original PHP Code:
 
HTML
HEAD
TITLE Inserting Data Into a Database/TITLE
BODY
?php
/* This page receives and handles the data generated
by the form Insert_Table_Form.html*/
 
$Store = ($_POST['Store_ID']);
$Users = ($_POST['User_Name']);
$Pass  = ($_POST['Password']);
$Addr  = ($_POST['Address']);
$State = ($_POST['State']);
$Post  = ($_POST['Postal_Code']);
$Phone = ($_POST['Phone']);
$Email = ($_POST['EMail']);
$Certor = ($_POST['Cert_Org']);
$Certl = ($_POST['Cert_Level_ID']);
$Certd = ($_POST['Cert_Date']);
$Emergn = ($_POST['Emerg_Contact_Name']);
$Emergp = ($_POST['Emerg_Contact_Phone']);
 
 
//Set the variables for the database access:
$Host = localhost;
$User = root;
$Password = ;
 
$Link = mysql_connect($Host, $User, $Password)
or die(Could not connect:  . mysql_error());
mysql_select_db('dive_store') or die(could not select database);
$sql = mysql_query(INSERT INTO test_scores VALUES (NULL,
'$Store', '$Users', '$Pass', '$Addr', '$State', '$Post',
'$Phone', '$Email', '$Certor', '$Certd', '$Certl', 
'$Emergn', '$Emergp'))
 or die('Error: Unable to execute insertion query.'); 
 
$Result = mysql_query($sql)or die(mysql_error());
if ($Result){
  echo(Table Created successfully);
  }else{
  echo(error when creating table);
}
mysql_close($Link);
?
/BODY
/HEAD
/HTML
 


RE: [PHP-DB] Undefined Index error when trying to insert data from a form into a db

2003-06-26 Thread Hutchins, Richard
Chris,

It appears that the indices called out in the lines of error code are not
being transferred from the Insert_Table_Form.html page and that is causing
the query to ultimately fail. Almost self-explanatory due to PHP's good
error reporting.

First make certain that the names of the form controls on the
INsert_Table_Form.html page match up exactly with the names in your code on
lines 9 through 21.

Secondly, make sure each of the controls has a value when you attempt to
post the data from Insert_Table_Form.html. Some form controls will not
appear in the $_POST['indices'] array if they do not contain a value and
when you try to reference those empty controls, they cause problems because
they were never posted.

Hope this helps.

Rich

 -Original Message-
 From: Christopher McCourt [mailto:[EMAIL PROTECTED]
 Sent: Thursday, June 26, 2003 12:54 PM
 To: PHP Lists
 Subject: [PHP-DB] Undefined Index error when trying to insert 
 data from
 a form into a db
 
 
 Hello to all:
  
 I am getting the following error message when trying to 
 insert data from
 an html form into a MYSQL database that I recently created.  
 Can someone
 take a look at the errors and corresponding code and suggest some
 alternatives?
  
 Thank you very much in advance for your assistance.
  
 Regards,
 Chris McCourt
 ++
 ++
 
  
 Error Message:
  
 Notice: Undefined index: Store_ID in c:\program files\apache
 group\apache\htdocs\insertdata.php on line 9
 
 Notice: Undefined index: Postal_Code in c:\program files\apache
 group\apache\htdocs\insertdata.php on line 14
 
 Notice: Undefined index: Cert_Org in c:\program files\apache
 group\apache\htdocs\insertdata.php on line 17
 
 Notice: Undefined index: Cert_Level_ID in c:\program files\apache
 group\apache\htdocs\insertdata.php on line 18
 
 Notice: Undefined index: Cert_Date in c:\program files\apache
 group\apache\htdocs\insertdata.php on line 19
 
 Notice: Undefined index: Emerg_Contact_Name in c:\program files\apache
 group\apache\htdocs\insertdata.php on line 20
 
 Notice: Undefined index: Emerg_Contact_Phone in c:\program 
 files\apache
 group\apache\htdocs\insertdata.php on line 21
 Error: Unable to execute insertion query.
  
 +++
  
 Original PHP Code:
  
 HTML
 HEAD
 TITLE Inserting Data Into a Database/TITLE
 BODY
 ?php
 /* This page receives and handles the data generated
 by the form Insert_Table_Form.html*/
  
 $Store = ($_POST['Store_ID']);
 $Users = ($_POST['User_Name']);
 $Pass  = ($_POST['Password']);
 $Addr  = ($_POST['Address']);
 $State = ($_POST['State']);
 $Post  = ($_POST['Postal_Code']);
 $Phone = ($_POST['Phone']);
 $Email = ($_POST['EMail']);
 $Certor = ($_POST['Cert_Org']);
 $Certl = ($_POST['Cert_Level_ID']);
 $Certd = ($_POST['Cert_Date']);
 $Emergn = ($_POST['Emerg_Contact_Name']);
 $Emergp = ($_POST['Emerg_Contact_Phone']);
  
  
 //Set the variables for the database access:
 $Host = localhost;
 $User = root;
 $Password = ;
  
 $Link = mysql_connect($Host, $User, $Password)
 or die(Could not connect:  . mysql_error());
 mysql_select_db('dive_store') or die(could not select database);
 $sql = mysql_query(INSERT INTO test_scores VALUES (NULL,
 '$Store', '$Users', '$Pass', '$Addr', '$State', '$Post',
 '$Phone', '$Email', '$Certor', '$Certd', '$Certl', 
 '$Emergn', '$Emergp'))
  or die('Error: Unable to execute insertion query.'); 
  
 $Result = mysql_query($sql)or die(mysql_error());
 if ($Result){
   echo(Table Created successfully);
   }else{
   echo(error when creating table);
 }
 mysql_close($Link);
 ?
 /BODY
 /HEAD
 /HTML
  
 

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



[PHP-DB] add source code from form to DB - quote error- tried addslashes..

2003-06-26 Thread Steve B.
Hi I spent my 6+ hours trying yesterday to get a form to submit source code to the db.
The data gets in the db fine if it is just plain ascii.

The server has Magic Quotes on and this is bad according to most but should not stop 
it from
working- in fact it should just work.

Short Source is here can anyone tell my what 
addslash/addquote/removequote/htmlentities thing I
need to do? I've tried a few.

if (!empty($HTTP_POST_VARS[cname]))
{
$cname= $HTTP_POST_VARS[cname];
$source= $HTTP_POST_VARS[source];

echo lt;plt;/pForm Source = lt;br.htmlspecialchars($source).lt;br;

// try to make it insert right.
// not getting insert error but only getting partial data inserted for source.

//$source= '.mysql_escape_string($source).';
//$source = addslashes($source);
//$source = '.mysql_escape_string(stripslashes($source)).';

$sql = 
INSERT INTO classes set 
cname='$cname',
source='$source';

// the query prints on the screen fine
print lt;br.htmlspecialchars($sql).lt;br;

mysql_connect(a, b, c); 

mysql_select_db(codepost); 

mysql_query($sql);

echo New code added!!!;
}

?
lt;plt;/p
lt;form action=addnewclass.php method=POST 
Class name: lt;input type=text name=cname lt;br 
Source: lt;textarea name=source rows=10 cols=65lt;/textarea lt;br 
lt;input type=submit value=Add Code 
lt;/form 



__
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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



Re: [PHP-DB] Undefined Index error when trying to insert data from a form into a db

2003-06-26 Thread Miles Thompson
1. Check the manual on use of $_POST and notch down your error reporting 
level. As these vars have not been defined PHP is throwing an error.

2. While you are at it, and  assuming that your variables are all received 
correctly, why not simplify your sql?

insert into test_scores set field_one = '$field_one', field_two = 
''$field_two ... and so forth. It makes debugging INFINITELY easier and 
gives you more control.

3. Not related to your question at all, what's the type of your first 
field? Does it allow NULL's? If so then default it to NULL. (Something 
tugging at the back of my mind says that a NULL should not be assignable, 
but that's another issue.)

HTH - Mlies Thompson

At 12:53 PM 6/26/2003 -0400, Christopher McCourt wrote:
Hello to all:

I am getting the following error message when trying to insert data from
an html form into a MYSQL database that I recently created.  Can someone
take a look at the errors and corresponding code and suggest some
alternatives?
Thank you very much in advance for your assistance.

Regards,
Chris McCourt


Error Message:

Notice: Undefined index: Store_ID in c:\program files\apache
group\apache\htdocs\insertdata.php on line 9
Notice: Undefined index: Postal_Code in c:\program files\apache
group\apache\htdocs\insertdata.php on line 14
Notice: Undefined index: Cert_Org in c:\program files\apache
group\apache\htdocs\insertdata.php on line 17
Notice: Undefined index: Cert_Level_ID in c:\program files\apache
group\apache\htdocs\insertdata.php on line 18
Notice: Undefined index: Cert_Date in c:\program files\apache
group\apache\htdocs\insertdata.php on line 19
Notice: Undefined index: Emerg_Contact_Name in c:\program files\apache
group\apache\htdocs\insertdata.php on line 20
Notice: Undefined index: Emerg_Contact_Phone in c:\program files\apache
group\apache\htdocs\insertdata.php on line 21
Error: Unable to execute insertion query.
+++

Original PHP Code:

?php /* This page receives and handles the data generated by the form 
Insert_Table_Form.html*/ $Store = ($_POST['Store_ID']); $Users = 
($_POST['User_Name']); $Pass = ($_POST['Password']); $Addr = 
($_POST['Address']); $State = ($_POST['State']); $Post = 
($_POST['Postal_Code']); $Phone = ($_POST['Phone']); $Email = 
($_POST['EMail']); $Certor = ($_POST['Cert_Org']); $Certl = 
($_POST['Cert_Level_ID']); $Certd = ($_POST['Cert_Date']); $Emergn = 
($_POST['Emerg_Contact_Name']); $Emergp = ($_POST['Emerg_Contact_Phone']); 
//Set the variables for the database access: $Host = localhost; $User = 
root; $Password = ; $Link = mysql_connect($Host, $User, $Password) or 
die(Could not connect:  . mysql_error()); mysql_select_db('dive_store') 
or die(could not select database); $sql = mysql_query(INSERT INTO 
test_scores VALUES (NULL, '$Store', '$Users', '$Pass', '$Addr', '$State', 
'$Post', '$Phone', '$Email', '$Certor', '$Certd', '$Certl', '$Emergn', 
'$Emergp')) or die('Error: Unable to execute insertion query.'); $Result 
= mysql_query($sql)or die(mysql_error()); if ($Result){ echo(Table 
Created successfully); }else{ echo(error when creating table); } 
mysql_close($Link); ?



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


[PHP-DB] PHP DB Interaction with Javascript?

2003-06-26 Thread Aaron Wolski
Hi All,
 
Trying to get my head around something and want to know if it's possible
first.
 
Can PHP and Javascript interact to the point of PHP querying a DB to
find out what records are in use as a variable for another record and
then using JS to A) prevent the user from clicking a delete button; or
B) pop-up a notice telling the user they can delete that particular
record.
 
Hope that makes sense.. any ideas?
 
Thanks!
 
Aaron 
 


[PHP-DB] Weird mySQL problem with mod_rewrite

2003-06-26 Thread GJL
Hi,

I'm encountering a very strange problem that's manifesting itself in mySQL.
Basically, when accessing a PHP script using mod_rewrite URLs, e.g.: instead
of http://www.domain.com/index.php?this=that using
http://www.domain.com/index.php/that if that script accesses mySQL, mySQL is
becoming flooded with unauthenticated users and after a couple of reloads
it bogs the server down. If I access it in the normal GET way (the script
can handle either URL method) this doesn't happen - we see no unauthenticed
users in mySQL. Nothing else seems to be affected, only mySQL.

I'm stumped as to what it could be. This isn't just happening on one server,
it's happening on many. Does anybody have any ideas?

Regards,

G



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



Re: [PHP-DB] PHP DB Interaction with Javascript?

2003-06-26 Thread jeffrey_n_Dyke

may be missing the point.  but

when you're brining down the page decide what records the user can and
can't delete and write javascript function(s) using php for the correct
scenario, I'd write a single js function that you'd pass one(many) PHP
variable(s) into, when building the page, after you have the db info and
let the JS decide what the function does, based on the variable passed.
Making PHP decide ALL of the Business logic and just passing command type
paramaters to JS.

hope this helps and i'm not just totaly off base.

Jeff


   
 
  Aaron Wolski   
 
  [EMAIL PROTECTED]To:   [EMAIL PROTECTED]  
   
  z.com   cc: 
 
   Subject:  [PHP-DB] PHP DB Interaction 
with Javascript?   
  06/26/2003 01:52 
 
  PM   
 
   
 
   
 




Hi All,

Trying to get my head around something and want to know if it's possible
first.

Can PHP and Javascript interact to the point of PHP querying a DB to
find out what records are in use as a variable for another record and
then using JS to A) prevent the user from clicking a delete button; or
B) pop-up a notice telling the user they can delete that particular
record.

Hope that makes sense.. any ideas?

Thanks!

Aaron







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



[PHP-DB] Can't go higher than PHP 4.3.0

2003-06-26 Thread Ryan Jameson (USA)
I'm trying to update to the latest version but I can't get anything newer than 4.3.0 
to run in ISAPI mode. Any ideas?

Thanks..

 Ryan

Ryan Jameson
Software Development Services Manager 
International Bible Society
W (719) 867-2692

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



RE: [PHP-DB] generating sequence without AUTO_INCREMENT

2003-06-26 Thread Jennifer Goodie
You could you do MAX(issue_number)+1 where YEAR(date) = Year(NOW()) to get
next issue number for the current year, but if you had 2 people entering
issues at the same time, it wouldn't work so well.  Just trying to give you
a starting point because it seems like you haven't really gotten an answer
yet.

 -Original Message-
 From: anders thoresson [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, June 25, 2003 11:43 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] generating sequence without AUTO_INCREMENT


 Hi,
  I'm working on a web based article planning system for a news
 paper, based
 on PHP and MySQL. One vital table in the setup will contain release date
 and number for each issue. It's a simple table with just three columns:
  id, which is the primary key and AUTO_INCREMENT
  date, which is the release date for each issue
  issue_number
  I need help with a solution to automatically create the
 issue_number. The
 conditions is as follow:
  1. The paper is published every Monday to Friday, except for national
 holidays, so issue_number isn't the same as the day number
  2. The first issue each year should be number 1, and then the
 rest should
 follow in sequence
  The first condition is taken care of manually, where one of the editors
 will input a start date and an end date between which the
 newspaper will be
 released Mondays to Fridays. That way I'll handle the national holidays,
 for each year the editors have to enter a couple of date sequences to
 fence out the holidays.
  But keeping track of each and every issue_number manually isn't
 practical.
 I've looked at the MySQL manual, but all I find is LAST_INSERT_ID(). But
 from what I've understood, that function is only useful when it's
 the same
 value that is being updated, and this isn't the case in my problem.
  So I guess I'll have to write my own function. The solution I think of
 right now is adding new issues in two steps: First adding the
 date for the
 new issue to the table, then checking the issue_number for the
 date before,
 and then adding the issue_number next in turn to the new issue,
 or, if the
 year differs start over from 1 again.
  Is there a smarter way of doing this?


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



[PHP-DB] error checking question

2003-06-26 Thread dpgirago


Hello everyone,

I've been experimenting with checking for errors in data inserted into a table
using an html form.  The main page displays the result of a  select  *  from
the_table at the top of the page, with the form for inserting the data beneath.
The SQL for the insert occurs on a different page, with redirection back to the
main page using the header() function ( as I've learned to do from reading this
list ). This all works well. The inserted data shows up in the table, and there
are no surprises when refreshing, etc... I have also implemented some error
checking on the client side using JavaScript, and this is also working well.

What I would like to do is somehow have a redundant error check on the server
side and then display an error message above the form on the main page should
fields be left blank or forbidden characters entered. Since I have access to the
$_POST['variables'] on the form processing page, I've already written some code
to detect the presence of error characters, etc...and no query is performed if
there is an error.  But how do I pass a flag variable back to the main page to
echo an appropriate message above the form?

Advice or suggestions greatly appreciated.

David



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



[PHP-DB] PHP 4.2.2, RedHat 9, OCI 8 issue

2003-06-26 Thread Robb Foster




I was running fine on RedHat 7.3 with a hand compiled version of PHP 4.2.3 with OCI8 connecting to an Oracle 9.2 database with Oracle 9.2 libraries. Now, I am trying to move the RedHat 9.0, and I am trying to use the off-the-shelf RPMs for PHP. First off, I am using PHP 4.2.2. Since there does not appear to be an RPM for OCI8, so I built one using the 4.2.2 source code. Now, when I run a simple PHP script which simply logs onto the database, everything works fine, but PHP gets a segmentation violation upon exiting the script. I tried to debug the problem by modifying the oci8.c code, but everything in there seems to work fine. We get all the way through php_mshutdown_oci cleanly, so I guess the problem lies in the higher levels of invocation.

Has anyone seen this problem?

Any help would be most gratefully received.

Thanks.



-- 
'The weak will go' -- Gerard Houiller, OBE
--
Robb Foster [EMAIL PROTECTED]








signature.asc
Description: This is a digitally signed message part


[PHP-DB] latest version of php only cgi?

2003-06-26 Thread Doug Finch
Is the newest version of php 4 only available as a cgi-based program?
DF




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



RE: [PHP-DB] latest version of php only cgi?

2003-06-26 Thread Ryan Jameson (USA)
It seems to be capable of being installed as ISAPI but I haven't had any luck yet. I 
have heard of people who have though. So... ???

 Ryan

-Original Message-
From: Doug Finch [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 26, 2003 2:12 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] latest version of php only cgi?


Is the newest version of php 4 only available as a cgi-based program?
DF




-- 
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] generating sequence without AUTO_INCREMENT

2003-06-26 Thread anders thoresson
MAX(issue_number)+1 where YEAR(date) = Year(NOW())
I continued to work while waiting for ideas, and have now manage to get a 
script that work.

I'm getting the next issue number this way:

// Connect to database to get latest issue number from table un_issue

db_connect($dbuser, $dbpassword, $dbdatabase);
$query = SELECT * FROM un_issue ORDER BY i_id DESC LIMIT 1;
$result  = mysql_query($query);
$row = mysql_fetch_row($result);
$next_issue_number = $row[2] + 1;
$previous_issue_date = $row[1];

I didn't think of the problem when two users are adding at the same time 
since this won't happen in this particular case. But what could I do to 
avoid the problem in future scripts?

Doing what I wanted to do took six hours and 120 lines of code, all in 
all, but I learnt a good deal on the way. ;-)

//Anders

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


[PHP-DB] php admin text edit then crash question

2003-06-26 Thread Steve B.
I can post some source code by form to db and it all looks good in the db.

When using phpadmin and adding wow to the end of the source phpadmin gets a quote 
error.

The db field holding this is text.

Why would it get a quote error from that?
Is this a server issue or my fault? (its hosted)
Thanks


__
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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



[PHP-DB] mysql database function problem

2003-06-26 Thread Andres
Hello Everybody!

I tried to connect with a mysql databasem , but It shows the follow error:

Warning: mysql_numrows(): supplied argument is not a valid MySQL result
resource in c:\inetpub\wwwroot\ejercicios\cap11\cursor.php on line 25

Número de filas en el resultado:

Warning: mysql_num_fields(): supplied argument is not a valid MySQL result
resource in c:\inetpub\wwwroot\ejercicios\cap11\cursor.php on line 29

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result
resource in c:\inetpub\wwwroot\ejercicios\cap11\cursor.php on line 32

Warning: mysql_free_result(): supplied argument is not a valid MySQL result
resource in c:\inetpub\wwwroot\ejercicios\cap11\cursor.php on line 40

It seems doesn't  recognize the mysql functions I wrote in the code, or did
I something wrong?

I'm a newbie trying to learn and I have php 4.3.2  with mysql 4.0.13 in a
windows xp with ISS 5.0 and I've Installed those programs a lot of times
trying to fix it up but the problem remains.

I'll really appreciate any help.

Andres



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



FW: [PHP-DB] error checking question

2003-06-26 Thread David Shugarts

-- Forwarded Message
 From: David Shugarts [EMAIL PROTECTED]
 Date: Thu, 26 Jun 2003 18:53:53 -0400
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] error checking question
 
 Hi, David--
 
 The question you are asking belongs to the topic or concept called form
 validation and you will see lots of hits about it on a Google search. I have
 been looking at the same issue and I am impressed with one solution,
 http://www.x-code.com/vdaemon_web_form_validation.php. However, I am
 interested in what other people might think.
 
 With the help of this List, I have had some success in validation of one or
 two variables in a form, but this solution, vdaemon, represents an attempt to
 cover the complete spectrum of the variables people most often want to
 validate. I feel it may be on the right track (even though the one I wish to
 validate isn't covered).
 
 --Dave Shugarts
 
 
 
 
 Hello everyone,
 
 I've been experimenting with checking for errors in data inserted into a
 table
 using an html form.  The main page displays the result of a  select  *  from
 the_table at the top of the page, with the form for inserting the data
 beneath.
 The SQL for the insert occurs on a different page, with redirection back to
 the
 main page using the header() function ( as I've learned to do from reading
 this
 list ). This all works well. The inserted data shows up in the table, and
 there
 are no surprises when refreshing, etc... I have also implemented some error
 checking on the client side using JavaScript, and this is also working well.
 
 What I would like to do is somehow have a redundant error check on the server
 side and then display an error message above the form on the main page should
 fields be left blank or forbidden characters entered. Since I have access to
 the
 $_POST['variables'] on the form processing page, I've already written some
 code
 to detect the presence of error characters, etc...and no query is performed
 if
 there is an error.  But how do I pass a flag variable back to the main page
 to
 echo an appropriate message above the form?
 
 Advice or suggestions greatly appreciated.
 
 David
 
 

-- End of Forwarded Message


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



[PHP-DB] Need help on query

2003-06-26 Thread Gezeala 'Eyah' Bacuño II
Dear all,

I have 2 tables product_customer and product_price

product_customer

prod_cust_idprod_cust_product_idprod_cust_customer_id
1   1   1
2   2   1
3   3   1
4   1   2
product_price

prod_price_id   prod_price_prod_cust_id prod_price_unitpriceprod_price_currency_id 
 prod_price_effective_date
1   1   1.23456 2  
 6/30/2003
2   1   1.12346 3  
 5/9/2003
3   4   0.23456 3  
 5/21/2003
4   4   1.45678 3  
 6/26/2003
Column prod_price_prod_cust_id of product_price table references 
prod_cust_id of product_customer table..

I have this query :

SELECT prod_price_prod_cust_id, prod_price_id, prod_price_unitprice, 
prod_price_effective_date
FROM product_price
WHERE prod_price_prod_cust_id in (1,4)
GROUP BY prod_price_prod_cust_id, prod_price_id, prod_price_unitprice, 
prod_price_effective_date
HAVING MAX(prod_price_effective_date) = current_date

Which returns :

prod_price_prod_cust_id prod_price_id   prod_price_unitprice
prod_price_effective_date
1   2   1.12346 5/9/2003
4   3   0.23456 5/21/2003
4   4   1.45678 6/26/2003
What I intend to get is the maximum prod_price_effective_date for each 
prod_price_prod_cust_id.
The second row should not be included in the output since 6/26/2003 is 
greater than 5/21/2003 .

My target output is this :

prod_price_prod_cust_id prod_price_id   prod_price_unitprice
prod_price_effective_date
1   2   1.12346 5/9/2003
4   4   1.45678 6/26/2003
Any suggestions on how I can arrive with these output??

Help is greatly appreciated..TIA!

Marie Gezeala M. Bacuño II
Information Systems Department
Your choice: the red pill or the blue pill.

_
The new MSN 8: advanced junk mail protection and 2 months FREE* 
http://join.msn.com/?page=features/junkmail

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


[PHP-DB] Efficiency question

2003-06-26 Thread Micah Stevens
I would guess that:

$data = mysql_fetch_assoc(mysql_query(select * from some_table limit 1));

would be faster than:

$pointer = mysql_query(select * from some_table limit 1);
$data = mysql_fetch_assoc($pointer);

but I'm not sure, php may optimize this. Anyone know the answer?

I'm taking over some code that someone else made that has a lot of one record 
retrevals coded in it, like option 2, and I was wondering if it was worth my 
time to change it. 

Thanks!
-Micah


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



[PHP-DB] Re: Efficiency question

2003-06-26 Thread Hugh Bothwell
Micah Stevens [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 $data = mysql_fetch_assoc(mysql_query(select * from some_table limit
1));

 would be faster than:

 $pointer = mysql_query(select * from some_table limit 1);
 $data = mysql_fetch_assoc($pointer);

 but I'm not sure, php may optimize this. Anyone know the answer?


It will be faster by one store and one fetch... the
database query probably takes 1000 times as long.
I don't think the difference is worth the time you'd
take to change it.

--
Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada
v3.1 GCS/E/AT d- s+: a- C+++ L+$ P+ E- W+++$ N++ K? w++ M PS+
PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+




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



[PHP-DB] Splitting Product Catalogue Over Multiple Pages?

2003-06-26 Thread Boa Constructor
Greetings all, I'm not sure if this has been discussed recently, I've read
bits and pieces and I can't remember where I read everything so if it has
been brought up recently - sorry.

If I do an SQL (MySQL) query on the first example to get the min and max IDs
then I will get 1 and 6 respectively.  I will then be able to loop from 1 to
6 and return all 6 products from the database.  If however I wanted to split
this in to two pages with 3 items in each page then using the first example
below I could grab the min ID and add 2 to it to make 3.  I could not do
this using the second example because if I grab the min ID I would get 3, if
I add 2 to it then I would get 5.  5 does not exit in this table so that
wouldn't work.  How in example 2 would I be able to split this over two
pages?

//example 1

ID   Product_Name
1  Hoover
2  Kettle
3  Fridge
4  Cooker
5  Food Mixer
6  TV

//example 2

ID   Product_Name
3 Fridge
4 Cooker
7 Microwave Oven
8 Freezer
9 DVD Player
10   Computer


Any ideas?

Anything is much appreciated.

Graeme :)


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



[PHP-DB] Re: mysql database function problem

2003-06-26 Thread David Robley
In article [EMAIL PROTECTED], [EMAIL PROTECTED] 
says...
 Hello Everybody!
 
 I tried to connect with a mysql databasem , but It shows the follow error:
 
 Warning: mysql_numrows(): supplied argument is not a valid MySQL result
 resource in c:\inetpub\wwwroot\ejercicios\cap11\cursor.php on line 25
 
 Número de filas en el resultado:
 
 Warning: mysql_num_fields(): supplied argument is not a valid MySQL result
 resource in c:\inetpub\wwwroot\ejercicios\cap11\cursor.php on line 29
 
 Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result
 resource in c:\inetpub\wwwroot\ejercicios\cap11\cursor.php on line 32
 
 Warning: mysql_free_result(): supplied argument is not a valid MySQL result
 resource in c:\inetpub\wwwroot\ejercicios\cap11\cursor.php on line 40
 
 It seems doesn't  recognize the mysql functions I wrote in the code, or did
 I something wrong?
 
 I'm a newbie trying to learn and I have php 4.3.2  with mysql 4.0.13 in a
 windows xp with ISS 5.0 and I've Installed those programs a lot of times
 trying to fix it up but the problem remains.
 
 I'll really appreciate any help.

The problem is most likely in the syntax of your query. Use mysql_error() 
immediately after sending your query to the db to get an error string from 
mysql.

-- 
Quod subigo farinam

$email =~ s/oz$/au/o;


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



Re: [PHP-DB] Re: Efficiency question

2003-06-26 Thread Peter Beckman
Since this is the PHP DB list, I can tell you this -- you would be better
off performance-wise replacing the * in select * from and replacing it
with a list of the columns (even if it is all of them) than you would
putting all of that on one line.

$r = rand(0,7)*-1;
$s = abs($r);

is as fast as (maybe a few CPU cycles, but when you're talking 2GHz
processor, eh)

$s = abs(rand(0,7)*-1);

The second is probably more elegant, but then again, you still have to
check to see what $data contains -- the DB might not have returned a row
(for some unknown reason).

Optimize DB calls before compacting variables.  I'm all about writing
compact optimized code, but your DB calls and DB layout (indexes and
queries mostly, but also table design) cost the most performance-wise and
you're better off spending time getting them better.

I highly recommend:
http://www.mysql.com/documentation/mysql/bychapter/manual_MySQL_Optimisation.html#Estimating_performance

Peter

On Thu, 26 Jun 2003, Hugh Bothwell wrote:

 Micah Stevens [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  $data = mysql_fetch_assoc(mysql_query(select * from some_table limit
 1));
 
  would be faster than:
 
  $pointer = mysql_query(select * from some_table limit 1);
  $data = mysql_fetch_assoc($pointer);
 
  but I'm not sure, php may optimize this. Anyone know the answer?


 It will be faster by one store and one fetch... the
 database query probably takes 1000 times as long.
 I don't think the difference is worth the time you'd
 take to change it.

 --
 Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada
 v3.1 GCS/E/AT d- s+: a- C+++ L+$ P+ E- W+++$ N++ K? w++ M PS+
 PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+




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


---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

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