[PHP-DB] mysql -- php

2001-04-08 Thread Adam

Hello,
I have a fresh instalation of mysql from the ditribution of RH7.
What do I have to put into the user and host tables so that
I can use MySQL through PHP (I doesn't have to be super-secure,
just so that not everybody could get to my databases)

Btw.
Now I get this error when trying to use mysql in a php script:
Warning: MySQL Connection Failed: Can't connect to local MySQL server
through socket '/var/lib/mysql/mysql.sock' (111) in lib.inc.php3 on line 97
 Error
I'm sure that mysql server is running.

Greets,
Adam



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Gathering data from a database

2003-03-22 Thread Adam -
Hi,

   $select = mysql_select_db ($database);  like Mike said you don't 
need to have this in  and no need for a var to be assigned...

  Then when you want to print out the data

print_r( $row );

you can use $row['table_row_name'];
:)
Adam
At 08:26 PM 3/22/2003 -0500, you wrote:
I have been having this problem for a while now, and I cant figure it out. 
the code is:
?
$host = localhost;
$uname = sniper;
$pass = starcraft;
$database = sha;
$tablename = members;
$connect = mysql_connect ($host, $uname, $pass);
$select = mysql_select_db ($database);
$query = SELECT * from $tablename;
$result = mysql_query ($query, $connect);

while ($row = mysql_fetch_array($result))
{
print_r( $row );
echo mysql_error();
}
?
mysql has an error on line 19. Line 19 is while ($row = 
mysql_fetch_array($result)). What am I doing wrong?

Thanks for your help,
Mike


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


Re: [PHP-DB] Returning a formated dat

2001-02-02 Thread Adam Younce

Ben,

The easiest (and quickest) way I've done this in the past is to use
MySQL's DATE_FORMAT function when doing the SELECT. To format it like you
want try this:

SELECT DATE_FORMAT(date_column, '%m/%d/%y') as f_date FROM Table_name;

Be sure to use the correct name for the column that the date is stored
in.

To get more info on the DATE_FORMAT function, check out the MySQL online
manual.

http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html#Dat
e_and_time_functions

Regards,

Adam Younce
[EMAIL PROTECTED]

- Original Message -
From: "Ben Cairns" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, February 02, 2001 4:13 AM
Subject: [PHP-DB] Returning a formated dat


 I have a date stored in a MySQL field in a format like this:

 For example, 02/02/2001 (Today) would be stored as:
 02022001

 What I need to do is to format that so that it looks like:
 02/02/2001

 -- Ben Cairns - Head Of Technical Operations
 intasept.COM
 Tel: 01332 365333
 Fax: 01332 346010
 E-Mail: [EMAIL PROTECTED]
 Web: http://www.intasept.com

 "MAKING sense of
 the INFORMATION
 TECHNOLOGY age
 @ WORK.."


 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Is MySQL in 4.0.6?

2001-06-25 Thread Adam Lundrigan

Is MySQL included in the 406kb version of PHP 4.0.6?
When I try to connect to MySQL (after adding localhost  paswords to php.ini) using 
this version it says:
Warning: Can't connect to MySQL server on 'localhost' (10061) in mysql_local_test.php 
on line 2

From what i've heard, MySQL is included in PHPbut why doesn't the connect work if 
it is included?

-Adam Lundrigan
 CEO, VPU
 http://www.vpu-virtual.com/
 
 ICQ # 73617446
 [EMAIL PROTECTED]

 



[PHP-DB] PHP on Linux and MS SQL

2001-07-30 Thread Adam Oliver

Anybody know of a good installation description for connection PHP on linux
to MS SQL on a 2000 machine?  I've been through about 3 so far and none of
them have worked.

Adam



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Can't connect to MS SQL

2001-07-30 Thread Adam Oliver

I have PHP running on Apache for win32.  The mssql module is enabled.  I am
trying to connect to a database with the following code.

?php
$hostname = 192.168.1.1:1433;
$username = test;
$password = smiley;
$dbName = meyedev;
$dbc = mssql_connect($hostname,$username,$password) or DIE(DATABASE FAILED
TO RESPOND.);
mssql_select_db($dbName) or DIE(Table unavailable);
mssql_close($dbName);
?

However I get the following error.

Warning: MS SQL: Unable to connect to server: 192.168.1.1:1433 in c:\program
files\apache group\apache\htdocs\meyedev\connect.php4 on line 11
DATABASE FAILED TO RESPOND.

What am I doing wrong?

Adam



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Random question selection in PHP w/ MySQL backend.

2001-07-31 Thread Adam Lundrigan

I'm having a bit of trouble creating a random question selector. I'm using PHP 4.0.6 
and MySQL 3.23.36 on Windows 98 SE.
I've tried several different solutions, but none work at all.

What i need to do is select 10 questions from a database (db: vpt, table: questions), 
and make sure that the same question doesn't appear twice. The questions need to 
appear in a random order each time the script is loaded. It sounds simple enough, but 
i just can't seem to get it to work.

Any suggestions??


Thanks in advance,
 
-Adam Lundrigan
 CEO, VPU
 http://www.vpu-virtual.com/
 
 ICQ # 73617446
 [EMAIL PROTECTED]

 



[PHP-DB] REG_EMPTY

2001-08-01 Thread Adam Lundrigan

What exactly does the error 'REG_EMPTY' mean in PHP?

-- 
-Adam Lundrigan
 CEO, VPU
 http://www.vpu-virtual.com/
 
 ICQ # 73617446
 [EMAIL PROTECTED]

 



[PHP-DB] MySQL Connection Lost....

2001-08-13 Thread Adam Douglas

Ok I've finally gotten MySQL 3.23.37 installed and operating. Thanks to 
all that helped! The problem I'm now experiencing is when I try to 
interface with MySQL via PHP. MySQL seems to work fine by logging into 
MySQL directly and through a MySQL GUI Client. I get the following error...

Warning: MySQL Connection Failed: Lost connection to MySQL server during 
query...

I'm assuming this is a MySQL issue since everything worked fine before 
the upgrade from MySQL 3.32.22 to MySQL 3.23.37. But for all I know it 
could be PHP I guess.

I'm doing very simple query to see if it works and no success. Even code 
that worked before I upgraded doesn't work anymore. Here's the test 
query I made... (BTW, the below query works fine via MySQL/MySQL GUI Client)

$szQuery = SELECT * FROM People WHERE First_Name='adouglas';
$dbconnection = mysql_connect(207.195.58.33,webuser,adamacc226);
mysql_select_db(venmar, $dbConnection) or die(could not connect to 
venmar for security authentication.);
$saResults = mysql_query($szQuery, $dbConnection) or die (2could not 
query venmar for security authentication.);
$obResults = mysql_fetch_row($saResults)

echo $obResults[0], $obResults[1], $obResults[2], $obResults[3], 
$obResults[4], $obResults[5];


The MySQL Database has it's own dedicated machine running on OpenBSD 
2.9. The web server accessing the MySQL Database is on it's own machine 
with Apache 1.3.12 and OpenBSD 2.9. Any other details needed let me know.

+--+---+
| Variable_name| Value |
+--+---+
| Aborted_clients  | 0 |
| Aborted_connects | 6 |
| Bytes_received   | 4125  |
| Bytes_sent   | 45247 |
| Connections  | 15|
| Created_tmp_disk_tables  | 0 |
| Created_tmp_tables   | 0 |
| Created_tmp_files| 0 |
| Delayed_insert_threads   | 0 |
| Delayed_writes   | 0 |
| Delayed_errors   | 0 |
| Flush_commands   | 1 |
| Handler_delete   | 4 |
| Handler_read_first   | 7 |
| Handler_read_key | 16|
| Handler_read_next| 2 |
| Handler_read_prev| 0 |
| Handler_read_rnd | 0 |
| Handler_read_rnd_next| 2597  |
| Handler_update   | 1 |
| Handler_write| 4 |
| Key_blocks_used  | 4 |
| Key_read_requests| 28|
| Key_reads| 4 |
| Key_write_requests   | 18|
| Key_writes   | 12|
| Max_used_connections | 1 |
| Not_flushed_key_blocks   | 0 |
| Not_flushed_delayed_rows | 0 |
| Open_tables  | 22|
| Open_files   | 44|
| Open_streams | 0 |
| Opened_tables| 38|
| Questions| 135   |
| Select_full_join | 0 |
| Select_full_range_join   | 0 |
| Select_range | 0 |
| Select_range_check   | 0 |
| Select_scan  | 15|
| Slave_running| OFF   |
| Slave_open_temp_tables   | 0 |
| Slow_launch_threads  | 0 |
| Slow_queries | 0 |
| Sort_merge_passes| 0 |
| Sort_range   | 0 |
| Sort_rows| 0 |
| Sort_scan| 0 |
| Table_locks_immediate| 52|
| Table_locks_waited   | 0 |
| Threads_cached   | 0 |
| Threads_created  | 14|
| Threads_connected| 1 |
| Threads_running  | 1 |
| Uptime   | 7235  |
+--+---+

+-+---+
| Variable_name   | Value 
 
|
+-+---+
| ansi_mode   | OFF 
 
|
| back_log| 50 
 
|
| basedir | /usr/local/ 
 
|
| binlog_cache_size   | 32768 
 
|
| character_set   | latin1 
 
|
| character_sets  | latin1 dec8 dos german1 hp8 koi8_ru 
latin2 swe7 usa7 cp1251 danish hebrew win1251 estonia hungarian koi8_ukr 
win1251ukr greek win1250 croat cp1257 latin5 |
| concurrent_insert   | ON 
 
|
| connect_timeout | 5 
 
|
| datadir | /var/mysql/ 
 
 

RE: [PHP-DB] Using A Query Results Multiple Times

2001-10-24 Thread Adam Douglas

Yes, I had the right code just was missing the mysql_data_seek. Thanks for
the help.


 -Original Message-
 From: Rick Emery [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, October 23, 2001 1:09 PM
 To: 'Adam Douglas'; PHP-DB (mailing list) (E-mail)
 Subject: RE: [PHP-DB] Using A Query Results Multiple Times
 
 
 You're on the right track.  Did you try?:
 
 while( $row[] = mysql_fetch_array($result) );
 
 This should load each result row into a row of a 
 multi-dimensional array.
 
 You would then access it with:
 
 $row[0]['colname']
 
 -Original Message-
 From: Adam Douglas [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, October 23, 2001 1:48 PM
 To: PHP-DB (mailing list) (E-mail); PHP-General (mailing 
 list) (E-mail)
 Subject: [PHP-DB] Using A Query Results Multiple Times
 
 
   I have an instance where I have to query my MySQL 
 database and then
 use the multiple row results to create multiple pull down 
 menus on a web
 page. My problem is how can I take the results of the query 
 and use them
 more the once to create pull down menus? I've always used a 
 while look to
 fetch each row of the results and have it create the pull 
 down menu as it
 goes through each row. But doing it this way only stores one 
 row of results
 in a variable. Is there a way I can grab all the results from 
 a query that
 would go into an array so I could use it multiple times? I've looking
 briefly for a function to MySQL that would allow me to do 
 this but haven't
 found anything unless I misunderstand mysql_fetch_array 
 function. At first I
 thought I could loop through my while loop and have it put 
 the results from
 the query of each row in to a multidimensional array. But 
 then how would I
 add to the array after the initial row?
 
 BTW, I'm using PHP 3.0.16 so I can't use the added array 
 functions that
 PHP 4 has. I do plan on upgrading soon.
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: 
 [EMAIL PROTECTED]
 
 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Using A Query Results Multiple Times

2001-10-24 Thread Adam Douglas

Thanks for the help. I had all the code right just had to add the
mysql_data_seek. Wasn't aware it operated in this manner.


 -Original Message-
 From: Peter Lovatt [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, October 23, 2001 3:41 PM
 To: Adam Douglas; PHP-DB (mailing list) (E-mail); PHP-General (mailing
 list) (E-mail)
 Subject: RE: [PHP-DB] Using A Query Results Multiple Times
 
 
 Hi
 
 while(...)
 {
 do whatever
 }
 
 mysql_data_seek ($mysqlresultid, 0)
 
 while(...)
 {
 do whatever
 }
 
 mysql_data_seek ($mysqlresultid, 0)
 etc
 
 will set the pointer back to the beginning of the result set, 
 so you can
 scan through it as many times as you need to, without needing 
 to repeat the
 query.
 
 
 HTH
 
 Peter
 
  -Original Message-
  From: Adam Douglas [mailto:[EMAIL PROTECTED]]
  Sent: 23 October 2001 19:48
  To: PHP-DB (mailing list) (E-mail); PHP-General (mailing 
 list) (E-mail)
  Subject: [PHP-DB] Using A Query Results Multiple Times
 
 
  I have an instance where I have to query my MySQL 
 database and then
  use the multiple row results to create multiple pull down 
 menus on a web
  page. My problem is how can I take the results of the query 
 and use them
  more the once to create pull down menus? I've always used a 
 while look to
  fetch each row of the results and have it create the pull 
 down menu as it
  goes through each row. But doing it this way only stores one row
  of results
  in a variable. Is there a way I can grab all the results 
 from a query that
  would go into an array so I could use it multiple times? 
 I've looking
  briefly for a function to MySQL that would allow me to do 
 this but haven't
  found anything unless I misunderstand mysql_fetch_array function.
  At first I
  thought I could loop through my while loop and have it put the
  results from
  the query of each row in to a multidimensional array. But 
 then how would I
  add to the array after the initial row?
 
  BTW, I'm using PHP 3.0.16 so I can't use the added array
  functions that
  PHP 4 has. I do plan on upgrading soon.
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: 
 [EMAIL PROTECTED]
 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Using A Query Results Multiple Times

2001-10-23 Thread Adam Douglas

I have an instance where I have to query my MySQL database and then
use the multiple row results to create multiple pull down menus on a web
page. My problem is how can I take the results of the query and use them
more the once to create pull down menus? I've always used a while look to
fetch each row of the results and have it create the pull down menu as it
goes through each row. But doing it this way only stores one row of results
in a variable. Is there a way I can grab all the results from a query that
would go into an array so I could use it multiple times? I've looking
briefly for a function to MySQL that would allow me to do this but haven't
found anything unless I misunderstand mysql_fetch_array function. At first I
thought I could loop through my while loop and have it put the results from
the query of each row in to a multidimensional array. But then how would I
add to the array after the initial row?

BTW, I'm using PHP 3.0.16 so I can't use the added array functions that
PHP 4 has. I do plan on upgrading soon.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] dates in db

2002-01-05 Thread Adam Jackson


i have a date in my mysql database in the format of 20011201 how do I output
that to show for example 01 December 2001 or something similar?

Cheers
Adam




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] 2D array into mySQL DB

2002-01-11 Thread Adam Royle

Hi there...

I wrote a PHP script which extracts the title and content from all the 
HTML files in a directory and puts the filename, title and content into 
a 2 dimensional array.

I know the array is fine because when I print it to the page it dislays 
properly.

When I try to input it into the DB I think mySQL chokes. Is there a 
better way to put contents of an array in a db, or some way to slow down 
the process?

I have tried using insert delayed, and also doing a complex calculation 
after each insert to keep the php engine thiking but allowing mysql to 
fix itself, but this does not work. The results I get in the db is 
muffled and only contains three rows (instead of about 15) and the 
information is all jumbled aswell.

I tried a test line (commented out) and it worked as expected. This is 
my code.

for ($i=0;$icount($arr_page);$i++){

$sql = INSERT into tblContent
(Title, Filename, Parent, DirName, Content)
VALUES

('$arr_page[$i][0]','$arr_page[$i][1]','$parent','$dir_name','$arr_page[$i]
[2]');

//('$i','$i','$i','$i','$i'); this line instead of previous 
inserts as expected

mysql_query($sql);
}

Any help would be appreciated.

Adam


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] mail() on Mac OS X

2002-01-15 Thread Adam Royle

I have been trying for months now (on and off) to get mail() working in 
OS X. I have trid various things, but this is my current setup. If you 
have any suggestions or if you could put me in the right direction, then 
I would be glad.

- I am using PHP v4.0.6 on Mac OS X 10.1 (pre-compiled with cool options 
from entropy.ch)
- I installed Communigate Pro (a mail server -- and this works when I 
use it in Mail.app)
- I don't want to use sendmail, I want to use the mail server I have 
already installed.
- I have these two lines in my php.ini

SMTP = ifunk.dyndns.org
sendmail_from = [EMAIL PROTECTED]

my sendmail_path is still the same as default... but I was just thinking 
that PHP would use my smtp server(ifunk.dyndns.org)

Can someone slap me in the face if I'm misunderstanding something, or 
help me if you can.

Thanks,
Adam.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Automatic Listboxes

2002-01-15 Thread Adam Royle

Javascript is your way to do this, but there are obviously a few ways you
can do that aswell. You don't want to have to submit a form and reload
images/pages etc, so javascript is the only way to go (or dhtml or other
stuff)

One way to do this is either with layers (hide/unhide depending on what
need) and all the information is already printed to the page, but shows only
the needed information.

Another way is to create javascript arrays and let javascript do the
selections and stuff... I've seen a few tutorials around that do that...

Here are some links that might help you:

This is for dreamweaver and ASP but same principal (and explains how it
works aswell)
http://www.macromedia.com/support/ultradev/ts/documents/client_dynamic_listb
ox.htm

This is something similar, and also cool...
http://javascript.internet.com/forms/auto-drop-down.html

This is a basically what you want... but you might have to modify it a
little bit...

http://javascript.internet.com/forms/category-selection.html

So you get PHP to fill the javascript array by something like this, knowing
that I am no genius in javascript (as long as you have values in $array):

head
script langauage=Javascript
!--
function start(){
var something = new Array();
?php
for ($i=0;$icount($array);$i++){
echo javascript array stuff -- $array[$i];
}
?
// now the other javascript code (additional lists etc)
}

and then thats it! (well, sorta, but you get the jist)

Adam


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Authentication

2002-01-16 Thread Adam Royle

 I have a successful website with authenticatin and logons.  There are
 sections that I allow anyone to get to, but the others have to be
 authenticated.  This site is not using frames at all.  its a page by 
 page,
 with the unit that does the authentication and sessions being included 
 in
 each page.

 I've taken these same units to another site.  I altered the pieces 
 neccesary
 to hit the new sites database and users.  This site is using frames.  
 the
 outer frames are not using the authentication or sessions.  However,
 internal pages do.  As I enter a section that needs a logon, it prompts 
 me.
 Then it goes to the correct page.  But the next page it goes too, it 
 wants
 to get a logon again.  These pages are in a row, and they all use the 
 same
 sessions stuff that the other site uses.  I know that they all have to
 include the same units, so once it needs to logon, it'll prompt that, 
 but it
 should pass this session info from here to there, and not have to logon
 again.  Its driving me nuts.

 The only thing I can think of thats different is the frames.  I even 
 took
 the same code from the other site ( the one that does work without 
 frames),
 and plugged it in.  So the session logon was for the other site and 
 other
 db.  It'd prompt me each time too.  I am not sure what to do now...

 help please.

When I first set up PHP my sessions did not work. What I eventually 
found was something to do with my php.ini file on how it deals with 
sessions (ie. where they save them, etc)

This is some stuff from my php.ini file which i found useful (and made 
it work, I think)

register_globals = true
session.save_path = /tmp
session.use_trans_sid = 1
session.auto_start = 1

Some of it might not be the solution but I think the session.save_path 
directive is what makes it work. For better definition of what these 
things do, look in the php manual (Chapter 3. Configuration).

Hope this helps,
Adam.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] RE: Recalculation ?

2002-01-20 Thread Adam Royle

You shouldn't need to unset session variables if you're going to use them
again, just write over them. And to check if a session variable has been
used or not, you can use:

if (session_is_registered($qty)){
calcluation in here
}

If the calculation part is the same in your 'if' statement, then you should
need to do the session_unset() and session_register() stuff. If $qty is
already registered as a session variable, you can safely run
session_register($qty) again and cause no harm to the already registered
variable, so this will register a session variable, but not change an
existing session variable.

Also, in logic (I haven't tested though), your condition for your 'if'
statement ($qty == $qty) will always evaluate to true.

Adam

-Original Message-
From: Dave Carrera [mailto:[EMAIL PROTECTED]]
Sent: Saturday, January 19, 2002 3:17 AM
To: php List
Subject: Recalculation ?


Hi All,

I have create a page to calculate qtys and show totals.
This works fine, except that I change a qty the change is not registered and
calculate from the old value.

I am using sessions and have try a loop of
if($qty == $qty){
than calc stuff here}
else{
session_unset($qty);
session_register($qty);
calc stuff here
}

And have tried other ways but to no avail.

Can someone throw any light on this.

As always any help is appreciated.

Dave C





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] RE: MySQL Update help needed

2002-01-21 Thread Adam Royle

A few things to check:

1. You have a connection to the database (I'm assuming you do).
2. mysql_query() is a php function so you should not put a dollar sign
before it (indicating it is a variable. If you want mysql_query() to return
a variable, do something like this: $result = mysql_query(UPDATE etc);
3. Check that you field names are the same, they are case sensitive (I'm
pretty sure).
4. If all that doesn't work, try setting the query out in a logical pattern.
This way it is easy to find mistakes.

ie. $sql = “UPDATE search6 SET
email = ‘$email’,
description = ‘$comments’,
 etc 
region = ‘$region’
WHERE id = ‘$id’“);

-Original Message-
From: Chris Payne [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 21, 2002 3:18 PM
To: [EMAIL PROTECTED]
Subject: MySQL Update help needed


Hi there,

Can anyone see what is wrong with this query?  I am trying to update some
fields, if I do an echo everything looks good but it doesn't update the
fields in the DB - am I missing something obvious here?

Thanks for your help

Chris
www.planetoxygene.com

$mysql_query (UPDATE search6 SET email = '$email',description =
'$comments',category = '$category',url = '$url',type = '$type',country =
'$country',rating = '$rating',fname = '$fname',state = '$state',region =
'$region',city = '$city' WHERE id = '$id');



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] RE: ensuring unique field value in MySQL using PHP

2002-01-28 Thread Adam Royle

Checking a small database for username/password combination would happen so
quick, it would be nearly impossible for two usernames to be entered in.
Your script should work properly, but to make sure no duplicates are
entered, you can change the column definition using the ALTER columnName
command to make sure there are no duplicates. Look in the mySQL
documentation (www.mysql.com) to find the correct command.

Adam

-Original Message-
From: Janet Valade [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 29, 2002 1:24 PM
To: [EMAIL PROTECTED]
Subject: ensuring unique field value in MySQL using PHP


I have a form in which users create their own login name. The code for
storing the login name they created does something like the following:

$userlogin is the name the user typed in the form
$sql = select loginname from login where loginname='$userlogin';
$result=mysql_query($sql);
$num=mysql_num_rows($result);
if ($num  0)
{
   echo Sorry, that login name is already taken, Try another;
   shows form again;
}
else
   insert new record into database;
   echo okay, your new account is added;

I am wondering if it is possible that two people could hit the submit button
at the exact same time with the same login name so that the same login name
could get entered twice? Seems unlikely that this would happen by accident,
but is this something a hacker could do on purpose?

Thanks,

Janet




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] RE: FIle Uploading to database

2002-02-03 Thread Adam Royle

You missed the SET parameter in your query... example is below...

$query = INSERT INTO Canidate SET (FirstName, LastName, Indus...

Adam

-Original Message-
From: Todd Williamsen [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 04, 2002 11:06 AM
To: [EMAIL PROTECTED]
Subject: Re: FIle Uploading to database


Well...  thanks to Dan Burner for the script...  BUT

I cannot get this friggin INSERT statement to execute..  which craps out..
I cannot figure it out.  I have been staring at it for about an hour and I
still cannot figure it out

here it is:

$db = @mysql_select_db($db_name, $connection) or die(Could not select
database);
$query = INSERT INTO Canidate(FirstName, LastName, Industry, Address1,
Address2, City, State, Zip, LocationPref, Phone, Email, ResumeUp) VALUES
('$FirstName', '$LastName', '$Industry' '$Address1', 'Address2', '$City',
'$State', '$Zip', '$LocationPref', '$Phone', '$Email', '$ResumeUp2');
$result = @mysql_query($query, $connection) or die(could not execute
query);
$pat = array(#, @, *, , %, @,$,',`);
$w= '_';
$ResumeUp2 = str_replace ($pat, $w, stripslashes($ResumeUp));
exec(cp '$ResumeUp' '/resumes/$ResumeUp2');
?

it errors out on the $result could not execute query

Let me know if you need more info!

Thank you!




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




[PHP-DB] Re: Counting db generate links

2002-02-06 Thread Adam Royle

You use a link management system.

You can find examples of these all around the web, but I know you can 
get some at http://www.hotscripts.com They are also probably more 
complex and flexible than what i describe below.

Basically what it does (you could even write it yourself) is this:

1. All links point to a redirect.php script with a URL like the 
following.
  - 
eg.1.http://www.domain.com/redirect.php?URL=http://www.otherdomain.com/place.
htm
OR
  - eg.2 http://www.domain.com/redirect.php?link=432
Depending on which way you choose, the link=432 will search a database 
with link 432 and send the user to that appropriate page.
2. To redirect the user (for eg.1) all is needed is redirect.php to 
contain the following code
   - eg. ?php header (Location: $URL); ?
   - before this line is called however you need to insert the url 
(and maybe date/time/referring page etc aswell) into the database.
3. When you want to display the data, all you need to do is filter the 
results and sum up the totals as necessary.

If you store the code the following way it seems much more flexible.

3/12/02 5:36PM  http://www.domain.com/  
http://www.referringdomain.com/page.htm
3/12/02 8:44PM  http://www.domain2.co.uk/place.htm  
http://www.referringdomain.
com/page2.htm
3/13/02 7:26AM  http://www.domain.com/  
http://www.referringdomain.com/page.htm

Cause you only have to do one sql statement (a quick insert, rather than 
a select and update, etc) and then you can collate all data on a 
different page, and provide comprehensive results.


Another link system (like eg.2  up above) would involve the database a 
lot more, by connecting to the database and selecting certain links, 
then updating, etc. this is would be good if you were storing addresses 
(like downloadable things, eg PDFs or scripts, etc) cause then it really 
is a link MANAGEMENT system, and not just a link stat counter

Adam


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




[PHP-DB] Re: option in forms

2002-02-09 Thread Adam Royle

I think this is what you're getting at:

select name=artistID
option value=?= $row[ID] ??= $row[ArtistName] ?/option
/select

or something like that so it would look like (in HTML)

select name=artistID
option value=23Artist's Name First in list/option
option value=44Artist's Name second in list/option
option value=105Artist's Name third in list/option
/select

if you select the first item in the list, the next page will produce:

$artistID = 23

so yah... thats it
---____-_--_-_-_-_-___-___--_-_-_-_--

I know how to do the option call e.g.
This is the list of artists already in our database :
SELECT name=artist
?php echo $option_block; ?
/SELECT
But I want to do a form where they select the option then fill out rest
of form. The option above returns the artist name, but I want to insert
the artistid.


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




[PHP-DB] RE: Outputing Distinct rows

2002-02-10 Thread Adam Royle

What you *should* do is have a lastUpdated field in your posts table, and
the value inserted into their is the date when you update it.

Then your query would be like

$sql = SELECT posts.topic_id, posts.forum_id, topics.topic_title,
topics.topic_replies
WHERE topics.topic_id = posts.topic_id
ORDER BY posts.lastUpdated DESC LIMIT 10;

Also, this would allow for extra things in the future, such as a page
showing all updates in a certain day, or within last 3 days, or something
like that.

Hope this helps.

Adam

-Original Message-
From: KingZeus [mailto:[EMAIL PROTECTED]]
Sent: Sunday, February 10, 2002 1:36 PM
To: [EMAIL PROTECTED]
Subject: Outputing Distinct rows


I'll give you all the short version of what I need and if it is enough for
you to help that would be great. I need to pull the last 10 updated topics
from a table and output them. However, the posts table lists each post and
then has a topic id. There is also a table of topics with topic id, title,
etc. I cannot just pull the last 10 posts in the post table because those
posts could all be for the same topic and I'm trying to output the last 10
updated topics (not posts). How can I do this? I can't find anything on the
subject. This is what I tried as a random guess:
$sql = SELECT DISTINCT posts.topic_id, posts.forum_id,  topics.topic_title,
topics.topic_replies WHERE topics.topic_id = posts.topic_id DESC LIMIT 10;

Any ideas about what I need to do? I'm sure it is pretty simple.

Regards,
Steve KingZeus Downs
Co-Webmaster:
http://www.cncrenegade.com



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




Re: [PHP-DB] Session confusion :-(

2002-02-18 Thread Adam Royle

I presume that the session is not updating because PHP does not 
automatically overwrite session variables.

You should use something like this:

$category = $HTTP_GET_VARS[category];
session_register(category);

Session register can be called more than once, and has no effect on 
current session variables with the same name.

See if that works, and if it doesn't have a look at this...
http://www.php.net/manual/en/language.variables.predefined.php

Adam


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




[PHP-DB] Re: Special Insertion Into MySQL - at a loss!

2002-02-21 Thread Adam Royle

The following code is how you should retrieve the data from mySQL... 
if you wanted to update all of the information through one button, 
though, I would do it in a slightly different way...

?php

$sql = SELECT whatever FROM whatever...;

$result = mysql_query($sql);

while ($row = mysql_fetch_array($result)){
$domain = $row[0]; // first item in array
$cancel = $row[1]; // second item in array
?

tr
tdfont size=2 face=Arial?= $domain ?/font/td
tdfont size=2 face=ArialCancel This Domain?/font/td
tdfont size=2 face=Arialinput type=text name=confirm 
value='?= $cancel ?' size=3/font/td
/tr

?  }  ?


as long as all these are from the same table... the update is easy...

I recently did the same thing with ASP (and I wish we had PHP at 
work), but I don't have it here at home. It was slightly more 
complicated, in the way that each value relating to each row 
presented to the user had to be put into different tables according 
to the values.

with the HTML form, you would put the fields like this (formatted 
without HTML for ease of viewing)
this method is for updating only one table

// start row
input type=hidden name=ID[] value=?= $row[ID] ?
input type=text name=domain[] value=?= $row[Domain] 
input type=text name=cancel[] value=?= $row[Cancel] ?
// end row

so basically you get the idea... what happens here is all the values 
are put into their respective arrays (when submitting the form) and 
you loop through the arrays on the next page on an insert query...

like so...

?php

// connection information in here

for ($i=0;$icount($ID);$i++){ // this will loop through as many 
records as you got and will put the correct information
$sql = UPDATE tablename SET Domain = ' . $domain[$i] . ' , 
Cancel = ' . $cancel[$i] . ' WHERE ID =  . $ID[$i] ;
mysql_query($sql);
}

?
all the above could should work, although its untested things to 
watch out for is making sure you have single quotes around the text 
fields but none around the ID (which should be a number)

if you have multiple tables to update, mail me and I'll tell you how 
to do that... its late and I don't want to explain unless u need 
it... also, I would probably also have a good look at how you are 
presenting the form to the user. my example might not be how you 
want it to look, but i think its the data transfer that you were 
worried about...

any questions about the code?? just ask...

Adam


I have a special set of information retrieved from a while loop that I would
like a person to be able to edit and send back into a MySQL table.

I know all of the basic MySQL commands for doing such, but the PHP side to
get the input from the form to go in is really stumping me.

This is what I have:

-

$or = 0;

while($or  $orderidrows) {

   $orderinfo = mysql_fetch_row($orderidinfo);
   $domain[$or] = $orderinfo[2];
   $cancel[$or] = $orderinfo[3];

   print trtdfont size=2 
face=Arial$domain[$or]/font/tdtdfont
size=2 face=ArialCancel This Domain?/font/tdtdfont size=2
face=Arialinput type=text name=confirm value='$cancel[$or]'
size=3/font/td;

   $or++;
  }

--

The values I would normally insert into the MySQL from the form would be
$confirm - however, in this case, I have a number of rows with the same
name.  How do I distinguish one from another?  The [$or] doesn't work to do
it (didn't think it would).

Thanks for any help!

-Mike


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




[PHP-DB] Question about advanced SQL

2002-02-27 Thread Adam Royle

Hi.

I need some guidance for writing an effective query (instead of processing
through PHP).

I lets says I have two tables, tblCDs and tblOrders.

tblCD

cdID|  cdTitle  |  cdArtist
--
1   |  Great Hits   |  Bon Jovi
2   |  Forever Young|  The Youngsters
3   |  Now and Then |  Beach Boys
4   |  Cheesy Name  |  Two Tones


tblOrders

orderID |  cdID_FK  |  ordererID
--
1   |  1|  442
2   |  3|  233
3   |  1|  233


Now, I want to select all the records from tblCD where the cdID does not
appear in any row of tblOrders.cdID_FK

This means that it selects all the CDs that have not been ordered.

The results of the query should be


cdID|  cdTitle  |  cdArtist
--
2   |  Forever Young|  The Youngsters
4   |  Cheesy Name  |  Two Tones


I know how I can do this in PHP (two queries - put all cdID_FK in an array,
and on displaying the other query, check if it is in the array, and display
if not) but there HAS to be an easier way.

Adam.



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




[PHP-DB] RE: login

2002-03-10 Thread Adam Royle

If the variable $SCRIPT_NAME does not suit your needs, try the other
environment variables here:

http://www.php.net/manual/en/language.variables.predefined.php

Adam


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




[PHP-DB] Re: Output of curl to an array.

2002-03-21 Thread Adam Royle

Hi Keith,

I read your post and decided to write a function for you. Basically what 
it does is does, is take in a string, and optional newline and value 
separators, and outputs an associative array.

It actually works, and has a few comments... so yeah, enjoy.. and thanks 
for the challenge : )

Adam


You can use it like so...

PHP Script (of course, you must either have the function on the same 
page or include() it like so):

?php include('extractPairs.php');

header(Content-Type: text/plain);

$strText = Name1=Value1 \n Name2 = Value 2\nName 3 =Value 3;

$arrPairs = extractPairs($strText);

print_r($arrPairs);

?

Output:


Array
(
 [Name1] = Value1
 [Name2] = Value 2
 [Name 3] = Value 3
)

//= extractPairs.php
?php

function 
extractPairs($strText,$strValueSeparator==,$strNewlineSeparator=\n){

// kill the bad stuff... prevent a meaningless array
if (!is_string($strText)){ return array(=); }

// gets rid of newlines/spaces etc so we don't get a crap array
$strText = trim($strText);

// separate each line in an element in an array
$arrLines = explode($strNewlineSeparator,$strText);

// loop through $arrLines, separating the names/values and placing 
them in $arrOutput
for ($i=0;$icount($arrLines);$i++){
$pos = strpos($arrLines[$i],$strValueSeparator);

// get the text before and after the found position
// and get rid of the whitespace b4 and after
$arrOutput[trim(substr($arrLines[$i],0,$pos))] = 
trim(substr($arrLines[$i],$pos+1));
}

return $arrOutput;
}

?

 Ok, lets say I have some code here:

 $result = array();

 $ch = curl_init (https://www.myverificationplace.com/verify.asp;);

 curl_setopt ($ch, CURLOPT_POST, 1);
 curl_setopt ($ch, CURLOPT_POSTFIELDS, $args);
 curl_setopt ($ch, CURLOPT_TIMEOUT, 120); // Set the timeout, in seconds.
 curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
 $result = curl_exec ($ch);

 curl_close ($ch);

 Now that we see that, how can I make it so that the output from curl, 
 which
 is in the variable $result, will be an array, for each line of output?

 Some of the line of output looks like this:

 ssl_result_message=APPROVED
 ssl_txn_id=----
 ssl_approval_code=00

 I need each of the lines to be turned into a variable. Any ideas as to 
 how I
 might go about this?

 Thanks,

 Keith Posehn



[PHP-DB] Re: insert into javascript php

2002-03-22 Thread Adam Royle

PHP cannot recognise javascript variables because javascript is 
interpreted via the browser, and not the server (which php is). for php 
to use javascript variables, you must post the variable to another page 
using either a form or querystring.

Adam

 script

 c=document.forms[0].category.options[document.forms[0].category.selectedIndex]
 .text
 ?php
 $x=c;
 ?

 /script

 but the php doesn't understand this c variable


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




Re: [PHP-DB] marking DB entries...

2002-03-22 Thread Adam Royle

I have done an address book in php, although I kept the 
username/password in with the rest of their details. If you wanted to 
keep it all in two tables, then go ahead. You really should have an ID 
field in every table, whether you use it or not, and most of the times, 
you'll find you will use it. So if you're using two tables, you'll have 
a column in each of them 'linking' up the columns (ie, the same number). 
If you don't know how to do this, there are tons of tutorials on the net 
which gloss over this... (have a look at the mysql 
documentation/examples).

Then on your actual page, what you should do is have a login page, which 
checks a username/password from a form against the database. At the same 
time, retrieve the ID number where it matches the user/name password and 
put the username and id number in separate session variables.

Once you have the ID number of the person logged in, you can 
allow/disallow what they can edit depending on the ID. If you need 
further help, contact me directly.

Adam.




 Im making an address book using PHP and mySQL.
 I want each user to have access only to his/hers adressinputs. Now Im
 wondering how I gonna solve this, ofcourse its very easy just to 
 create a
 table for each user but then the hole idea of database loose its 
 purpose
 =). How can I mark each input so that only the specific user who 
 entered
 the information can access it? If two users enters the exact same
 information I want them both to have access to it...

 I was thinking about a table looking like this:
 name CHAR(30),
 adress CHAR(30),
 email CHAR(30),
 phonenumber INT(20),
 authority ENUM()//here is my thought--

 I was thinking I could save the users name in authority and thereby
 marking that this entry was made bye the specific person. Is it possible
 to
 use this? Please give me a few pointers or better, give me a website 
 where
 I
 can read about it...
 thanks!
 /Ljungan



[PHP-DB] Re: urgent guys

2002-03-22 Thread Adam Royle

You cannot use javascript variables in php, nor php variables in 
javascript, unless you write the variable to the page (for php - 
javascript) or post to a new page with querystring or form 
(javascript - php).

php - javascript:

script language=JavaScript
var jsVariable = ?= $phpVariable ?;
/script

javascript - php:

script language=JavaScript
// this is probably wrong javascript syntax, but you get the idea
location.href = thing.php?q=first+onep=second+one;
/script

Adam

 i know it has nothing to do with php but i'm stuck:)

 i have this url:
 http://localhost/auction/seller/additems.php?category=Bookssubcategory=Fiction

 and in javascript when i say for example alert(category) it gives me 
 undefineddoesn't javascript see variables passed with the url???


 Rehab M.Shouman



[PHP-DB] Re: If else Question

2002-03-26 Thread Adam Royle

Maybe I am missing something but it seems you are doing things in a 
potentially unreliable way.

Firstly... your sql statement in create.php

$query_update = INSERT INTO pets (uid) SELECT uid FROM users WHERE
uid={$session[uid]};

could simply be

mysql_query(INSERT INTO pets SET uid =  . $session[uid]);

if you are using php4 session variables, why don't you use $uid as the 
session,
so you would only need --  mysql_query(INSERT INTO pets SET uid = 
$ID);

Moving on...

I don't know why you would create an empty record, and insert data later 
if it is allowed.

Do this:

Show Form -- Submit Form -- Check Data Integrity -- Check If Allowed 
to Insert Record -- Insert Record

If anything stuffs up then you don't do the bit following.

So it doesn't check data integrity if you haven't submitted the form 
(obvious) and it doesn't insert the record until it checks the data 
integrity and if they are allowed to insert the record.

Adam.


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




[PHP-DB] Re: PHP/Access problem

2002-03-26 Thread Adam Royle

SELECT * FROM 'Documents'WHERE (CourseRef='4712' AND
Valid_From=#26/03/2002# AND Valid_Until=#26/03/2002#) Order by
Author,Title


should be


SELECT * FROM Documents WHERE (CourseRef='4712' AND
Valid_From=#26/03/2002# AND Valid_Until=#26/03/2002#) Order by
Author,Title


your table name should not hae single quotes around it...

adam



[PHP-DB] Re: Checking for 2 unique row contents

2002-03-27 Thread Adam Royle

Simple do these checks and you'll be sweet as a nut

Adam

?php

$sql = SELECT nickname FROM tblUsers WHERE nickname = '$nickname'';
$result = mysql_query($sql);

$sql = SELECT email FROM tblUsers WHERE email = '$email';
$result2 = mysql_query($sql);

if (mysql_num_rows($result)){
$error[] = That nickname is already chosen;
}

if (mysql_num_rows($result2)){
$error[] = That username is already chosen;
}

if (!$error){
// do the inserting here
}

?


// you might have this at the top of your form to show the error messages
?php
if ($error){
echo p class=\msg\\n;
for($i=0;$icount($error);$i++){
echo $error[$i] . br\n;
}
echo /p\n;
}
?

 Hi all



 I am trying to create a registration area that uses a nickname and email
 pair.



 I need both to be unique.



 So how do I that either do not already exist then if unique insert into
 db.



 So

 if nickname exist then error = sorry...

 if email exist then error = sorry...

 else must be unique

 insert.



 I have been trying for hours know but cant get the twin check to work.



 Can get single check to work though.



 I thank you in advance for any thoughts or code examples



 Dave Carrera

 Php Developer

 http://davecarrera.freelancers.net

 http://www.davecarrera.com



[PHP-DB] Advice to PHP beginners

2002-03-27 Thread Adam Royle

Just some advice... You should use a consistent programming style, 
especially with PHP. You can read some guys advice here. 
http://www.phpbuilder.com/columns/tim20010101.php3?page=1

Some of the advantages of having a consistent style, is when you are 
looking for bugs. If you look over your code and see something unusual, 
then you can target that area to see if it is the culprit. If you don't 
have a consistent style, then sometimes that can cause serious 
heartache, as everything will look unusual.

A few issues that trip up most people when beginning to use PHP, is the 
syntax errors. Usually these arise from quote issues, to semi-colon and 
brace issues. A lot of this trouble can be avoided (or easily debugged) 
by simply using tabs to your advantage. Consider the following:

?php if ($condition){ echo correct;} else {
echo 'what';
if (!$condition2){
include 'thing.php';
while (!$dead)
{ if ($jam!= $yes){ $dead = true;
} else{
for ($i=0;$i100;$i++)
{ $thing = processSomething('something', something2);
$string = 'something'.$here.too;
}
?

Technically I *think* this would be syntactically correct, but if I was 
looking for a bug, I would be shot in the foot. A better way to write 
this would be the following:

?php

if ($condition){
echo correct;
} else {
echo what;
if (!$condition2){
include ('thing.php');
while (!$dead){
if ($jam != $yes){
$dead = true;
} else {
for ($i=0;$i100;$i++){
$thing = processSomething(something, 
something2);
$string = something $here too;
}
}
}
}
}

?

So its a couple more lines, but if I came back to that script a month or 
two months later trying to fix something, or add a new feature, it would 
be easy. Couple that style with comments and you're on fire!!!

Hope this helps for someone out there...

Adam


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




[PHP-DB] Re: Pop up are you sure...

2002-04-01 Thread Adam Royle

Dave,

Javascript is client side.
PHP is server side.

Obviously the limitations imposed by each of the languages is evident.
PHP can't do anything once the output is sent to the browser.
JavaScript can't do anything before it gets sent to the browser.

But, each is important as the other.

Learn to use both (its not that hard) and it will make life a lot easier
(and more interesting).

Adam



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




Re: [PHP-DB] mail()

2002-04-02 Thread Adam Voigt

You know that $fromaddress must have the correct header's to, right?
Like just [EMAIL PROTECTED] will not be interepreted but something like 
Reply-to:[EMAIL PROTECTED]
will set the Reply-to header correctly.
Also, did you try taking out the dynamic values and just entering a hardcoded test 
without the
variables to make sure it works just even with straight static values?

Adam Voigt
[EMAIL PROTECTED]

On Tue, 2 Apr 2002 10:55:20 -0500, James Kupernik [EMAIL PROTECTED]  wrote:
 I'm trying to run a mail function .. the program is running, but I'm not
 getting the email. Here is the code .. any one have any ideas?
 
 $toaddress = $friendemail;
 
 $subject = A message from .$fromname..;
 
 $mailcontent = Here's a special message from a friend
.Your friend, .$fromname. at .$fromemail. writes:\n\n
..$message.;
 
 $fromaddress = $fromemail;
 
 mail($fromemail, $subject, $mailcontent, $fromaddress);
 
 I talked with my ISP and the sendmail_path is set up correctly
 
 I know it's not DB related, but I didn't know where else to turn. Thanks for
 any help you can provide.
 
 
 
 --
 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: RE: [PHP-DB] mail()

2002-04-02 Thread Adam Voigt

The last parameter of the mail command is for email headers, if you pass in
just a single email address it doesn't know what you want to do with that since
thats not a valid header. If you don't know what your doing with the last parameter
then you don't need to have it, and should omit it, as it is opitional for a reason.

If your sure you do need it, you seperate headers like this:

To set the reply-to field and the from field (as it would appear to the person who 
recieves
the email), you would do: From:[EMAIL PROTECTED]\nReply-to:[EMAIL PROTECTED]

This would make the email appear as coming from [EMAIL PROTECTED], while
when they clicked the reply button, it would go to [EMAIL PROTECTED], the most useful
situation for these is when your server appends a nastry from address like 
apache@localhost
or whatever from the webserver daemon.

Adam Voigt
[EMAIL PROTECTED]

On Tue, 2 Apr 2002 11:05:09 -0500 , Jamie Kupernik [EMAIL PROTECTED] wrote:
 I did try taking out the dynamic values and entering static ... Didn't
 seem to do anything. What do you mean by the Replay-to: thing you
 said. Can you show me an example that would fit in with mine?
 
 Thanks for responding..
 
 James
 
 -Original Message-
 From: Adam Voigt [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, April 02, 2002 11:02 AM
 To: James Kupernik
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] mail()
 
 
 You know that $fromaddress must have the correct header's to, right?
 Like just [EMAIL PROTECTED] will not be interepreted but something like
 Reply-to:[EMAIL PROTECTED] will set the Reply-to header correctly. Also,
 did you try taking out the dynamic values and just entering a hardcoded
 test without the variables to make sure it works just even with straight
 static values?
 
 Adam Voigt
 [EMAIL PROTECTED]
 
 On Tue, 2 Apr 2002 10:55:20 -0500, James Kupernik [EMAIL PROTECTED]
 wrote:
  I'm trying to run a mail function .. the program is running, but I'm
  not getting the email. Here is the code .. any one have any ideas?
 
  $toaddress = $friendemail;
 
  $subject = A message from .$fromname..;
 
  $mailcontent = Here's a special message from a friend
 .Your friend, .$fromname. at .$fromemail.
 writes:\n\n
 ..$message.;
 
  $fromaddress = $fromemail;
 
  mail($fromemail, $subject, $mailcontent, $fromaddress);
 
  I talked with my ISP and the sendmail_path is set up correctly
 
  I know it's not DB related, but I didn't know where else to turn.
  Thanks for any help you can provide.
 
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
 
 This message has been scanned for computer
 viruses and none were found.
 
 Country Curtains Information Systems Department
 
 
 
 
 
 
 This message has been scanned for computer
 viruses and none were found.
 
 Country Curtains Information Systems Department
 
 
 

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




Re: [PHP-DB] New PostgreSQL functions

2002-04-08 Thread Adam Voigt

I'm just curious is the purpose of these functions to remove
the requirement that programmers know SQL? I'm not trying
to sound sarcastic or anything, but I mean, whats next
a pgsql_select_join for joins? If someones smart enough to figure
out the Postgres install and performance tuning (and I know my first
time was quite a rollercoaster of pain), why would you need
to try and simplify it's use when a all powerful, all knowing, all doing
pgsql_query would work? I'm mainly just wondering because
sometimes my windows counterparts (who write in ASP or iHTML)
think it's funny PHP has so many ways to do certain things, and so
few ways to do other things. =)

Just Curious,

Adam Voigt
[EMAIL PROTECTED]

On Mon, 08 Apr 2002 13:41:46 +0900, Yasuo Ohgaki [EMAIL PROTECTED] wrote:
 Hi,
 
 I've added new PostgreSQL functions to CVS.
 
 
 array pg_metadata(resource db, string table)
 Get metadata
 
 
 array pg_convert(resource db, string table, array values)
 Check and convert values for PostgreSQL SQL statement
 It escapes and add quotes around values accoding to
 metadata (i.e. Table Definition)
 
 
 bool pg_insert(resource db, string table, array values[, bool convert[,
 bool async]])
 Insert values (field=value) to table
 
 
 bool pg_update(resource db, string table, array fields, array ids[, bool
 convert[, bool asy
 nc]])
 Update table using values (field=value) and ids (id=value)
 
 
 bool pg_delete(resource db, string table, array ids[, bool convert[,
 bool async]])
 Delete records has ids (id=value)
 
 
 array pg_select(resource db, string table, array ids[, bool convert])
 Select records that has ids (id=value)
 
 
 
 They will be available for PHP 4.3.0.
 Please refer to test files under ext/pgsql/tests/ for usage.
 
 If you use PHP 4.1.x or above, you can replace old PostgreSQL
 module by new one. There are many new functions that will be
 avaiable in PHP 4.2.0 also.
 
 Bug reports and comments are welcome.
 Enjoy.
 
 --
 Yasuo Ohgaki
 [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




Re: Re: [PHP-DB] New PostgreSQL functions

2002-04-08 Thread Adam Voigt

Well since I've programmed in PHP for a while,
I think PHP is quite capable in damn near all of the possible programming
areas. But for instance, here are some of their complaints:

1. Weak PHP-Internal Date Manipulation Functions, on certain
sites we do quite a bit of non-sql based date manipulation and
certain functions which are sql based (and there are functional
counterparts for other languages) that are missing from PHP.

2. Weak Error Handling, We could not get the custom error
handling to work except when using the trigger_error function,
which is useless if an error is caused somewhere theres not an
or die(trigger_error()). Essentially what they want is
called an error block on iHTML which essentially sends
a copy of all errors on that page to a specified email address
along with a dump of all the standard arrays like $_POST, and
$_GET, and if we could get custom error handling to work, I'm
sure we could write this in, but after a week of just trying to
get that to work, we were unsuccessful. Also, on some occasions,
even with error_reporting set to E_ALL, a missing quote or } would
make PHP just show a completely blank white page instead of an
error like unterminated function, etc. They also don't like that they
have to put or die(mssql_get_last_message()) after every query
where in other languages it would automatically stop execution of
the page and throw the error the database returned to the page.

And just to let you know, you should have seen there
eye's light up with glee at me explaining the explode and implode
functions, as they were not used to being able to use arrays in
situations where they would fit so perfectly, with other languages
which handled them clunkily at best. This is just one example
of all the positives they found to the PHP language, and I certainly
don't want you to think me a ASP zealot because I don't program
in ASP or iHTML for that matter, I'm a pure PHP evangelist from
top to bottom.

Adam Voigt
[EMAIL PROTECTED]

On Mon, 08 Apr 2002 23:04:25 +0900, Yasuo Ohgaki [EMAIL PROTECTED] wrote:
 Adam Voigt wrote:
  think it's funny PHP has so many ways to do certain things, and so
  few ways to do other things. =)
 
 I forgot to ask.
 May I ask what kind of features/functions are missing?
 It does not have to be about PostgreSQL module.
 
 --
 Yasuo Ohgaki
 

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




Re: [PHP-DB] Finding highest number in auto increment

2002-04-09 Thread Adam Voigt

SELECT * FROM whatever ORDER BY id DESC;

Ofcourse if you want Ascending order, it would be ASC instead of DESC

Adam Voigt
[EMAIL PROTECTED]

On Tue, 09 Apr 2002 15:48:45 +0200, Lisi [EMAIL PROTECTED] wrote:
 Each record in my table has a unique ID number generated by auto increment
 each time a new record is added. This is stored in a field called ID. I
 have a page that displays records as they are selected, but I want the
 default to be the latest entry if none has been selected.
 
 How do I write the query to find the highest number an display that record?
 
 It should be something like this I think:
 
 SELECT organization FROM ayny WHERE ID ...
 
 how does this end?
 
 Thanks,
 
 -Lisi
 
 
 --
 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] Finding highest number in auto increment

2002-04-09 Thread Adam Voigt

Oh, forget to include that if you only want that one record,
use the LIMIT 1 keyword as well.

Adam Voigt
[EMAIL PROTECTED]

P.S.: All of this is in the MySQL manual.

On Tue, 09 Apr 2002 15:48:45 +0200, Lisi [EMAIL PROTECTED] wrote:
 Each record in my table has a unique ID number generated by auto increment
 each time a new record is added. This is stored in a field called ID. I
 have a page that displays records as they are selected, but I want the
 default to be the latest entry if none has been selected.
 
 How do I write the query to find the highest number an display that record?
 
 It should be something like this I think:
 
 SELECT organization FROM ayny WHERE ID ...
 
 how does this end?
 
 Thanks,
 
 -Lisi
 
 
 --
 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] PHP tips to make your life easier

2002-04-24 Thread Adam Royle

Hello everybody,

There are some techniques which I use that come in REALLY handy when 
writing PHP (or even ASP). I will just go through them here briefly. Any 
questions? Email me.

1. Keep a php file (lib.php) inside a 'code' folder in a directory for 
every site you work on (depending on security needs, you might want to 
keep it out oft he web directory). In this file, keep your functions 
that you are likely to use again and again. In mine, I keep my database 
connection and query functions, and all the other string/array functions 
I create. Your pages become cleaner and to start a new page, all you 
have to type is the following:

?php include 'code/lib.php';

?

2. Try to use functions (and classes) to your advantage. Write them. I 
have written a few to make my life easier.

// Open a database connection
dbConnect();

// select and put into 2d associative array
$sql = SELECT * FROM tblTable;
$data = getData($sql, ASSOC);

If you want to use these functions, send me an email and I will send 
them to you. They are very flexible (although they are only mySQL 
compatible). Here are some functions that I wrote when I first started 
using PHP:

// if you want to quickly test a variable (such as an sql statement) 
chuck this in... saves time.

test($sql);

function test($str){
echo $str;
exit();
}

// Useful for: printing arrays and seeing their structure preformatted 
from php
// Example:
/*

plainText();

print_r($array);

*/

function plainText(){
header (Content-Type: text/plain);
}


// Useful for: sending someone back to the last page they were on
// Usage: goBack();

function goBack(){
header (Location: $HTTP_REFERER);
exit;
}



// Useful for: quick redirection to another page
// Usage: go(url.php);

function go($URL){
header (Location: $URL);
exit();
}


So you see, these functions aren't big, and they don't have to be, but 
it cleans things up a bit and makes your code more readable... And as a 
huge bonus, a lot of your syntax errors/spelling errors are fixed 
because you don't have to type as much.

Adam


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




[PHP-DB] Re: Adding totals

2002-05-20 Thread Adam Royle

This should be it (if I am understanding you correctly).

Adam

$strSQL = SELECT SUM(columnName) as sum FROM tblName;
$result = mysql_query($strSQL);

while ($row = mysql_fetch_array($result)){
$total = $row[sum];
}


Hi all,

Is there a way for me in PHP4 to add all the contens (floating numbers) =
of a cartain column whithin a row and show up the result? I have several =
time inputs and need to show the total.

Thanx.

Cesar Aracena
[EMAIL PROTECTED]
Neuquen, Argentina



Re: [PHP-DB] new pair of eyes

2002-05-31 Thread Adam Royle

Hey there,

I was just looking at your code, and I also look at other's code, and I 
think people are making life difficult for themselves. Sure a lot of 
people on this list are beginners, but thats more te reason to simplify 
code...

One thing you should always do, is write functions... I have written a 
few functions to connect to a database, execute queries and return 
results, and insert and update queries. Using functions like these make 
it a lot easier to write working code, and because it's less typing, its 
a lesser chance of an error occurring...

for example... here is a portion of my lib.php which I include() on each 
page I create (some comments are removed to save space)

putting the below code into an external file and including it on every 
page makes everything a lot cleaner, and if you need to connect to a 
database, just call

dbConnect();

in your php script... you must make sure that in the external file, the 
constants are set with your server details... or you can do it in the 
actual page with the function, like so:

dbConnect(dbname,localhost,username,password);

and if you need the connection ID, it is in the variable $DB_CONN.
If you want some more functions like this (i have a few more called 
getData(), dbInsert(), dbUpdate() which all make it a LOT easier to 
transport data to and from a mysql database), email me and I will send 
them to you directly. If you don't run mySQL, then you can just modify 
the functions to suit your DB, or you can add and delete things inside 
the functions for your own setup.

Adam

/ DEFINE CONSTANTS /

// Connecting to a database

define( DB_SERVER ,   localhost ); // used for dbConnect()
define( DB_USERNAME   ,   username ); // used for dbConnect()
define( DB_PASSWORD   ,   password ); // used for dbConnect()
define( DB_DATABASE   ,   dbname ); // used for dbConnect()


/ DATABASE FUNCTIONS /

function dbConnect($dbDatabase=DB_DATABASE, $dbServer=DB_SERVER, 
$dbUsername=DB_USERNAME, $dbPassword=DB_PASSWORD){

global $DB_CONN;

$DB_CONN = mysql_connect($dbServer, $dbUsername, $dbPassword) or 
die(Couldn't connect to database server.);
$db = mysql_select_db($dbDatabase) or die(Couldn't select 
database.);

return $DB_CONN;
}


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




[PHP-DB] sql and week starting ending numbers (dates)

2002-06-01 Thread Adam Royle

Hello all,

I am creating a finance manager in php and mysql for my own accounting 
purposes (and to broaden my skills in php and sql) and I have a couple 
of pages where I view statistics on how much I spend, etc, and what 
patterns are formed from my spending.

I have made a couple of pages with different statistics, and on one 
specific page, I show how much I spend total each week... The following 
query does that, but I want to display the start date and end date of 
the week.

$sql = SELECT YEARWEEK(purchaseDate,1) AS week,
CONCAT_WS(' ',MONTHNAME(purchaseDate), 
YEAR(purchaseDate),'- Wk', WEEK(purchaseDate,1)) AS month,
SUM(itemPrice) AS total
FROM tblCashflow
WHERE userID_FK = ${user['userID']}
AND Type = 'Expenditure'
GROUP BY week;

OK, so the sql works, and the output on the page looks like something 
below...

February 2002 - Wk 5$49.70
February 2002 - Wk 7$12.95
February 2002 - Wk 8$53.29
February 2002 - Wk 9$275.99
March 2002 - Wk 10  $78.95
March 2002 - Wk 11  $171.15
March 2002 - Wk 12  $82.85
March 2002 - Wk 13  $20.50
April 2002 - Wk 14  $55.15
April 2002 - Wk 15  $30.55
April 2002 - Wk 16  $104.20
April 2002 - Wk 17  $461.95
May 2002 - Wk 18$152.75
May 2002 - Wk 19$219.80
May 2002 - Wk 20$133.55
May 2002 - Wk 21$98.65

Now thats all well and good, but I want to make it display something 
like the following:

February 1 - 7 2002 $49.70
February 8 - 15 2002$12.95
February 16 - 23 2002 $53.29

etc etc etc

Does anyone have any idea on how this could be achieved? I looked at the 
mySQL time and Date functions, but I couldn't find out how to do it with 
that, and I think doing the work in PHP might be the answer Also, 
currently the SQL statement only shows the weeks where I have spent 
money, so if I don't spend anything in that week, it won't show up at 
all, although I would like it to say January 12 - 19 2002 $0 or 
something like that.

Below is my table schema for the above query

Adam

CREATE TABLE tblCashflow (
   ID bigint(20) NOT NULL auto_increment,
   purchaseDate date default NULL,
   categoryID_FK tinyint(4) default NULL,
   itemName text,
   itemPrice float default '0',
   isEssential tinyint(4) default '0',
   paymentTypeID_FK tinyint(4) default '1',
   receiverID_FK tinyint(4) default NULL,
   itemDesc text,
   Type text,
   userID_FK int(11) default NULL,
   PRIMARY KEY  (ID)
);


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




[PHP-DB] Re: SQL Troubles with JOIN, GROUP BY and MAX???

2002-06-04 Thread Adam Royle

I think this is something like you would want...

Adam

SELECT users.id, username, MAX(stamp) as stamp, filename
FROM users, files
WHERE users.id = userid
GROUP BY username


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




[PHP-DB] Re: Having trouble understanding how to manage arrays

2002-06-10 Thread Adam Royle

Hi Bill,

Looks like you're making it hard for yourself, by querying the database for each 
record found. Here is some code which should make your life easier. Of course, I have 
developed functions which would turn the following code into 10 or so lines, but this 
should work for your situation.

Adam

?php
/* Connecting, selecting database */
$link = mysql_connect(192.168.0.112, root, )
or die(Could not connect);
print Connected successfully;
mysql_select_db(dgdrivers) or die(Could not select database);

/* Performing SQL query */

$query = SELECT type, manname, manlink FROM man_links;
$result = mysql_query($query) or die(Query failed);
?

table border=0 cellspacing=0 cellpadding=5

?php while ($row = mysql_fetch_array($result)){ ?
tr
  td?= $row[type] ?/td
  tda href=?= $row[manlink] ??= $row[manname] ?/a/td
/tr
?php } ?

/table

?php
/* Free resultset */
mysql_free_result($result);

/* Closing connection */
mysql_close($link);
?



Re: [PHP-DB] MySQL Clustering, redundancy

2002-06-18 Thread Adam Voigt

Yes,it's called Replication in the MySQL documentation.
However, since the info in the manual is kind of sparse so I would hop
on google and do a search for specific instructions on how to do it when
your ready, but to answer your question, yes, MySQL does do
Redundancy/Failover. (Ofcourse you must take account of this in your
code interacting with the server, but the data will be sync'd).

Adam Voigt
[EMAIL PROTECTED]

On Tue, 2002-06-18 at 08:47, Matt Babineau wrote:
 Hi All:
  
 I quickly skimmed the MySQL manual and didn't see any information on
 clustering. Does MySQL have any support for clustering or some type of
 redundant failover systems?
  
 Thanks!
  
 Matt Babineau
 Freelance Internet Developer
 -
 e:  mailto:[EMAIL PROTECTED] [EMAIL PROTECTED]
 p: 603.943.4237
 w:  http://www.criticalcode.com/ http://www.criticalcode.com
 PO BOX 601
 Manchester, NH 03105
  



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




RE: [PHP-DB] MySQL Clustering, redundancy

2002-06-18 Thread Adam Voigt

I have never actually tried to program against something which talks to
multiple DB's, the quickest way would be in your DB connection code to
have something that will either:

A. Try the first DB and connect to the second if it's down.
B. Randomly choose a SQL server.

The most fluid solution I could think of would be an application
gateway of some sort which will load balance properly to different IP's
while in your code you only point to one.

Adam Voigt
[EMAIL PROTECTED]

On Tue, 2002-06-18 at 09:12, Matt Babineau wrote:
 Thanks for your response Adam! 
 
 Do you know if there is any way MySQL can be spread across multiple
 machines? I am looking at a huge application for a client, that will
 need to support thousands of simultaneous users. I am wondering if MySQL
 can handle load like that. That's why I was asking about clustering
 MySQL servers for the ability to handle more users simultaneously.
 
 Has anyone had any experience with a large scale application on MySQL?
 
 Matt Babineau
 Freelance Internet Developer
 -
 e: [EMAIL PROTECTED]
 p: 603.943.4237
 w: http://www.criticalcode.com
 PO BOX 601
 Manchester, NH 03105
 
 
 -Original Message-
 From: Adam Voigt [mailto:[EMAIL PROTECTED]] 
 Sent: Tuesday, June 18, 2002 8:55 AM
 To: [EMAIL PROTECTED]
 Cc: Matt Babineau
 Subject: Re: [PHP-DB] MySQL Clustering, redundancy
 
 
 Yes,it's called Replication in the MySQL documentation. However, since
 the info in the manual is kind of sparse so I would hop on google and do
 a search for specific instructions on how to do it when your ready, but
 to answer your question, yes, MySQL does do Redundancy/Failover.
 (Ofcourse you must take account of this in your code interacting with
 the server, but the data will be sync'd).
 
 Adam Voigt
 [EMAIL PROTECTED]
 
 On Tue, 2002-06-18 at 08:47, Matt Babineau wrote:
  Hi All:
   
  I quickly skimmed the MySQL manual and didn't see any information on 
  clustering. Does MySQL have any support for clustering or some type of
 
  redundant failover systems?
   
  Thanks!
   
  Matt Babineau
  Freelance Internet Developer
  -
  e:  mailto:[EMAIL PROTECTED] [EMAIL PROTECTED]
  p: 603.943.4237
  w:  http://www.criticalcode.com/ http://www.criticalcode.com PO BOX 
  601 Manchester, NH 03105
   
 
 
 
 -- 
 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] Converting values from text to numerical

2002-06-21 Thread Adam Royle

Hi Matt,

I think this might be the answer to your problem. It basically checks if 
the string is an integer. I generally love the PHP automatic type 
conversion, but sometimes it can trick ya :)

if (intval($val) == $val){
// integer stuff
} else {
// string stuff
}

Adam

 Hi Russ,

 thanks for the reply ...  if that will evaluate whether a (in this 
 case) a
 text string is an integer or not, then its exactly what I need! :)

 if it doesnt work, I will post a more detailed example to the list and 
 see
 what we can come up with! :)


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




[PHP-DB] Re: Populating multi-select list from mysql

2002-06-21 Thread Adam Royle

Hi Bob,

I have written some functions which make select lists much easier. I 
have two functions:
- BuildQuickSelect() - you pass a couple of parameters (tablename, etc)
- BuildSelectMenu() - you pass $sql and some more parameters

Unfortunately, they require a few things (such as other functions I have 
written). Fortunately, I have them all in one lib.php file, and you are 
welcome to use it. I think you will find it very handy and time-saving. 
I COULDN'T do without them. Look through the whole file, and you might 
see some other handy ones in there too.

There are four variables at the top of the lib.php file, which you must 
set according to your server setup (server, username, password, etc).

To use the stuff, simply include() it at the top of each page.

And to solve your problem (using the lib.php file), all you have to do 
is this:

BuildQuickSelect(category_list_array[],categories,,multiple 
size=10);

And voila... all is done...

Need any help... ask

Oh yeah, btw everyone else, I have emailed the lib.php file to Bob - if 
you want a copy, email me.

Adam




lib.php.zip
Description: Zip archive

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


[PHP-DB] Re: getting the value of a javascript variable

2002-06-22 Thread Adam Royle

Hi Hermann,

This has been covered many times on this list, but the basics are this:

PHP retrieves all information and outputs it into a javascript array -  
this way all combinations are available to javascript. Then when the 
user selects a list from the menu, javascript determines the contents of 
the second drop-down box.

There are a few examples around on the net - Google is your friend.

Adam


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





Re: [PHP-DB] Form not working...

2002-06-26 Thread Adam Royle

What you said (Mike) is mostly correct, although the GetSQLValueString() 
function in Scott's code automatically puts the quotes around the values 
if the datatype definition of text is passed to the function.

Adam


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




[PHP-DB] Re: remove from db renumbering

2002-06-30 Thread Adam Royle

You should not rely on the autonumber as a sorting method. You should use it
as a reference. I see you have two easy options (there may be more, but this
seems suitable).

1. Get the SQL to pull a random record (requires mySQL 3.23.x or higher)
SELECT * FROM tblName ORDER BY RAND() LIMIT 1

2. Get all of the ID numbers into an array and pick a random value, then
retrieve the rest of the details using the row ID you picked from the array.

Adam


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




[PHP-DB] Re: delete multiple records with one query

2002-07-02 Thread Adam Royle

another way to do this is (quicker, using only one query):

$delete_IDs = implode(,,$name_array);
$sql = DELETE FROM $mysql_table WHERE id IN ($delete_IDs);
mysql_query($sql);

or you could delete the first line (implode) and take the square 
brackets out of the name of the form field. this will make a 
comma-delimited string of all your selected ID numbers, and will be 
available in $name_array

your choice

adam


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




[PHP-DB] Re: Refresh after DB Query

2002-07-03 Thread Adam Royle

Sorry if you are a newbie..

but if might help if you delete the records before you select them to display in 
html

ie: put the delete query at the top of the page, just after this line:

require (templates/db_connect.php);

adam



[PHP-DB] Re: Urent please

2002-07-08 Thread Adam Royle

Simply open the javascript window with a querystring..

so you have some like this in your javascript code:
window.open(somepage.php?var1=value1var2=value2,theWindow,width=200,
height=300);

and if the variables are inside php... use something like this:
window.open(somepage.php?var1=?= var1 ?var2=?= var2 
?,theWindow,width=200,height=300);

adam

 maybe this is more a javescripy problem...but its related to my php 
 code:
 how can i open a new window with javacript and pass to it php 
 variables??
 thanks guys alot.


 Rehab M.Shouman


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




Re: [PHP-DB] A Simple Question

2002-07-09 Thread Adam Alkins

 4. Be careful with the $_GET[] array that Tony mentions, it is only
 available on more recent versions of PHP, before that it was
$HTTP_GET_VARS
 and a lot of people had been using just plain $var1 or whatever, assuming
 that register_globals would always be ON in the php.ini file (which also
 changed in recent versions).

 4. Be careful with the $_GET[] array that Tony mentions, it is only
 available on more recent versions of PHP, before that it was
$HTTP_GET_VARS
 and a lot of people had been using just plain $var1 or whatever, assuming
 that register_globals would always be ON in the php.ini file (which also
 changed in recent versions).


register_globals was turned off by default in the INI file in 4.2.0+ so I
would recommend against using them. Besides compatability issues, there are
security issues with it. Of course, to maintain backward compatability
(Superglobals are only supported in 4.1.0+) you might want to use the
$HTTP_POST_VARS, $HTTP_GET_VARS e.t.c. which are being phased out however.

Remember though, 4.1.0 was released on the 10th of Decemeber, so there's a
good chance many hosts have upgraded to that version or greater, but there
are always the late ones.

Good reading: http://www.php.net/manual/en/language.variables.predefined.php

--
Adam Alkins
http://www.rasadam.com
--


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




Re: [PHP-DB] catch warnings?

2002-07-10 Thread Adam Alkins

 Hi all!
 
 This is not a typical DB-Question, but I hope you give me some hints
 either...
 
 If I insert a String instead of a date(f.Ex) into the DB, I get a
 Warning:
 
 MS SQL message: Syntax error converting datetime from character
 string. (severity 16) 
 
 How can I catch these warnings in PHP?

I believe mssql_get_last_message() is what you want.

--
Adam Alkins
http://www.rasadam.com
--




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




RE: [PHP-DB] A Simple Question

2002-07-10 Thread Adam Royle

Just a correction you can use arrays with querystrings

page.php?var1[]=firstvar1[]=secondvar1[]=third

$var1
Array
(
 [0] = first
 [1] = second
 [2] = third
)


OR

page.php?var1[]=firstvar2[2]=secondvar2[]=third

$var 1
Array
(
 [0] = first
)

$var2
Array
(
 [2] = second
 [3] = third
)

You can also have multidimensional arrays, but not associative arrays.

But you do have the 255 character limitation (can be a bummer).

Adam


 Also, as far as limitations go, the following are considerations;

 1. You can't pass an array using the querystring
 2. Multiline variables (ie. textarea contents) are bad
 3. There is a limit of 255 or something characters to a URI (someone?)
 4. Be careful with the $_GET[] array that Tony mentions, it is only
 available on more recent versions of PHP, before that it was 
 $HTTP_GET_VARS
 and a lot of people had been using just plain $var1 or whatever, 
 assuming
 that register_globals would always be ON in the php.ini file (which 
 also
 changed in recent versions).

 HTH

 Beau



Re: [PHP-DB] PHP Security and Code Design

2002-07-10 Thread Adam Alkins

 I understand that this applies to data put into a form to be submitted to
a
 database (or another page, I guess), but does it also apply to
 variable/value pairs passed along the URL from a hyperlink (a
 href=foo/bar.php?thisVar=thisValClick here./a)? I couldn't quite get
it
 from the explanation above. Would I need to reference the passed variable
 with $_GET[thisVal] on the receiving page (bar.php)? I'm sure I would
have
 to if $thisVar was passed from a form with the GET method, but wasn't sure
 about the hyperlink stuff.

 Anybody working with register globals off already that can clear this up?

Yes. URL passed variables are access via the GET method. So page.php?foo=bar
is accessed by $_GET['foo']

--
Adam Alkins
http://www.rasadam.com
--


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




Re: [PHP-DB] Re: HELP NEEDED!

2002-07-13 Thread Adam Alkins

 Use mysql_result or mysql_fetch_array to get your results.
 
 Example:
 $userName = mysql_reqult($result,0);

Just use mysql_num_rows($result) and count the amount of rows selected.

if(mysql_num_rows($result) == '0')
{
do_user_doesnt_exist_stuff();
}
else
{
do_user_exists_stuff();
}

--
Adam Alkins
http://www.rasadam.com
--


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




[PHP-DB] Re: HELP NEEDED

2002-07-13 Thread Adam Royle

First of all, you are not using the variable when you are passing it to 
the sql string. Second, you are doing a pointless var check, and 
thirdly, your condition statement is flawed.

1. SQL should be (if you have register globals turned on, otherwise you 
must use $_GET['_Name1'] ):
  $_query =  select userName from users where userName='$_Name1' ;

2. mysql_query returns a result identifier - not the actual results. You 
should use mysql_num_rows() to find out if any rows were returned (or 
use the other mySQL functions to retrieve the actual data):
$numRows = mysql_num_rows($_result);

3. Print the value of $numRows, without doing a check:
echo $numRows;

4. In your IF statement, the equal comparison operator should be '==' 
(otherwise you are assigning the value to the variable). What you also 
could choose to do, is to leave out the comparison like so:

  if ( $_result ) // 0 = false, 1 = true;
   {
 echo Name was found in the database;
   }
  else
   {
echo Name was NOT found in the database;
   }

Hope that helps..

Adam


 Hi there
 I am having a problem querrying to my database.
 I wish to check to see if a username is listed in the database so that 
 I can
 authenticate that individual. However, when I try to echo my $_result 
 i'm
 always getting 0 can someone please help. I think it should be either 1 
 or
 0.

 These are my scripts.

 This is my login pagepage
 ?php
 echo FORM name=_Form1 method=post action=test.php;
echo TABLE border=1 width=300 height=300;
   echo tr;
echo td valign=top;
 echo INPUT type=text value='' name=_Name1br;
 echo INPUT type=text value='' name=_Name2br;
 echo INPUT type=submit value='Submit' name=_submitButton;
 echo INPUT type=Reset value='Reset' name=_ResetButtonbr;
echo /td valign=top;
  echo /tr;
echo /TABLE;
  echo /FORM
 ?

 This is my script processor
 ?php
 file://Script processor
 mysql_connect(localhost, nik, playas) or
  die(Could not connect to the server);

  mysql_select_db(chronicleOnline) or
   die(Could not connect to the database);

  $_query =  select userName from users where userName='_Name1' ;

  $_result = mysql_query($_query) or
   die(mysql_error());

  if ( $_result = 0 )
   {
 echo $_result;
   }
  else
   {
echo $_result;
   }
 ?

 P.S. I have no problem putting the data into the database, just this 
 query.

 Thx
 Nik



Re: [PHP-DB] extract data from database into an array

2002-07-13 Thread Adam Alkins

 I have a database, all the data is numbers. I want to make a query that
 will extract the data and then make it available in an array, so the
 array is populated 'real-time'. I could just enter the number into an
 array manually, but I want to automate the job. I don't know what to
 start looking for, the 3 books I have either don't talk about this or I
 just am missing it.
 Could someone point me in the right direction?

Well after you SELECT the data and run the query, you can use a few
functions, it depends on your database type?

For example, for MySQL, you can use mysql_fetch_array() which will take your
data and store it in an array, both numeric and associative.

i.e. $data = mysql_fetch_array($result) can be accessed like

$data['column_name']
$data[column_number]

You can also fetch an array only as an associative (mysql_fetch_assoc) or
numeric (mysql_fetch_row). And simply if selecting multiple rows, use a loop

while($data = mysql_fetch_array())...

--
Adam Alkins
http://www.rasadam.com
--


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




Re: [PHP-DB] Select a subset?

2002-07-14 Thread Adam Alkins

 ie start at record 10 and show the next 10. But this delivers back 10
 as the $num_rows variable, when I want the total number of rows.

 I don't really have to complete two querys to get the appropriate values
 do I?

mysql_num_rows just counts the amount of rows in a query, so if you only
selected 10 rows, it will return 10.

If you want to count all the rows in the table, its best to use the COUNT()
function

 SELECT COUNT(*) FROM table

--
Adam Alkins
http://www.rasadam.com
--


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




Re: [PHP-DB] extract data from database into an array

2002-07-15 Thread Adam Voigt

$query = mysql_query(SELECT whatever FROM whatever;);
while($row = mysql_fetch_array($query))
$construct[] = $row[whatever];

That will give you an array (construct) with position 0 being the first
row, position 1 being the second row, and so on.

Adam Voigt
[EMAIL PROTECTED]

On Mon, 2002-07-15 at 13:04, [EMAIL PROTECTED] wrote:
 
 Adam Alkins [EMAIL PROTECTED] wrote on 07/13/2002 07:56:46 PM:
 
   I have a database, all the data is numbers. I want to make a query that
   will extract the data and then make it available in an array, so the
   array is populated 'real-time'. I could just enter the number into an
   array manually, but I want to automate the job. I don't know what to
   start looking for, the 3 books I have either don't talk about this or I
   just am missing it.
   Could someone point me in the right direction?
 
  Well after you SELECT the data and run the query, you can use a few
  functions, it depends on your database type?
 
  For example, for MySQL, you can use mysql_fetch_array() which will take
 your
  data and store it in an array, both numeric and associative.
 
  i.e. $data = mysql_fetch_array($result) can be accessed like
 
  $data['column_name']
  $data[column_number]
 
  You can also fetch an array only as an associative (mysql_fetch_assoc) or
  numeric (mysql_fetch_row). And simply if selecting multiple rows, use a
 loop
 
  while($data = mysql_fetch_array())...
 
  --
  Adam Alkins
 
 I guess I wasn't very clear on exactly what results I expect. I can get the
 data and print all the numbers, that's no problem. What I want is to have
 all the numbers inserted into an array that would look like this:
 $datax = (50,50,50,60,60,60,70,70,70,65,65,70,75,75,80);
 Each number in the array is from a single row in the table (15 rows in this
 example).
 The database is weights, entered after a work-out, along with their reps.
 I only need the weights, as shown above. This array $datax is then
 processed
 by a php script to create a graph showing the progress of the person's
 wieght
 lifting over time. I can enter all the numbers into the array manually and
 the graph is drawn correctly, but prefer the web interface I made. This is
 okay for me, but not others.
 So, I made a web form that takes the data and inserts into the database.
 That works fine also. The table contains columns:
 squats, squats_reps, legpress, legpress_reps, etc etc.
 The first is the weight and the second is the number of reps. So after
 each workout the appropriate numbers would be entered via the form page,
 the graph would be generated with the updated numbers from another page.
 
 Hope this helps to explain it a bit better,
 
 --
 Chip
 
  http://www.rasadam.com
  --
 
 
  --
  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] Keeps prompting to download php page???

2002-07-16 Thread Adam Alkins

Wrong list. This is for Databases.

Try the php-install list.

--
Adam Alkins
http://www.rasadam.com
--


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




[PHP-DB] Re: Construct, Q+E, QBE

2002-07-17 Thread Adam Royle

This sounds very interesting. As far as I know, there are no automatic functions to do 
this, although i don't think it would be too hard to write the php function to do 
this. If end up finding a solution, please email it to me (and the list), or if you 
need a hand in writing it, I'd be happy to help.

Adam



[PHP-DB] To Bo

2002-07-21 Thread Adam Royle

Study these two parts in the manual, and you will know how to do everything you've 
mentioned (and more).

http://www.php.net/manual/en/ref.strings.php

http://www.php.net/manual/en/ref.array.php

Adam



[PHP-DB] Re: php and javascript?

2002-07-22 Thread Adam Royle

Just reiterating over what the others have said (plus expanding), and 
just a bit cleaner.

SCRIPT language=JavaScript
!--
function deleteRecord(recordName, recordID)
{
if (confirm(Do you really want to delete + recordName+?){
window.location = /delete.php?id=+recordID;
}
}
//--
/SCRIPT

!-- and your html will be like this (obviously change your var names as 
per your script  --

A HREF=javascript:deleteRecord('?= $recordName ?','?= 
$recordID ?');?= $recordName ?/A

HTH,
Adam.

 Hi,

 Here is what I wanted to achieve, I want to get a confirmation box pop 
 up
 when user click on the delete link of the webpage(displays the contents 
 got
 from mysql database). I know we can do it in javascript easily, but my
 question is:
 1st,
 a common javascript confirmation will be like this:
 SCRIPT language=JavaScript
 !--
 function go_there()
 {
 var where_to= confirm(Do you really want to go to this page??);
 if (where_to== true)
 {
 window.location=http://detination;;
 }
 else
 {
 window.location=http://original;;
 }
 }
 //--
 /SCRIPT
 A HREF=javascript:go_there()New Page/A

 my question is how to integrate the javascript with php, the sample 
 delete
 link will be something like: http://localhost/index.php?id=1 ,and the id
 number(in this case:1) is from database: (a
 href=delete.php?.$row[id].)

 2nd is there a better way to write pure php code to get a confirm 
 window pop
 up once i clicked on delete link?

 Thanks and Good day.

 Bo



Re: [PHP-DB] has anyone used php to connect to access ?

2002-07-24 Thread Adam Alkins

 hi all,
I am trying to insert some data into access but I cant. I have no
 option but to use access so has anyone inserted anything in a access db ?
 pls help with a small code which sucessfully has inserted into access.
 Thanks,
 Vishal

You can do it via ODBC

http://www.php.net/manual/en/ref.odbc.php

--
Adam Alkins
http://www.rasadam.com
--


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




Re: [PHP-DB] PHP4 MSSQL Error handling

2002-07-25 Thread Adam Voigt

$result = mssql_query($query) or die(mssql_get_last_message());

Adam Voigt
[EMAIL PROTECTED]

On Wed, 2002-07-24 at 19:48, Salve Tinkerworth wrote:
 Does anyone have any good tips for error handling? I've tried different
 methods to retrieve good error information from mssql_query but nothing
 seems to be working.
 
 Here's the latest attempt:
 
 $result=mssql_query($sql2);
 $result=mssql_query('SELECT @@ERROR As ErrorCode');
 $error=mssql_fetch_row($result);
 if($error['ErrorCode'] != 0) {
  echo $error['ErrorCode'];
  echo $sql2;
  die('Inserting OPS failed');
 }
 
 
 
 -- 
 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] mssql datetime field

2002-07-25 Thread Adam Voigt

Could you give an example of what you are sending in as the date value
in an Insert/Update?

Adam Voigt
[EMAIL PROTECTED]

On Thu, 2002-07-25 at 08:45, [EMAIL PROTECTED] wrote:
 
 has anyone had any expierence with the datetime field coming back from
 MSSQL as someting along the lines of February 3, 2036 6:36AM.  This happens
 to me no matter the time in the database.  PHP inserts it correctly, but
 the select has a problem.  I am using php4.1.2 and SqlServer 7.0.
 
 Or is anyone haveing success, in new versions of PHP.  Upgrading PHP is no
 problem, upgrading SQL is not an option
 
 Thanks in advance.
 Jeff
 
 
 
 -- 
 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: Pulling a data from array of checkboxes

2002-07-28 Thread Adam Royle

This is friendlier, cleaner and faster way to return the results.

$chk = implode(, , $chk);
$sql = SELECT field1, field2 FROM tblName WHERE ID IN ($chk) ORDER BY ID;

this should bring back all the records within one resultset, which is easier
to manage

Adam


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




[PHP-DB] Re: Auto Increment Problems....

2002-07-29 Thread Adam Royle

Firstly, don't cross post unless the question *really* has to do with both (in this 
case, it should be just db).

Secondly, your id field should only be used as a reference to a row (not showing order 
of record). Auto increments are exactly that, the rdbms will take care of creating the 
increment. 

eg. you have this table

tblName
ID | field1 | field2

Your insert sql should be something like this:

INSERT INTO tblName VALUES ('','value1', 'value2')

OR

INSERT INTO tblName SET field1 = 'value1', field2 = 'value2'

The reason why the 'hole' is there, is to maintain data integrity. Say you have two 
tables and they relate to each other (through the id). If you delete a record from one 
and it relates to something in the other table, if you add a new record using the old 
id, it will join with the second table, when it shouldn't. Confusing? yeah its just 
cause i can't explain it right.

If you want to use numbering for your records, create it dynamically when you display 
the data.

Adam


--- Original Message ---

rite,

my primary key column (id) is set to auto_increment as usual which is very
handy. But when I delete a row, the auto_increment just keeps incrementing
and there's this 'hole' left where I deleted the row!

Apart from this looking ugly, it poses another problem. In my PHP script
where I can add new rows, I query the table, checking how many rows in the
table altogether and set the new id as the next number, but this doesnt work
if theres 'holes' in the id field, as the new record tries to overwrite
another id.

So I've 2 questions
1) Can the next auto_increment value be 'set' by a SQL query
2) Can I get a SQL query to INSERT INTO the first 'hole' it finds in the ID
column??

TIA



[PHP-DB] Benefits of assigning query to variable

2002-07-31 Thread Adam Royle

Yes, I see a few benefits.

1. It makes the code easier to read.
2. It makes the code easier to debug.

Imagine the following:

$sql = SELECT * FROM tblName;
$result = mysql_query($sql);

Now if you want to print the sql and not do the select, you would simply add a line

$sql = SELECT * FROM tblName;
test($sql);
$result = mysql_query($sql);

where the function test is:

function test($var){
echo $var;
exit();
}

The benefits are more evident when you have bigger sql queries, such as:

$sql = INSERT INTO tblName SET
field1 = 'something1',
field2 = 'something2',
field3 = 'something3',
field4 = 'something4';

$result = mysql_query($sql);

Hope that answers your question.
Adam



[PHP-DB] Re: Multiple select ?

2002-08-01 Thread Adam Royle

Try using parentheses inside your sql:

Select * from table_name where (col1=1 OR col2=1) and col3=0
Select * from table_name where col1=1 OR (col2=1 and col3=0)

They make a big difference, also helps to indentify what you're selecting when you 
come back to the sql later.

Adam



Re: [PHP-DB] Need Advice on Installing PHP MySQL on Mac OSX

2002-08-11 Thread Adam Royle

You need to uncomment two lines in the httpd.conf file then restart apache

there are many places on the internet where it shows which lines (you could do it 
yaself, it has php4 in the lines)

also, make sure apache is turned on, you can do this inside system preferences

apple has some good info on their ste
http://developer.apple.com/internet/macosx/php.html

Adam



Re: [PHP-DB] Upgrading PHP

2002-08-14 Thread Adam Williams

I'd uninstall php first...I believe its rpm -e mod_php (or you can do rpm
-e `rpm -qa|grep php` and then I'd upgrade apache and PHP on your box for
security reasons.  Read the installation section in the php manual at
www.php.net for details.

Adam

On Wed, 14 Aug 2002, Julio Cuz, Jr. wrote:

 Hi--

 I'm currently running 4.0.4pl1 on RedHat 7.0 and I want to upgrade to PHP
 4.2.2is there anything special I have to do BEFORE or AFTER the
 install?  Or is it just a straight re-install of PHP on top of the current
 Version?  THANKS!

 Julio Cuz, Jr.
 [EMAIL PROTECTED]
 Information Services
 Riverside Community College


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




Re: [PHP-DB] Upgrading PHP

2002-08-14 Thread Adam Williams

I should add if you are going to upgrade apache also, to rpm -e apache
first so that You will have a clean install.  backup httpd.conf first
though!  But you might want to save /etc/logrotate.d/httpd because the rpm
-e removed this, and it is what rotates the log files for
/var/log/httpd/access_log and error_log

Adam

On Wed, 14 Aug 2002, Julio Cuz, Jr. wrote:

 Hi--

 I'm currently running 4.0.4pl1 on RedHat 7.0 and I want to upgrade to PHP
 4.2.2is there anything special I have to do BEFORE or AFTER the
 install?  Or is it just a straight re-install of PHP on top of the current
 Version?  THANKS!

 Julio Cuz, Jr.
 [EMAIL PROTECTED]
 Information Services
 Riverside Community College


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




Re: [PHP-DB] PHP File for adding to database

2002-08-15 Thread Adam Williams

what is the structure of the table that this info will be going into?
Paste me the CREATE TABLE command you used to create it.

Adam

On Thu, 15 Aug 2002, Shoulder to Shoulder Farm wrote:

 Hi all,
 How can I make a PHP4 page that will add information to a MySQL database
 when the person (me) clicks the Submit button. The following fields to
 be added are:

 SKU
 Name
 About
 PriceOZ
 PriceLB

 Thanks all, Taj





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




Re: [PHP-DB] Connecting Linux (PHP) to MS Access database

2002-08-15 Thread Adam Williams

See if this message posted earlier helps you out:

http://marc.theaimsgroup.com/?l=php-dbm=102938139730405w=2

Adam

On 16 Aug 2002, Osman Omar wrote:

 Hi,

 Can I connect/access MS access database from linux ?
 if can, what software/driver that I need?

 Now I'm using iodbc without any success

 thanks







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




Re: [PHP-DB] Return Results in Categories - like CNET

2002-08-16 Thread Adam Williams

If your articles are in an SQL database uses the LIMIT clause on your SQL
statement.

Adam

On Fri, 16 Aug 2002, olinux wrote:

 I would like to allow articles to be searched and
 returned in grouped categories - similar to cnet.com

 See example here:
 http://cnet.search.com/search?timeout=3q=php

 Grouping is not a problem - but it becomes a problem
 when there are thousands of results and I only want to
 display the first few - similar to the way cnet does.

 Thanks much,
 olinux




 __
 Do You Yahoo!?
 HotJobs - Search Thousands of New Jobs
 http://www.hotjobs.com




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




Re: [PHP-DB] default value for date.

2002-08-19 Thread Adam Williams

set a default value that isn't possible (like -99-99 99:99:99) and
then have an if statement saying if ( $row[date] == '-99-99 99:99:99'
) { $row[date] = '';}

Adam

On Mon, 19 Aug 2002, Smita Manohar wrote:

 i'm using php with mysql. some tables in database have date fields for which
 i have not set any default value. while displaying the values from tables,
 if any record has null value for date field then it displays 0-00-00.
 what i need to do to display null value or spaces instead of zeros.

 suggestions are welcome.

 thnx and regds,
 smita.



 _
 Send and receive Hotmail on your mobile device: http://mobile.msn.com





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




[PHP-DB] Re: Date Subtraction

2002-08-21 Thread Adam Royle

Use getdate() with mktime() and this is your solution.

http://www.php.net/manual/en/function.getdate.php

http://www.php.net/manual/en/function.mktime.php

Adam



Re: [PHP-DB] full text search and how to underline keyword in results

2002-08-25 Thread Adam Royle

The first argument passed to eregi_replace is

 .$keywords[$i]. 

You are concatenating the string and a space on the end and front. This was
obviously used as a hack to make sure only full words were highlighted. A
fix for this? A simple hack would be to take out the spaces, so it is simply
$keywords[$i], although you could figure out a proper regex if you don't
want partial words higlighted.

Adam


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




[PHP-DB] is the following query legal?

2002-08-26 Thread Adam Williams

I have an informix database with a table called phptesttable.  It has a
SERIAL field (for mysql users that can help, its the same as INT NOT NULL
PRIMARY KEY AUTO_INCREMENT) and a CHAR field (CHAR in Informix is the
same as VARCHAR in mysql).

In my PHP script if I submit an array and then insert all the data by
looping through with for loop to INSERT all the data from the array my the
value it inserts is empty.  For example I have:

INSERT INTO phptesttable (textname) VALUES ('$statement[$counter]')

but when I echo $querya it shows:

INSERT INTO phptesttable (textname) VALUES ('')

It should show the value of the $statement[$counter] that I am looping
through.  But as above you can see the value is empty, but when I echo
$statement[$counter] and $counter, they are shown correctly:

the counter is set to 1
the statement is testing this field

So it should echo INSERT INTO phptesttable (textname) VALUES ('testing
this field' but obviously it is not.

When I change the query to not use an array and only insert one variable:

INSERT INTO phptesttable (textname) VALUES ('$statement')

it echos and inserts correctly.  So my question is, is it legal to loop
through an array and insert the array $statement[$counter]?  I am at a
loss as to what is happening, because if I change the form to submit one
variable instead of an array, it works fine.  Any idea as to what is
happening?

Adam




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




Re: [PHP-DB] is the following query legal?

2002-08-26 Thread Adam Williams

I got it to work.  I have to put the statement in ifx_prepare right before
I call it in the loop.  I think its because when I define the statement at
the start of the code, $statement[$counter] has not been asigned yet so it
sets its value to nothing.

Adam


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




Re: [PHP-DB] How do I submit data AND send user to other page?

2002-08-26 Thread Adam Williams

use an HTML form.

Adam


On Mon, 26 Aug 2002, Gerd Ulrich wrote:

 Hello, I want to build a questionaire where the user is guided through five
 pages of questions. How can I program PHP that the user gets to the second
 page after pushing the Submit-Button?
 My solution printed here doesn't work.
 Any hints are greatly apreciated!

 S. Maier

 ?php
 if ($submit) {
  // process form
 require ('.htmypasswd');
 $verbnr = mysql_connect ($dbhost,$dbuser,$dbpasswd);
 $db = mysql_connect($dbhost,$dbuser,$dbpasswd);
 mysql_select_db(pretest,$db);
 $sql = INSERT INTO frage3 (a1,a2,a3,be_fe01,be_fe02) VALUES
 ('$a1','$a2','$a3','$be_fe01','$be_fe02');
 $result = mysql_query($sql);
 header (Location: http://www.example.com;);
 exit;
 } else{
   // display form
 ?






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




Re: [PHP-DB] AUTO_INCREMENT problemos

2002-08-27 Thread Adam Williams

Thats how its supposed to work.  It won't reuse old numbers even after you
delete the entire row.

Adam

On Tue, 27 Aug 2002, simon wrote:

 Hi

 Wondering if anybody can help with this:

 My table has an INT column named 'member_id' which is set to AUTO_INCREMENT.
 It works very well but I have inserted and deleted some test rows during the
 development stage and now my incremented numbers have jumped ahead.
 The deleted rows (their member_id values) have not been forgotten it seems
 and the DB is using them still to evaluate the next number.

 Any ideas?

 Simon






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




Re: [PHP-DB] Create database

2002-08-27 Thread Adam Williams

?php
$conn = mysql_connect(localhost,username,password) or die(Couldn't
connect to mysql);

$query = (CREATE DATABASE db_name);

if (mysql_query($query))
{
echo pThe database was created successfully/p;
}
else
{
echo pThe database was not created .mysql_error()./p;
}
?

If it still gives you the same error, try connecting to mysql from the
console with mysql -u user -ppasswd

Adam

On Tue, 5 Aug 2003, Russell Griechen wrote:

 Newbie here,
 With PhpMyAdmin, What is the syntax for create database?

 I have:

 $link = mysql_pconnect(hostname, username, password)
 or exit(Could not connect);

 if (mysql_create_db(Sportsmen)) {
 print (Database created successfully\n);
 } else {
 printf (Error creating database: %s\n, mysql_error ());
 }
   /*error
 Error
 MySQL said:


 You have an error in your SQL syntax near '$link =
 mysql_pconnect(\64.177.44.120\, \russgri\, \sportsme\)
 or' at line 1

 Russell Griechen





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




Re: [PHP-DB] login won't work for Internet Explorer

2002-08-27 Thread Adam Williams

View the source in mozilla, it might just be suppressing the output
for whatever reason.

Adam

On Wed, 28 Aug 2002 [EMAIL PROTECTED] wrote:



 Hi there,

 I am experiencing a peculiar problem. I have recently moved a PHP / MySQL driven
 website I have been developing from my linux box on to a live host. Everything
 seemed to go smoothly apart from one peculiar problem. When I access the site
 using Internet Explorer (so far I have tried 5.0 and 5.5), I am unable to log
 into the members' section of the site. Instead I receive the following error:

 Warning: Unable to jump to row 0 on MySQL result index 2 in
 [pathdir]/member_login_check.php on line 12

 Warning: Unable to jump to row 0 on MySQL result index 2 in
 [pathdir]/member_login_check.php on line 13

 Warning: Unable to jump to row 0 on MySQL result index 2 in
 [pathdir]/member_login_check.php on line 14

 The peculiarity is that when I log in using Mozilla, I have no problem. Why
 should the choice of browser have any effect on a set of processes which are all
 server-side? Or am I completely wrong about that? All suggestions and help
 appreciated.

 Thanks, Ben







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




Re: [PHP-DB] connectivity problem

2002-08-27 Thread Adam Williams

look at http://www.php.net/manual/en/function.pg-connect.php

do you have postgresql starting with the -i paramater so that it is
listening on a TCP port?  PHP needs this to be able to connect to
postgresql.

Adam

On Tue, 27 Aug 2002, Brian Noecker wrote:

 Hey everyone, got a problem here.  I'm using php4.2.1, postgres 7.2.  I'm
 trying to do a simple database connect with the following small php script:
 --
 htmlheadtitlePHP Test/title/head
 body
 ?php

 //connect to postgres database
 $conn=pg_connect(user=bnoecker dbname=brian);

 //see if our connection was successful
 if ($conn==false) {
 //connection failed - exit the page with an error
 echo pg_errormessage($conn);
 exit;
 }
 else if($conn) {
 echo I did it;
 }
 $sql=SELECT * FROM employee;
 $sql_result=pg_exec($conn.$sql) or die (Couldn't Execute Query.);
 

 I can manually run the SELECT * FROM employee string and get results with
 user bnoecker.  I've granted all to bnoecker and as well added the postgres
 admin to the user=.  In test, no password has been assigned.  I do not get a
 connection failed message, in fact I do the the I did it message.  I do
 however get the following as it tries to do the query:

 I did it
 Warning: pg_exec() query failed: ERROR: parser: parse error at or near
 resource in /home/bnoecker/public_html/hello.php on line 19
 Couldn't Execute Query.
 Now, others use the same postgres instance with other databases from php
 scripts without issue, mostly using includes.  Can someone show me what I
 may be overlooking.  I'm new to php but I found examples where things are
 basically layed out like what I've got?

 Thanks,
 Brian




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




Re: [PHP-DB] connectivity problem

2002-08-27 Thread Adam Williams

In your connect statement, you aren't selecting a password and TCP port to
connect to.  You made need to specify those.

Adam

On Tue, 27 Aug 2002, Brian Noecker wrote:

 Hey everyone, got a problem here.  I'm using php4.2.1, postgres 7.2.  I'm
 trying to do a simple database connect with the following small php script:
 --
 htmlheadtitlePHP Test/title/head
 body
 ?php

 //connect to postgres database
 $conn=pg_connect(user=bnoecker dbname=brian);

 //see if our connection was successful
 if ($conn==false) {
 //connection failed - exit the page with an error
 echo pg_errormessage($conn);
 exit;
 }
 else if($conn) {
 echo I did it;
 }
 $sql=SELECT * FROM employee;
 $sql_result=pg_exec($conn.$sql) or die (Couldn't Execute Query.);
 

 I can manually run the SELECT * FROM employee string and get results with
 user bnoecker.  I've granted all to bnoecker and as well added the postgres
 admin to the user=.  In test, no password has been assigned.  I do not get a
 connection failed message, in fact I do the the I did it message.  I do
 however get the following as it tries to do the query:

 I did it
 Warning: pg_exec() query failed: ERROR: parser: parse error at or near
 resource in /home/bnoecker/public_html/hello.php on line 19
 Couldn't Execute Query.
 Now, others use the same postgres instance with other databases from php
 scripts without issue, mostly using includes.  Can someone show me what I
 may be overlooking.  I'm new to php but I found examples where things are
 basically layed out like what I've got?

 Thanks,
 Brian




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




Re: [PHP-DB] Script to control mysql users?

2002-08-29 Thread Adam Williams

read mysql.com's documentation on the GRANT command.  Or install
phpmyadmin and use that.

Adam

On Thu, 29 Aug 2002, Leif K-Brooks wrote:

 I need to add mysql users to some databases, but my dumb control panel
 (ensim) doesn't seem to have a feature to do that, and I'm nothing in
 the mysql database.  Does anyone have a script to let me add them
 automaticly if I supply it with the root password?





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




Re: [PHP-DB] This is driving me insane!

2002-08-29 Thread Adam Williams

restart apache

Adam

On Thu, 29 Aug 2002, James Hatridge wrote:

 HI all...

 I'm at my end, would some kind soul please help? I'm working on a database
 using SuSE 8.0, mysql, and PHP. All the standard installs.

 I need to use exec, unlink, etc. BUT the durn PHP is stuck in safe_mode and
 I can't get it out. I've looked in /etc/php.ini and it shows safe_mode as
 off, but when I use phpinfo() it is show on.

 Can anyone help?

 Thanks

 JIM






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




Re: [PHP-DB] how to hide source code??

2002-08-29 Thread Adam Williams

set you to owner of the script and then chmod 700 it

Adam

On Thu, 29 Aug 2002, Smita Manohar wrote:

 hii
 im using php script with mysql. i want to hide the script from the admin or
 from the person who has privileges to access all the data. bcos i use ftp to
 upload the files. and i don't want anyone should be able to view the source.

 is it possible to do so?

 thnx and regds,
 smita.



 _
 Send and receive Hotmail on your mobile device: http://mobile.msn.com





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




RE: [PHP-DB] how to hide source code??

2002-08-29 Thread Adam Williams

oh yeah duh me, set it 701

Adam

On Thu, 29 Aug 2002, Ryan Jameson (USA) wrote:

 Wouldn't that make php unable to read it as well? Then it is useless as well.
  Ryan

 -Original Message-
 From: Adam Williams [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, August 29, 2002 1:00 PM
 To: Smita Manohar
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] how to hide source code??


 set you to owner of the script and then chmod 700 it

   Adam

 On Thu, 29 Aug 2002, Smita Manohar wrote:

  hii
  im using php script with mysql. i want to hide the script from the admin or
  from the person who has privileges to access all the data. bcos i use ftp to
  upload the files. and i don't want anyone should be able to view the source.
 
  is it possible to do so?
 
  thnx and regds,
  smita.
 
 
 
  _
  Send and receive Hotmail on your mobile device: http://mobile.msn.com
 
 
 





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




  1   2   3   >