[PHP-DB] Re: chat

2005-05-02 Thread JeRRy
From:Patrick Dunegan [EMAIL PROTECTED]To:[EMAIL PROTECTED]:Sun, 1 May 2005 
08:22:58 -0500Subject:chat
Does anyone know where there is a good chat room with PHP developers?


-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.11.0 - Release Date: 4/29/2005


 

There is a quite a few free ones but I don't believe any of the free ones are 
good, some you can customize and some you can't but customization is also poor. 
 I suggest if you want a good one get someone to create you one, than you get 
what you want.  Otherwise if you don't mind something that is similar to other 
sites go free and yucky! :P

Up to you, if you need further info just shoot me an email directly.

J





-
Find local movie times and trailers on Yahoo! Movies.


RE: [PHP-DB] String manipulation

2005-05-02 Thread Bastien Koert
Are you trying to achieve this in the db or for the application? It sounds 
like the application, in which case I would get the string from the db and 
then use substr to pull out the various elements.

$first_name = substr($rows['name'],0,1);
$last_name = substr($rows['name'],1);
Bastien
From: Chris Payne [EMAIL PROTECTED]
To: php-db@lists.php.net
Subject: [PHP-DB] String manipulation
Date: Mon, 2 May 2005 00:48:58 -0400
Hi there everyone,

I'm working with a mysql Db where I have a single string that I have to
split into 2 strings, the first character is the first name and I have that
split off into it's own variable, but what I need to know is what's the 
best
method to read the string again BUT ignore the first letter as that is
already copied into $firstname?  So basically I have $firstname defined 
from
the one string, but I have to define $lastname from the SAME string value 
as
the one I used for $firstname, BUT ignoring the first letter but I'm not
sure what the best method is to achieve this?


Any help would be very appreciated.

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


[PHP-DB] Sorting multidimensional arrays from mysql

2005-05-02 Thread J. Connolly
Morning all,
I am having problems understanding what I need to do. Usually for most 
of my work, all i need to do is pull the information and place it like this:

function office_list(){
   global $link;
   echo tabletr;
   $sql = SELECT town
   FROM offices;
   $result = mysql_query($sql, $link);
   while ($array = mysql_fetch_array($result)){
   $office = $array['town'];
   $state = $array['state'];
   $zip = $array['zip'];
   echo td$office/td
   td$state/td
   td$zip/td;
   }
   echo /tr/table;
}
But now I need to separate the information in order to build a more 
complex table. I do not understand how to obtain each cell. I have a 
fixed number so it will never change.
I thought multidimensional arrays came as array[0][0], but when i try

$office = $array['town'][0]
I just get the first letter of that office. If someone could point me in 
the right direction I'd greatly appreciate it. I think I just do not 
know the terminology I am looking for. The PHP manual keeps brining me 
to pages that are not what I need.
Thank you,
jozef

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


RE: [PHP-DB] Sorting multidimensional arrays from mysql

2005-05-02 Thread Juffermans, Jos
mysql_fetch_array will always only return 1 row. $array['town'] won't be an
array but just a text and is therefor interpreted differently.

If you can give us more information (ie data model, output sample) we might
be able to help you a bit better.

Jos

-Original Message-
From: J. Connolly [mailto:[EMAIL PROTECTED]
Sent: 02 May 2005 15:42
To: PHP list
Subject: [PHP-DB] Sorting multidimensional arrays from mysql


Morning all,

I am having problems understanding what I need to do. Usually for most 
of my work, all i need to do is pull the information and place it like this:

function office_list(){
global $link;
echo tabletr;
$sql = SELECT town
FROM offices;
$result = mysql_query($sql, $link);
while ($array = mysql_fetch_array($result)){
$office = $array['town'];
$state = $array['state'];
$zip = $array['zip'];
echo td$office/td
td$state/td
td$zip/td;
}
echo /tr/table;
}

But now I need to separate the information in order to build a more 
complex table. I do not understand how to obtain each cell. I have a 
fixed number so it will never change.
I thought multidimensional arrays came as array[0][0], but when i try

$office = $array['town'][0]

I just get the first letter of that office. If someone could point me in 
the right direction I'd greatly appreciate it. I think I just do not 
know the terminology I am looking for. The PHP manual keeps brining me 
to pages that are not what I need.
Thank you,
jozef

-- 
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] Aggregate MySQL functions in html table via php - having problems

2005-05-02 Thread Finner, Doug
I want to build a table that is populated from a MySQL query and have
the table include some aggregate data (mean, sd, and cv).
 
If I select 'avg(RawData) as Mn' - and then stuff Mn into the table -
life is good.
If I try and select just RawData and computed the mean and sd at the
time the table is created, I get an error 'Unidentified index:
avg(RawData) in php file name at line where I try and do the avg and
sd
 
The format used below that does not work came from a suggestion by Oli
(the original suggestion used echo rather than printf, but it seems to
me the concept should be identical - am I wrong here???).
 
I have a working method so I am in good shape, I'm just trying to learn
other ways to get the same result.  Any tips or pointers are
appreciated.
 
Doug
 
/// Query for STATISTICAL data
/
$sql = SELECT
RunID, ItemSN, RawDataDesc, ReasonRun, RawData,  //note, I've tried with
including and excluding RawData from this query - no change in the error
Avg(RawData) as Mn, Std(RawData) as SD, //note, I've
tried leaving this line in and taking it out - no change in the error.
(Std(RawData)/Avg(RawData) * 100) as CV
FROM $table
Where RawData != 'Passed' and RawData != 'Failed'
Group By RawDataDesc;
 
echo brbr;
 
$result = mysql_query($sql, $link)
or die(mysql_error());
 
echo This is the statistical data report for Item: $table brbr;
echo table border=1\n;
echo trtdRunID/tdtdItemSN/tdtdRunReason/tdtdDesc/td
td BGCOLOR='33FF99'Mean/tdtd BGCOLOR='99FFCC'SD/tdtd
BGCOLOR='FFCC66'CV/tr\n;
 
while($myrow = mysql_fetch_assoc($result)) {
printf(trtd%s/tdtd%s/tdtd%s/tdtd%s/td
td BGCOLOR='33FF99'%.1f/tdtd BGCOLOR='99FFCC'%.2f/tdtd
BGCOLOR='FFCC66'%.2f/tr\n,
$myrow['RunID'], $myrow['ItemSN'], $myrow['ReasonRun'],
$myrow['RawDataDesc'],
$myrow['Mn'], $myrow['SD'], $myrow['CV']);
// this works fine every time
//$myrow['avg(RawData)'], $myrow['std(RawData)'], $myrow['CV']); //
this was suggested by someone on this list but returns Unidentified
index: avg(RawData)
in php file name at line this line when uncommented and used
}
 
echo /table\n;

___
This e-mail message has been sent by Kollsman, Inc. and is for the use
of the intended recipients only. The message may contain privileged
or confidential information. If you are not the intended recipient
you are hereby notified that any use, distribution or copying of
this communication is strictly prohibited, and you are requested to
delete the e-mail and any attachments and notify the sender immediately.


RE: [PHP-DB] Aggregate MySQL functions in html table via php - ha ving problems

2005-05-02 Thread Juffermans, Jos
Hi,

Since you're telling mysql Avg(RawData) as Mn the index in $myrow won't be
Avg(RawData), it'll just be Mn.

Try printing the entire $myrow to find out what you're receiving from mysql:
print pre; print_r($myrow); print /pre;
That will show you the keys that you should use.

Jos


-Original Message-
From: Finner, Doug [mailto:[EMAIL PROTECTED]
Sent: 02 May 2005 16:05
To: php-db@lists.php.net
Subject: [PHP-DB] Aggregate MySQL functions in html table via php -
having problems


I want to build a table that is populated from a MySQL query and have
the table include some aggregate data (mean, sd, and cv).
 
If I select 'avg(RawData) as Mn' - and then stuff Mn into the table -
life is good.
If I try and select just RawData and computed the mean and sd at the
time the table is created, I get an error 'Unidentified index:
avg(RawData) in php file name at line where I try and do the avg and
sd
 
The format used below that does not work came from a suggestion by Oli
(the original suggestion used echo rather than printf, but it seems to
me the concept should be identical - am I wrong here???).
 
I have a working method so I am in good shape, I'm just trying to learn
other ways to get the same result.  Any tips or pointers are
appreciated.
 
Doug
 
/// Query for STATISTICAL data
/
$sql = SELECT
RunID, ItemSN, RawDataDesc, ReasonRun, RawData,  //note, I've tried with
including and excluding RawData from this query - no change in the error
Avg(RawData) as Mn, Std(RawData) as SD, //note, I've
tried leaving this line in and taking it out - no change in the error.
(Std(RawData)/Avg(RawData) * 100) as CV
FROM $table
Where RawData != 'Passed' and RawData != 'Failed'
Group By RawDataDesc;
 
echo brbr;
 
$result = mysql_query($sql, $link)
or die(mysql_error());
 
echo This is the statistical data report for Item: $table brbr;
echo table border=1\n;
echo trtdRunID/tdtdItemSN/tdtdRunReason/tdtdDesc/td
td BGCOLOR='33FF99'Mean/tdtd BGCOLOR='99FFCC'SD/tdtd
BGCOLOR='FFCC66'CV/tr\n;
 
while($myrow = mysql_fetch_assoc($result)) {
printf(trtd%s/tdtd%s/tdtd%s/tdtd%s/td
td BGCOLOR='33FF99'%.1f/tdtd BGCOLOR='99FFCC'%.2f/tdtd
BGCOLOR='FFCC66'%.2f/tr\n,
$myrow['RunID'], $myrow['ItemSN'], $myrow['ReasonRun'],
$myrow['RawDataDesc'],
$myrow['Mn'], $myrow['SD'], $myrow['CV']);
// this works fine every time
//$myrow['avg(RawData)'], $myrow['std(RawData)'], $myrow['CV']); //
this was suggested by someone on this list but returns Unidentified
index: avg(RawData)
in php file name at line this line when uncommented and used
}
 
echo /table\n;

___
This e-mail message has been sent by Kollsman, Inc. and is for the use
of the intended recipients only. The message may contain privileged
or confidential information. If you are not the intended recipient
you are hereby notified that any use, distribution or copying of
this communication is strictly prohibited, and you are requested to
delete the e-mail and any attachments and notify the sender immediately.

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



Re: [PHP-DB] URL question. .

2005-05-02 Thread Martin Norland
Mark Cain wrote:
 a 404 script is the way I would handle it.
[snip]
- Original Message -
From: Chris Payne [EMAIL PROTECTED]
To: php-db@lists.php.net
Sent: Friday, April 29, 2005 11:00 PM
Subject: [PHP-DB] URL question
Hi there everyone,
My client needs to be able to have their url www.blahblah.com
http://www.blahblah.com/  pickup the product number but I can't do it
the way I'd want (which would be www.blahblah.com/?mls=examplenumber, instead
they said it MUST be www.blahblah.com/examplenumber - how can I grab the
number AFTER the .com in PHP so that I can process it with MySQL without
it being assigned a variable name, just the number?
[snip]
You might also want to use apache mod_rewrite
http://httpd.apache.org/docs/mod/mod_rewrite.html
e.g. .htaccess
RewriteEngine On
RewriteRule ^/prod/(.*)$ product.php?pid=$1 [R]
I don't see that there's any easy way to trap a 404 error and rewrite 
based on that, you might be able to check if the requested object 
existed beforehand and set an ENV var to check against.

I don't know whether the straight 404 work would be easiest, or whether 
you might want to combine the two.  If you absolutely can't have any 
other pieces in the URL that you can uniquely tie to product lookups, 
you'll have a hard time doing this with just mod_rewrite, so the 404 may 
be the way to go.

Still, something to be aware of.  You could also do a rewrite map if the 
products are sufficiently static, though in that case you could also 
just alias it / etc.

cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International 
Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

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


RE: [PHP-DB] Sorting multidimensional arrays from mysql

2005-05-02 Thread Juffermans, Jos
In that case the best way is to read all the data at once. Something like
this:


// first read all the data
$sql = SELECT street, town, state, zip, phone FROM offices;
$result = mysql_query($sql, $link);
$all_data = array();
while ($this_row = mysql_fetch_array($result)){
array_push($all_data, $this_row);
}

// then create the HTML
echo table;
echo tr;
foreach ($all_data as $this_row) {
echo th . $this_row{town} . /th;
}
echo /tr;
echo tr;
foreach ($all_data as $this_row) {
echo td . $this_row{town} . /td;
}
echo /tr;
echo tr;
foreach ($all_data as $this_row) {
echo td . $this_row{street} . ,  .
$this_row{state} .   . $this_row{zip} . /td;
}
echo /tr;
echo tr;
foreach ($all_data as $this_row) {
echo tdPhone:  . $this_row{phone} . /td;
}
echo /tr;
echo /table;


Jos

PS: Please always reply to [EMAIL PROTECTED]

-Original Message-
From: J. Connolly [mailto:[EMAIL PROTECTED]
Sent: 02 May 2005 16:14
To: Juffermans, Jos
Subject: Re: [PHP-DB] Sorting multidimensional arrays from mysql


I have the data which comes out like this from a select all statement

1, 1510 New State Highway (Rte. 44),Raynham, MA,2767
2,  646 Washington St., South Easton,MA,2375
3,   47 Broad St.,  Bridgewater, MA,2324
4,  605 Belmont St.,Brockton,MA,2301
5,  662 Main St.,   Falmouth,MA,2540

I need to be able to pull out certain cells when necessary and place 
them in a table. When I need to fetch one entire row, it is no problem. 
I just do not understand how to define each cell as unique. Perhaps this 
is not possible?

I need the data to be inputted something like:

th
Easton
/th
th
Raynham
/th
/tr
tr
td
646 Washinton Street
/td
td
1510 New State Highway (Rte.44)
/td
/tr
tr
td
South Easton, MA 02375
/td
td
Raynham, MA 02767
/td
/tr
tr
td
Phone:  (508) 238-8400
/td
td
Phone:  (508) 822-7444
/td
/tr

thanks,
jozef






Juffermans, Jos wrote:

mysql_fetch_array will always only return 1 row. $array['town'] won't be an
array but just a text and is therefor interpreted differently.

If you can give us more information (ie data model, output sample) we might
be able to help you a bit better.

Jos

-Original Message-
From: J. Connolly [mailto:[EMAIL PROTECTED]
Sent: 02 May 2005 15:42
To: PHP list
Subject: [PHP-DB] Sorting multidimensional arrays from mysql


Morning all,

I am having problems understanding what I need to do. Usually for most 
of my work, all i need to do is pull the information and place it like
this:

function office_list(){
global $link;
echo tabletr;
$sql = SELECT town
FROM offices;
$result = mysql_query($sql, $link);
while ($array = mysql_fetch_array($result)){
$office = $array['town'];
$state = $array['state'];
$zip = $array['zip'];
echo td$office/td
td$state/td
td$zip/td;
}
echo /tr/table;
}

But now I need to separate the information in order to build a more 
complex table. I do not understand how to obtain each cell. I have a 
fixed number so it will never change.
I thought multidimensional arrays came as array[0][0], but when i try

$office = $array['town'][0]

I just get the first letter of that office. If someone could point me in 
the right direction I'd greatly appreciate it. I think I just do not 
know the terminology I am looking for. The PHP manual keeps brining me 
to pages that are not what I need.
Thank you,
jozef

  


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



Re: [PHP-DB] Sorting multidimensional arrays from mysql

2005-05-02 Thread J. Connolly
Thank you, That was the conceptual problem I was having.
jozef
Juffermans, Jos wrote:
In that case the best way is to read all the data at once. Something like
this:
// first read all the data
$sql = SELECT street, town, state, zip, phone FROM offices;
$result = mysql_query($sql, $link);
$all_data = array();
while ($this_row = mysql_fetch_array($result)){
array_push($all_data, $this_row);
}

// then create the HTML
echo table;
echo tr;
foreach ($all_data as $this_row) {
echo th . $this_row{town} . /th;
}
echo /tr;
echo tr;
foreach ($all_data as $this_row) {
echo td . $this_row{town} . /td;
}
echo /tr;
echo tr;
foreach ($all_data as $this_row) {
echo td . $this_row{street} . ,  .
$this_row{state} .   . $this_row{zip} . /td;
}
echo /tr;
echo tr;
foreach ($all_data as $this_row) {
echo tdPhone:  . $this_row{phone} . /td;
}
echo /tr;
echo /table;
Jos
PS: Please always reply to [EMAIL PROTECTED]
-Original Message-
From: J. Connolly [mailto:[EMAIL PROTECTED]
Sent: 02 May 2005 16:14
To: Juffermans, Jos
Subject: Re: [PHP-DB] Sorting multidimensional arrays from mysql
I have the data which comes out like this from a select all statement
1, 1510 New State Highway (Rte. 44),Raynham, MA,2767
2,  646 Washington St., South Easton,MA,2375
3,   47 Broad St.,  Bridgewater, MA,2324
4,  605 Belmont St.,Brockton,MA,2301
5,  662 Main St.,   Falmouth,MA,2540

I need to be able to pull out certain cells when necessary and place 
them in a table. When I need to fetch one entire row, it is no problem. 
I just do not understand how to define each cell as unique. Perhaps this 
is not possible?

I need the data to be inputted something like:
th
Easton
/th
th
Raynham
/th
/tr
tr
td
646 Washinton Street
/td
td
1510 New State Highway (Rte.44)
/td
/tr
tr
td
South Easton, MA 02375
/td
td
Raynham, MA 02767
/td
/tr
tr
td
Phone:  (508) 238-8400
/td
td
Phone:  (508) 822-7444
/td
/tr
thanks,
jozef


Juffermans, Jos wrote:
 

mysql_fetch_array will always only return 1 row. $array['town'] won't be an
array but just a text and is therefor interpreted differently.
If you can give us more information (ie data model, output sample) we might
be able to help you a bit better.
Jos
-Original Message-
From: J. Connolly [mailto:[EMAIL PROTECTED]
Sent: 02 May 2005 15:42
To: PHP list
Subject: [PHP-DB] Sorting multidimensional arrays from mysql
Morning all,
I am having problems understanding what I need to do. Usually for most 
of my work, all i need to do is pull the information and place it like
   

this:
 

function office_list(){
  global $link;
  echo tabletr;
  $sql = SELECT town
  FROM offices;
  $result = mysql_query($sql, $link);
  while ($array = mysql_fetch_array($result)){
  $office = $array['town'];
  $state = $array['state'];
  $zip = $array['zip'];
  echo td$office/td
  td$state/td
  td$zip/td;
  }
  echo /tr/table;
}
But now I need to separate the information in order to build a more 
complex table. I do not understand how to obtain each cell. I have a 
fixed number so it will never change.
I thought multidimensional arrays came as array[0][0], but when i try

$office = $array['town'][0]
I just get the first letter of that office. If someone could point me in 
the right direction I'd greatly appreciate it. I think I just do not 
know the terminology I am looking for. The PHP manual keeps brining me 
to pages that are not what I need.
Thank you,
jozef


   

 

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


RE: [PHP-DB] Sorting multidimensional arrays from mysql

2005-05-02 Thread John R. Sims, Jr.
I need your help.

I have a script that allows me to select a specific user from a mysql
database and then allow me to show the data on a specific client.

I would like to put this information into a for that I have created instead
of just displaying them on the screen.

Any Suggestions.

Keeping the faith in fatherhood

John


_

PHP script

?php
//connect to database
$conn = mysql_connect(localhost, root, becky) or die(mysql_error());
mysql_select_db(testDB,$conn)  or die(mysql_error());

if ($_POST[op] != view)  {
//haven't seen the selection form, so show it
$display_block = h1Select an Entry/h1;

//get parts of records
$get_list = select id, concat_ws(', ', lname, fname) as
display_name from client order by lname, fname;
$get_list_res = mysql_query($get_list) or die(mysql_error());

if (mysql_num_rows($get_list_res)  1) {
//no records
$display_block .= pemSorry, no records to
select!/em/p;

} else {
//has records, so get results and print in a form
$display_block .= 
form method=\post\ action=\$_SERVER[PHP_SELF]\
PstrongSelect a Record to View:/strongbr
select name=\sel_id\
option value=\\-- Select One --/option;

while ($recs = mysql_fetch_array($get_list_res)) {
$id = $recs['id'];
$display_name = stripslashes($recs['display_name']);

$display_block .= option
value=\$id\$display_name/option;
}

$display_block .= 
/select
input type=\hidden\ name=\op\ value=\view\
pinput type=\submit\ name=\submit\ value=\View
Selected Entry\/p
/FORM;
}
} else if ($_POST[op] == view) {

//check for required fields
if ($_POST[sel_id] == )  {
header(Location: selentry.php);
exit;
}

   //get master_info
$get_master = select *, concat_ws(' ', fname, lname) as display_name
from client where id = $_POST[sel_id];
$get_master_res = mysql_query($get_master);

$master = mysql_fetch_array($get_master_res);

$display_name = stripslashes($master['display_name']);
$student_id = stripslashes($master['student_id']);
$input_date = stripslashes($master['input_date']);
$address = stripslashes($master['address']);
$city = stripslashes($master['city']);
$state = stripslashes($master['state']);
$zip = stripslashes($master['zip']);
$hphone = stripslashes($master['hphone']);
$mphone = stripslashes($master['mphone']);
$email = stripslashes($master['email']);
$ctcorg = stripslashes($master['ctcorg']);
$cmanager = stripslashes($master['cmanager']);
$neighborhood = stripslashes($master['neighborhood']);
$notes = stripslashes($master['notes']);








 $display_block = h1Showing Record for $display_name/h1br
Student ID: $student_idbr
Input Date:  $input_datebr
br
Address: $addressbr
City: nbsp;$citybr
State: nbsp;$statebr
Zip Code: nbsp;$zipbr
Home Phone: nbsp;$hphonebr
Mobil Phone: $mphonebr
Email Address: nbsp;$emailbr
br
CTC organization: nbsp;$ctcorgbr
Case Manager:nbsp;$cmanager br
Neighborhoods: nbsp;$neighborhood br
Intake Notes: nbsp;$notesbrhrbr;

?

fieldset
legendEnter your information in the form below:/legend
table width=990 height=206 border=1
  tr
th width=467 scope=col bgcolor=#CCbStudent ID:/b
  input type=text name=student_id size=15 maxlength=15 /th
th width=507 scope=col bgcolor=#CC

Input Date: input type=text name=insert_date size=15 maxlength=15
/thbr
?php
//Prints something like: Monday 15th of January 2003 05:51:38 AM
echo date(l dS of F Y -- h:i:s A);//Prints something like: Monday the 15th
?
  /tr
  tr
tdpistrongEnter Name: First,nbsp;Last/strong/ibr
  input type=text name=fname size=15 maxlength=15nbsp;
  input type=text name=lname size=30 maxlength=30 nbsp;
 brbAddress:/b br
  input type=text name=address size=40 maxlength=40
  /p
  pbCity, State, Zip Code/b br
  input type=text name=city size=15 maxlength=15,
   

[PHP-DB] Problems with a script

2005-05-02 Thread John R. Sims, Jr.
?php
if (($_POST[op] != add) || ($_GET[master_id] != )) {
//haven't seen the form, so show it
$display_block = 
h1Add an Entry/h1
form method=\post\ action=\$_SERVER[PHP_SELF]\;
 
if ($_GET[master_id] != ) {
//connect to database
$conn = mysql_connect(localhost, root, becky) or
die(mysql_error());
mysql_select_db(testDB,$conn)  or die(mysql_error());
 
//get first, last names for display/tests validity
$get_names = select concat_ws(' ', fname, lname) as display_name
from client where id = $_GET[master_id];
$get_names_res = mysql_query($get_names) or die(mysql_error());
 
if (mysql_num_rows($get_names_res) == 1) {
$display_name = mysql_result($get_names_res,0,'display_name');
}
}
 
if ($display_name != ) {
$display_block .= PAdding information for
   strong$display_name/strong:/p;
} else {
$display_block .= 
PstrongFirst/Last Names:/strongbr
input type=\text\ name=\fname\ size=30 maxlength=75
input type=\text\ name=\lname\ size=30 maxlength=75;
}
$display_block .= PstrongAddress:/strongbr
 input type=\text\ name=\address\ size=30
 
 PstrongCity/State/Zip:/strongbr
 input type=\text\ name=\city\ size=30 maxlength=50
 input type=\text\ name=\state\ size=5 maxlength=2
 input type=\text\ name=\zip\ size=10 maxlength=10
 
 
 
 PstrongHome Telephone Number:/strongbr
 input type=\text\ name=\hphone\ size=30 maxlength=25
 

 PstrongMobil Telephone Number:/strongbr
 input type=\text\ name=\mphone\ size=30 maxlength=25
 

 PstrongEmail Address:/strongbr
 input type=\text\ name=\email\ size=30 maxlength=150
 
PstrongCTC Organization:/strongbr
 input type=\text\ name=\ctcorg\ size=30 maxlength=150
 
PstrongCase Manager:/strongbr
 input type=\text\ name=\cmanager\ size=30 maxlength=150
 
PstrongNeighborhood:/strongbr
 input type=\text\ name=\neighborhood\ size=30 maxlength=150
 
 PstrongPersonal Note:/strongbr
 textarea name=\notes\ cols=35 rows=5 wrap=virtual/textarea
 input type=\hidden\ name=\op\ value=\add\
 input type=\hidden\ name=\master_id\ value=\$_GET[master_id]\
 
 pinput type=\submit\ name=\submit\ value=\Add Entry\/p
 /FORM;
 
} else if ($_POST[op] == add) {
//time to add to tables, so check for required fields
if ((($_POST[fname] == ) || ($_POST[lname] == )) 
($_POST[master_id] == )) {
header(Location: basicinfo_form.php);
exit;
}
 
//connect to database
$conn = mysql_connect(localhost, root, becky) or
die(mysql_error());
mysql_select_db(testDB,$conn)  or die(mysql_error());
 
if ($_POST[master_id] == ) {
//add to master_name table
$add_master = insert into client values ('$_POST[fname]',
'$_POST[lname]');
mysql_query($add_master) or die(mysql_error());
 
//get master_id for use with other tables
$master_id = mysql_insert_id();
} else {
 $master_id = $_POST[master_id];
}
 
 if (($_POST[address]) || ($_POST[city]) || ($_POST[state]) ||
($_POST[zip])) {
  //something relevant, so add to address table
  $add_address = insert into client values ('$_POST[address]',
'$_POST[city]', '$_POST[state]', '$_POST[zip]');
  mysql_query($add_address) or die(mysql_error());
 }
 
 if ($_POST[hphone]) {
  //something relevant, so add to telephone table
  $add_tel = insert into client values ('$_POST[hphone]');
  mysql_query($add_tel) or die(mysql_error());
 }
 
 if ($_POST[mphone]) {
  //something relevant, so add to fax table
  $add_fax = insert into client values ('$_POST[mphone]');
  mysql_query($add_fax) or die(mysql_error());
 }
 
 if ($_POST[email]) {
  //something relevant, so add to email table
  $add_email = insert into client values ('$_POST[email]',);
  mysql_query($add_email) or die(mysql_error());
 }
 
if ($_POST[ctcorg]) {
  //something relevant, so add to ctcorg table
  $add_email = insert into client values ('$_POST[ctcorg]',);
  mysql_query($add_email) or die(mysql_error());
 }
 
if ($_POST[cmanager]) {
  //something relevant, so add to ccmanager table
  $add_email = insert into client values ('$_POST[cmanager]',);
  mysql_query($add_email) or die(mysql_error());
 }
 
if ($_POST[neighborhood]) {
  //something relevant, so add to neighborhood table
  $add_email = insert into client values ('$_POST[neighborhood]',);
  mysql_query($add_email) or die(mysql_error());
 }
 
 if ($_POST[notes]) {
  //something relevant, so add to notes table
  $add_note = insert into client values ('$_POST[notes]');
  mysql_query($add_note) or die(mysql_error());
 }
 
 $display_block = h1Entry Added/h1
 PYour entry has been added.  Would you like to
 a href=\basicinfo_form.php\add another/a?/p;
}
?
HTML
HEAD
TITLEAdd an Entry/TITLE
/HEAD
BODY
?php echo $display_block; ?
/BODY
/HTML


RE: [PHP-DB] Problems with a script

2005-05-02 Thread Bastien Koert
Since I definitely don't have time to copy your script and duplicate your 
environment, perhaps you would be so kind as to tell what the hell is wrong 
with itthen we can try to help you

bastien
From: John R. Sims, Jr. [EMAIL PROTECTED]
To: php-db@lists.php.net
Subject: [PHP-DB] Problems with a script
Date: Mon, 2 May 2005 17:07:48 -0400
?php
if (($_POST[op] != add) || ($_GET[master_id] != )) {
//haven't seen the form, so show it
$display_block = 
h1Add an Entry/h1
form method=\post\ action=\$_SERVER[PHP_SELF]\;
if ($_GET[master_id] != ) {
//connect to database
$conn = mysql_connect(localhost, root, becky) or
die(mysql_error());
mysql_select_db(testDB,$conn)  or die(mysql_error());
//get first, last names for display/tests validity
$get_names = select concat_ws(' ', fname, lname) as display_name
from client where id = $_GET[master_id];
$get_names_res = mysql_query($get_names) or die(mysql_error());
if (mysql_num_rows($get_names_res) == 1) {
$display_name = mysql_result($get_names_res,0,'display_name');
}
}
if ($display_name != ) {
$display_block .= PAdding information for
   strong$display_name/strong:/p;
} else {
$display_block .= 
PstrongFirst/Last Names:/strongbr
input type=\text\ name=\fname\ size=30 maxlength=75
input type=\text\ name=\lname\ size=30 maxlength=75;
}
$display_block .= PstrongAddress:/strongbr
 input type=\text\ name=\address\ size=30
 PstrongCity/State/Zip:/strongbr
 input type=\text\ name=\city\ size=30 maxlength=50
 input type=\text\ name=\state\ size=5 maxlength=2
 input type=\text\ name=\zip\ size=10 maxlength=10

 PstrongHome Telephone Number:/strongbr
 input type=\text\ name=\hphone\ size=30 maxlength=25
 PstrongMobil Telephone Number:/strongbr
 input type=\text\ name=\mphone\ size=30 maxlength=25
 PstrongEmail Address:/strongbr
 input type=\text\ name=\email\ size=30 maxlength=150
PstrongCTC Organization:/strongbr
 input type=\text\ name=\ctcorg\ size=30 maxlength=150
PstrongCase Manager:/strongbr
 input type=\text\ name=\cmanager\ size=30 maxlength=150
PstrongNeighborhood:/strongbr
 input type=\text\ name=\neighborhood\ size=30 maxlength=150
 PstrongPersonal Note:/strongbr
 textarea name=\notes\ cols=35 rows=5 wrap=virtual/textarea
 input type=\hidden\ name=\op\ value=\add\
 input type=\hidden\ name=\master_id\ value=\$_GET[master_id]\
 pinput type=\submit\ name=\submit\ value=\Add Entry\/p
 /FORM;
} else if ($_POST[op] == add) {
//time to add to tables, so check for required fields
if ((($_POST[fname] == ) || ($_POST[lname] == )) 
($_POST[master_id] == )) {
header(Location: basicinfo_form.php);
exit;
}
//connect to database
$conn = mysql_connect(localhost, root, becky) or
die(mysql_error());
mysql_select_db(testDB,$conn)  or die(mysql_error());
if ($_POST[master_id] == ) {
//add to master_name table
$add_master = insert into client values ('$_POST[fname]',
'$_POST[lname]');
mysql_query($add_master) or die(mysql_error());
//get master_id for use with other tables
$master_id = mysql_insert_id();
} else {
 $master_id = $_POST[master_id];
}
 if (($_POST[address]) || ($_POST[city]) || ($_POST[state]) ||
($_POST[zip])) {
  //something relevant, so add to address table
  $add_address = insert into client values ('$_POST[address]',
'$_POST[city]', '$_POST[state]', '$_POST[zip]');
  mysql_query($add_address) or die(mysql_error());
 }
 if ($_POST[hphone]) {
  //something relevant, so add to telephone table
  $add_tel = insert into client values ('$_POST[hphone]');
  mysql_query($add_tel) or die(mysql_error());
 }
 if ($_POST[mphone]) {
  //something relevant, so add to fax table
  $add_fax = insert into client values ('$_POST[mphone]');
  mysql_query($add_fax) or die(mysql_error());
 }
 if ($_POST[email]) {
  //something relevant, so add to email table
  $add_email = insert into client values ('$_POST[email]',);
  mysql_query($add_email) or die(mysql_error());
 }
if ($_POST[ctcorg]) {
  //something relevant, so add to ctcorg table
  $add_email = insert into client values ('$_POST[ctcorg]',);
  mysql_query($add_email) or die(mysql_error());
 }
if ($_POST[cmanager]) {
  //something relevant, so add to ccmanager table
  $add_email = insert into client values ('$_POST[cmanager]',);
  mysql_query($add_email) or die(mysql_error());
 }
if ($_POST[neighborhood]) {
  //something relevant, so add to neighborhood table
  $add_email = insert into client values ('$_POST[neighborhood]',);
  mysql_query($add_email) or die(mysql_error());
 }
 if ($_POST[notes]) {
  //something relevant, so add to notes table
  $add_note = insert into client values ('$_POST[notes]');
  mysql_query($add_note) or die(mysql_error());
 }
 $display_block = h1Entry Added/h1
 PYour entry has been added.  Would you like to
 a 

Re: [PHP-DB] Problems with a script. .

2005-05-02 Thread Martin Norland
John R. Sims, Jr. wrote:
 ?php
[snip * - not even gunna bother]
 /HTML
Okay, quick/proper fixes 1 - 4:
1) you never open a FORM element, you only close it - you'll be 
wanting one, probably with a method=POST.

2) you should quote your array indices... just because php will evaluate 
them as themselves doesn't mean it's a good thing to rely on.
wrong: ($_POST[master_id] == )) {
right: ($_POST['master_id'] == )) {

3) you should similarly quote and curly group for the mysql queries.
wrong:
$add_master = insert into client values ($_POST[fname]', '$_POST[lname]');
right:
$add_master = insert into client values ('{$_POST['fname']}',
'{$_POST['lname']}');
4) also, all of your queries are doing inserts - they're not specifying 
the fields they are to insert into, and I'm sure many of them should in 
fact be UPDATE statements.  You'll want to fix that before your data 
gets *too* sparse.


Once that's all fixed, go to step 5.

5) rewrite all the database accesses to prevent people from doing sql 
injection attacks and ruining everything.

cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International 
Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

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


[PHP-DB] MySQLi group

2005-05-02 Thread john
Caio,
I have started a new Google group for those of us here that may run into
issues specifically with MySQLi in PHP5.
http://groups-beta.google.com/group/MySQLi
Regards,
John
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] Where are my form variables?

2005-05-02 Thread MIGUEL ANTONIO GUIRAO AGUILAR
Hi!!

I created a form with five text boxes, method=post and action=myscript.php; but 
I can't see the variables at the target script, why?

Do I need a special sintaxis for accesing the POST array?
Regards,

--
MIGUEL GUIRAO AGUILERA

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