[PHP-DB] union/select statement number of columns

2007-10-19 Thread Jas
Hello all, I receive an error of the following: The used SELECT
statements have a different number of columns. Any help, pointers,
tutorials are appreciated.

Here are the two tables structure I am trying to pull from:
Table 1
mysql describe orders;
++--+--+-+-++
| Field  | Type | Null | Key | Default | Extra  |
++--+--+-+-++
| id | int(255) | NO   | PRI | | auto_increment |
| ordernum   | int(10)  | NO   | | ||
| date   | varchar(60)  | NO   | | ||
| time   | varchar(20)  | NO   | | ||
| group  | varchar(20)  | NO   | | ||
| purpose| varchar(255) | NO   | | ||
| tracking   | varchar(120) | NO   | | ||
| contact| varchar(255) | NO   | | ||
| eta| varchar(50)  | NO   | | ||
| department | varchar(125) | NO   | | ||
| notes  | varchar(255) | NO   | | ||
++--+--+-+-++
11 rows in set (0.01 sec)

Table 2
mysql describe order_items;
+-+---+--+-+-++
| Field   | Type  | Null | Key | Default | Extra  |
+-+---+--+-+-++
| id  | int(11)   | NO   | PRI | | auto_increment |
| ordernum| int(124)  | NO   | | ||
| quantity| int(124)  | NO   | | ||
| description | varchar(124)  | NO   | | ||
| price   | decimal(10,0) | NO   | | ||
| partnum | varchar(255)  | NO   | | ||
| vendor  | varchar(255)  | NO   | | ||
+-+---+--+-+-++
7 rows in set (0.00 sec)

And here is the statement I am using (PHP):
$query = ( SELECT * FROM `orders` WHERE ( `ordernum` LIKE $var\ OR
`purpose` LIKE \$var\ OR `tracking` LIKE \$var\ OR `contact` LIKE
\$var\ OR `date` LIKE \$var\ OR `time` LIKE \$var\ OR `eta` LIKE
\$var\ OR `department` LIKE \$var\ OR `notes` LIKE \$var\ ) AND
`group` = \$group\ ) UNION ( SELECT * FROM `order_items` WHERE (
`ordernum` LIKE \$var\ OR `price` LIKE \$var\ OR `partnum` LIKE
\$var\ OR `vendor` LIKE \$var\ OR `quantity` LIKE \$var\ OR
`description` LIKE \$var\ ) ORDER BY `ordernum` );

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



[PHP-DB] Re: Looking for a small open-source PHP-DB app that utilize OOP.

2007-09-28 Thread Jas
Well some resources for learning it first as these are usually the best
source of information:

Tutorials:
http://www.phpfreaks.com/tutorials.php
http://www.php-editors.com/articles/simple_php_classes.php

Examples:
http://www.phpclasses.org

I really recomend reading and following these as it will undoubtably
help with learning OOP with PHP/MySQL.

As a simple example here is a class, functions and how to use:

?PHP
// class.inc.php
class TestOOP
{
 function ChkPHPFuncs( $function_name )
 {
  if( empty( $function_name ) ) {
   return 1;
  } else {
   if( !function_exists( $function_name ) ) {
return 1;
   } else {
return 0;
   }
  }
 }
}
?

To use within a script:
?PHP
//include our class file so lib is available
include 'class.inc.php';

// check for mcrypt functions compiled with php
$list = array( 'mcrypt_cbc', 'mcrypt_cfb', 'mcrypt_create_iv',
'mcrypt_decrypt', 'mcrypt_ecb', 'mcrypt_encrypt' );

// initialize class file so we may use functions from that class
$x = new TestOOP();

//now use $x as our handle for any function from within class file
for( $i = 0; $i  count( $list ); $i++ ) {
 echo $x-chkPHPFuncs( $list[$i] );
}
?

Also here are some resources from PHP.net for reference:
http://us3.php.net/zend-engine-2.php
http://www.php.net/oop

HTH
Jas


T K wrote:
 Hi,
 For a study purpose, I'm looking for a small open source program that works
 in PHP-MySQL. In particular, I would like to see some examples with PHP 5
 and Object-Oriented Programming (such as class, objects, and so on).
 
 I'm looking for a small program, possibly like blog, wiki, forum and so on.
 I've downloaded several programs, but most of them don't use
 classes/objects.
 
 I'm using PHP without OOP, but recently set out to learn OOP.
 
 Any suggestions would be appreciated.
 
 Tek
 

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



Re: [PHP-DB] Re: mysql statement [SOLVED]

2007-09-27 Thread Jas
Thanks, most of that I knew but the grouping in your first example is
the one that allowed me to only use records matching any field but still
limited by the one db field. So thanks again. I was not aware of the
parenthesis for grouping objects like a mathematical equation where
anything inside the paren's gets executed first and still conditional on
the remainder of the equation.

TG wrote:
 Couple of little pointers.
 
 If you're doing the sub-select, then you don't need the group like 'mac' 
 because you've already limited your query in the subselect to a specific 
 groupname.
 
 The subselect is probably unnecessary since what you're doing is relatively 
 simple and uses the same table.  It probably just adds overhead.  But in 
 relation to that, you need to segregate your OR statements from your final 
 AND statement or it won't limit by group properly.
 
 WHERE ( `ordernum` LIKE 35132
 OR `price` LIKE 35132
 OR `partnum` LIKE 35132
 OR `vendor` LIKE 35132
 OR `purpose` LIKE 35132
 OR `tracking` LIKE 35132
 OR `contact` LIKE 35132 )
 AND `group` LIKE 'mac'
 
 Notice the ( and ).
 
 Next pointer..  LIKE is used when you're doing a non-exact search, but you 
 haven't used any wildcards to indicate a partial search.   So what you're 
 essentially doing is the same as price = 35132.If you're doing a 
 multi-field search and want to use LIKE, you'd do this on each:
 
 `price` LIKE %35132%
 
 The % is sorta like * in other systems.  Any quantity of any characters can 
 match that space.  Or you can do`price` LIKE 35132% if you want to 
 search the beginning of the field (note the % at the end, but not the 
 beginning of the search string this time).
 
 One last thing... I don't know if it increases speed or not, but since you're 
 using so many fields this MAY speed up the query.Depends on how much 
 data you're searching through and if you're doing %search% or need to find 
 start/end strings.
 
 Anyway, here's the test..  what's faster, what you're trying to do:
 
 WHERE ( `ordernum` LIKE 35132 OR `price` LIKE 35132 OR `partnum` LIKE 
 35132
  OR `vendor` LIKE 35132 OR `purpose` LIKE 35132 OR 
 `tracking` LIKE 35132
  OR `contact` LIKE 35132 )
 AND `group` LIKE 'mac'
 
 or something like this
 
 WHERE CONCAT(`ordernum`, `price`, `partnum`, `vendor`, `purpose`, `tracking`, 
 `contact`) LIKE %35132%
 AND `group` LIKE '%mac%'
 
 
 All the LIKE comparisons against a ton of data MAY be more taxing on the 
 server than doing a CONCAT of all the fields then doing a single LIKE.   If 
 you're doing LIKE %search% where it can appear anywhere in any of the 
 fields, then CONCAT + LIKE would work just as good as LIKE OR LIKE OR ...  
 results-wise.   I don't know if it's faster/less intensive or not though.  
 You'd have to do some tests.
 
 Also, comparisons like = should (if I recall) be faster than LIKE 
 comparisons.  So if you really meant to use =, do that instead.
 
 Let me know if any of that's unclear.  I know I get some kooky ideas 
 sometimes.  Also, anyone see anything I screwed up or have thoughts on this 
 matter?
 
 Good luck!
 
 -TG
 
 
 
 
 
 
 - Original Message -
 From: Jas [EMAIL PROTECTED]
 To: php-db@lists.php.net
 Date: Wed, 26 Sep 2007 12:08:53 -0600
 Subject: [PHP-DB] Re: mysql statement [SOLVED]
 
 Got if figured out, needed a sub-select type of query:

 mysql  SELECT *
  - FROM ( SELECT * FROM `orders`
  - WHERE `group` = groupname )
  - AS orders UNION SELECT * FROM `orders`
  - WHERE `ordernum` LIKE 35132
  - OR `price` LIKE 35132
  - OR `partnum` LIKE 35132
  - OR `vendor` LIKE 35132
  - OR `purpose` LIKE 35132
  - OR `tracking` LIKE 35132
  - OR `contact` LIKE 35132
  - AND `group` LIKE 'mac'
  - ORDER BY `ordernum`
  - LIMIT 0 , 30;

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



[PHP-DB] mysql statement

2007-09-26 Thread Jas
I am looking for some advice on how to achieve something and so far have
been unable to do what I am looking to do.

Here is the query I am using:
mysql  SELECT *
- FROM `orders`
- WHERE `ordernum` LIKE 35132
- OR `price` LIKE 35132
- OR `partnum` LIKE 35132
- OR `vendor` LIKE 35132
- OR `purpose` LIKE 35132
- OR `tracking` LIKE 35132
- OR `contact` LIKE 35132
- AND `group` LIKE 'mac'
- ORDER BY `ordernum`
- LIMIT 0 , 30;

First here is the table structure:
mysql describe orders;
+-+--+--+-+-++
| Field   | Type | Null | Key | Default | Extra  |
+-+--+--+-+-++
| id  | int(255) | NO   | PRI | | auto_increment |
| ordernum| int(10)  | NO   | | ||
| date| varchar(60)  | NO   | | ||
| time| varchar(20)  | NO   | | ||
| group   | varchar(20)  | NO   | | ||
| quantity| int(10)  | NO   | | ||
| description | varchar(255) | NO   | | ||
| price   | decimal(3,0) | NO   | | ||
| partnum | varchar(40)  | NO   | | ||
| vendor  | varchar(65)  | NO   | | ||
| purpose | varchar(255) | NO   | | ||
| tracking| varchar(120) | NO   | | ||
| contact | varchar(255) | NO   | | ||
| eta | varchar(50)  | NO   | | ||
| department  | varchar(125) | NO   | | ||
| notes   | varchar(255) | NO   | | ||
+-+--+--+-+-++
16 rows in set (0.00 sec)

I am trying to essentially LIMIT all records returned to be limited by
the `group` field so I can search for records and limit the rows
returned by that one field.

Any tips? TIA.
jas

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



[PHP-DB] Re: Data not fetching in the textfield.

2007-09-26 Thread Jas
You could always do something like:

while( $x = myql_fetch_array( $results ) ) {
 list( $var1, $var2, $var3, ... ) = $x;
 echo input name=storename type=text value=$var1;
}

Chris Carter wrote:
 I am trying to fetch data through this code:
 
 My code:
 for($i=0;$imysql_num_rows($results);$i++)
 {
   $rows = mysql_fetch_array($results);
   echo 'div' ;
   echo 'div class=fieldrow' ;
   echo '  ' ;
   echo '  label for=storenameStore 
 name:/label' ;
   echo '  ' ;
   echo '  input name=storename type=text 
 maxlength=35 id=storename
 class=regForm disabled=disabled value=$rows[0]/input' ;
   echo '/div' ;
 
 The value option in the textfield is not fetching the data, neither is it
 throwing errors. However the same code works perfectly as suggested by one
 of expert Nabble users:
 
 Nabble code:
 
 for($i=0;$imysql_num_rows($results);$i++)
   {
   $rows = mysql_fetch_array($results);
   echo(input name=\input1\ type=\text\ 
 value=$rows[0]);
   }
 
 Please help.
 
 Chris

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



[PHP-DB] Re: mysql statement [SOLVED]

2007-09-26 Thread Jas
Got if figured out, needed a sub-select type of query:

mysql  SELECT *
 - FROM ( SELECT * FROM `orders`
 - WHERE `group` = groupname )
 - AS orders UNION SELECT * FROM `orders`
 - WHERE `ordernum` LIKE 35132
 - OR `price` LIKE 35132
 - OR `partnum` LIKE 35132
 - OR `vendor` LIKE 35132
 - OR `purpose` LIKE 35132
 - OR `tracking` LIKE 35132
 - OR `contact` LIKE 35132
 - AND `group` LIKE 'mac'
 - ORDER BY `ordernum`
 - LIMIT 0 , 30;

Jas wrote:
 I am looking for some advice on how to achieve something and so far have
 been unable to do what I am looking to do.
 
 Here is the query I am using:
 mysql  SELECT *
 - FROM `orders`
 - WHERE `ordernum` LIKE 35132
 - OR `price` LIKE 35132
 - OR `partnum` LIKE 35132
 - OR `vendor` LIKE 35132
 - OR `purpose` LIKE 35132
 - OR `tracking` LIKE 35132
 - OR `contact` LIKE 35132
 - AND `group` LIKE 'mac'
 - ORDER BY `ordernum`
 - LIMIT 0 , 30;
 
 First here is the table structure:
 mysql describe orders;
 +-+--+--+-+-++
 | Field   | Type | Null | Key | Default | Extra  |
 +-+--+--+-+-++
 | id  | int(255) | NO   | PRI | | auto_increment |
 | ordernum| int(10)  | NO   | | ||
 | date| varchar(60)  | NO   | | ||
 | time| varchar(20)  | NO   | | ||
 | group   | varchar(20)  | NO   | | ||
 | quantity| int(10)  | NO   | | ||
 | description | varchar(255) | NO   | | ||
 | price   | decimal(3,0) | NO   | | ||
 | partnum | varchar(40)  | NO   | | ||
 | vendor  | varchar(65)  | NO   | | ||
 | purpose | varchar(255) | NO   | | ||
 | tracking| varchar(120) | NO   | | ||
 | contact | varchar(255) | NO   | | ||
 | eta | varchar(50)  | NO   | | ||
 | department  | varchar(125) | NO   | | ||
 | notes   | varchar(255) | NO   | | ||
 +-+--+--+-+-++
 16 rows in set (0.00 sec)
 
 I am trying to essentially LIMIT all records returned to be limited by
 the `group` field so I can search for records and limit the rows
 returned by that one field.
 
 Any tips? TIA.
 jas

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



Re: [PHP-DB] multiple fields all unique?

2004-02-04 Thread Jas
For this table to create 3 unique keys I did the following, in case it 
helps someone else out.
+--+--+--+-+-++
| Field| Type | Null | Key | Default | Extra  |
+--+--+--+-+-++
| id   | int(11)  |  | PRI | NULL| auto_increment |
| hostname | varchar(100) |  | | ||
| mac  | varchar(100) |  | | ||
| ip   | varchar(100) |  | | ||
| vlan | varchar(100) |  | | ||
+--+--+--+-+-++

UPDATE TABLE hosts ADD UNIQUE mac (mac);
UPDATE TABLE hosts ADD UNIQUE hostname (hostname);
UPDATE TABLE hosts ADD UNIQUE ip (ip);
+--+--+--+-+-++
| Field| Type | Null | Key | Default | Extra  |
+--+--+--+-+-++
| id   | int(11)  |  | PRI | NULL| auto_increment |
| hostname | varchar(100) |  | UNI | ||
| mac  | varchar(100) |  | UNI | ||
| ip   | varchar(100) |  | UNI | ||
| vlan | varchar(100) |  | | ||
+--+--+--+-+-++
Now I have used the following to check if duplicate records exist before 
updating:

?php
// Try and update with posted fields form html form
$update = mysql_query(UPDATE hosts SET hostname='$_POST[hostname]', 
mac='$_POST[mac]', ip='$_POST[ip]', vlan='$_POST[vlan]' WHERE 
id='$_SESSION[id]',$db);
$rows = mysql_affected_rows();

// Check results of operation
if($rows == 0) {
  echo No matching records found;
} else {
  echo Matching records found; }
Hope this helps anyone else, and thanks for the tip on MySQL's UNIQUE 
field, wish I would have known it sooner, I wouldn't be so pissed off 
from frustration.
Jas

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


Re: [PHP-DB] multiple fields all unique? [almost solved]

2004-02-04 Thread Jas
Jas wrote:

For this table to create 3 unique keys I did the following, in case it 
helps someone else out.
+--+--+--+-+-++
| Field| Type | Null | Key | Default | Extra  |
+--+--+--+-+-++
| id   | int(11)  |  | PRI | NULL| auto_increment |
| hostname | varchar(100) |  | | ||
| mac  | varchar(100) |  | | ||
| ip   | varchar(100) |  | | ||
| vlan | varchar(100) |  | | ||
+--+--+--+-+-++

UPDATE TABLE hosts ADD UNIQUE mac (mac);
UPDATE TABLE hosts ADD UNIQUE hostname (hostname);
UPDATE TABLE hosts ADD UNIQUE ip (ip);
+--+--+--+-+-++
| Field| Type | Null | Key | Default | Extra  |
+--+--+--+-+-++
| id   | int(11)  |  | PRI | NULL| auto_increment |
| hostname | varchar(100) |  | UNI | ||
| mac  | varchar(100) |  | UNI | ||
| ip   | varchar(100) |  | UNI | ||
| vlan | varchar(100) |  | | ||
+--+--+--+-+-++
Now I have used the following to check if duplicate records exist before 
updating:

?php
// Try and update with posted fields form html form
$update = mysql_query(UPDATE hosts SET hostname='$_POST[hostname]', 
mac='$_POST[mac]', ip='$_POST[ip]', vlan='$_POST[vlan]' WHERE 
id='$_SESSION[id]',$db);
$rows = mysql_affected_rows();

// Check results of operation
if($rows == 0) {
  echo No matching records found;
} else {
  echo Matching records found; }
Hope this helps anyone else, and thanks for the tip on MySQL's UNIQUE 
field, wish I would have known it sooner, I wouldn't be so pissed off 
from frustration.
Jas
Sorry, but now I have one more question about finding the exact field 
for a duplicate entry...

for instance, say you change the mac and hostname and there is a record 
in the database with the same mac string, how can I flag the field that 
matched from the 3?
Thanks,
jas

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


Re: [PHP-DB] multiple fields all unique? [almost solved]

2004-02-04 Thread Jas
If I do this statement:
mysql_query(UPDATE hosts SET hostname=\$_POST[hostname]\, 
mac=\$_POST[mac]\, ip=\$_POST[ip]\, vlan=\$_POST[vlan]\ WHERE 
id=\$_SESSION[id]\,$db)or die(mysql_error() . mysql_errno());

I get this error:
Duplicate entry '128.110.22.139' for key 41062
I have tried using these types of checks with no success:
$update = mysql_query(UPDATE hosts SET hostname=\$_POST[hostname]\, 
mac=\$_POST[mac]\, ip=\$_POST[ip]\, vlan=\$_POST[vlan]\ WHERE 
id=\$_SESSION[id]\,$db)or die(mysql_error() . mysql_errno());
$rows = mysql_affected_rows();
  while($match = mysql_fetch_assoc($update)) {
echo $match[hostname];
echo $match[mac];
echo $match[ip]; }
if($rows == 0) {
  echo update worked;
} else {
  echo update didn't work; }

And...
while($match = mysql_fetch_object($update)) {
And..
while($match = mysql_fetch_array($update)) {
So far everything I have tried will not allow me to find the exact field 
and contents of a record that matches an existing record in the 
database.  See below for details on database structure etc.
Any help is appreciated,
jas

Jas wrote:

Jas wrote:

For this table to create 3 unique keys I did the following, in case it 
helps someone else out.
+--+--+--+-+-++
| Field| Type | Null | Key | Default | Extra  |
+--+--+--+-+-++
| id   | int(11)  |  | PRI | NULL| auto_increment |
| hostname | varchar(100) |  | | ||
| mac  | varchar(100) |  | | ||
| ip   | varchar(100) |  | | ||
| vlan | varchar(100) |  | | ||
+--+--+--+-+-++

UPDATE TABLE hosts ADD UNIQUE mac (mac);
UPDATE TABLE hosts ADD UNIQUE hostname (hostname);
UPDATE TABLE hosts ADD UNIQUE ip (ip);
+--+--+--+-+-++
| Field| Type | Null | Key | Default | Extra  |
+--+--+--+-+-++
| id   | int(11)  |  | PRI | NULL| auto_increment |
| hostname | varchar(100) |  | UNI | ||
| mac  | varchar(100) |  | UNI | ||
| ip   | varchar(100) |  | UNI | ||
| vlan | varchar(100) |  | | ||
+--+--+--+-+-++
Now I have used the following to check if duplicate records exist 
before updating:

?php
// Try and update with posted fields form html form
$update = mysql_query(UPDATE hosts SET hostname='$_POST[hostname]', 
mac='$_POST[mac]', ip='$_POST[ip]', vlan='$_POST[vlan]' WHERE 
id='$_SESSION[id]',$db);
$rows = mysql_affected_rows();

// Check results of operation
if($rows == 0) {
  echo No matching records found;
} else {
  echo Matching records found; }
Hope this helps anyone else, and thanks for the tip on MySQL's UNIQUE 
field, wish I would have known it sooner, I wouldn't be so pissed off 
from frustration.
Jas
Sorry, but now I have one more question about finding the exact field 
for a duplicate entry...

for instance, say you change the mac and hostname and there is a record 
in the database with the same mac string, how can I flag the field that 
matched from the 3?
Thanks,
jas
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] multiple fields all unique? [almost solved]

2004-02-04 Thread Jas
John W. Holmes wrote:
[snip]
When you update the table with an existing mac value, the error will be
similar to Duplicate value for Key XX where XX is what key was duplicated.
I can't remember if the keys start at zero or one, but your ID column will
be the first key, then mac, hostname, and finally ip (in the order they were
created).
So, if you examine the result of mysql_error() and it say duplicate for key
2, then the mac column was duplicated.
Although this sounds a little harder than doing a SELECT prior to and just
comparing values, it lets you do this with just a single query and only have
extra processing upon errors instead of every single update.
[/snip]

Your right, I am able to see which record matches (not the record I am 
updating) I think you just answered my question by stating that

 Although this sounds a little harder than doing a SELECT prior to and 
 just
 comparing values, it lets you do this with just a single query and
 only have
 extra processing upon errors instead of every single update.

I suppose that is what I am going to have to do before doing the update. 
 If you know of a different method please elaborate.
thanks again,
Jas

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


Re: [PHP-DB] multiple fields all unique? [almost solved]

2004-02-04 Thread Jas
[snip]
You're not going to be able to fetch anything from the result set because
you're excuting an UPDATE query, not a SELECT.
You also do not want to die() when the query fails, otherwise you won't be
able to react to the error. Execute the query, then check mysql_error() for
a value. If it contains a value, then the query failed more than likely
because of a duplicate key.
[snip]

Well looks like I need to brush up on my php - mysql functions.  =)
For anyone that has been following this thread here is a simple way to 
catch the duplicate and show the user the contents:

?php
$update = mysql_query(UPDATE hosts SET hostname=\$_POST[hostname]\, 
mac=\$_POST[mac]\, ip=\$_POST[ip]\, vlan=\$_POST[vlan]\ WHERE 
id=\$_SESSION[id]\,$db);
$rows = mysql_affected_rows();
 if([EMAIL PROTECTED]($update)) {
  echo No match found;
 } else {
  echo Match found;
  $error = preg_match(/^[']$/,mysql_errno($update));
  $sql = mysql_query(select * from hosts where id = $error)
while($x = mysql_fetch_array($sql)) {
  list($id,$host,$mac,$ip,$vlan) = $x; }
 }
?

Might want to check the preg_match string to look for everything between 
 ' and ' but other than that you should be able to list the record that 
your update statement is having a problem with.
HTH
Jas

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


[PHP-DB] multiple fields all unique?

2004-02-03 Thread Jas
I am running into a problem and I have yet to find an elegant solution 
for it.

I have three fields in a database that cannot have duplicates of these 
particular fields.

+--+---++
| hostname | mac   | ip |
+--+---++
| pmac-1   | 00:30:65:6c:ea:cc | 128.110.22.15  |
+--+---++
| pmac-2   | 00:30:65:6c:e0:cc | 128.110.22.16  |
+--+---++
Now I have a simple form that opens up a record and allows users to 
modify 2 of the 3 fields, mac  ip.

In order for the user to save the record and overwrite the current 
contents of the database I first need to do a check to see if any of the 
2 fields being updated match an existing record.

For example say the user modifies the ip field from 128.110.22.15 to 
128.110.22.16, because there is an entry that matches that change the 
record does not update, or vice versa for the mac fields.

Has anyone every performed such a feat as to check for matching fields 
before updating?  And if so could you show me some code that used to 
accomplish this.  I have written my own but the if - else statements are 
getting ridiculous.

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


Re: [PHP-DB] multiple fields all unique?

2004-02-03 Thread Jas
John W. Holmes wrote:
From: Jason Gerfen [EMAIL PROTECTED]

Yeah, I have never used a unique field for the database, and you are 
right it is a mysql db.


Now is a good time to do it the right way, then...

---John Holmes...
Yes definately, I am trying to convert my exisiting fields to a unique 
type and am having no luck what-so-ever.  This is the table format:
+--+--+--+-+-++
| Field| Type | Null | Key | Default | Extra  |
+--+--+--+-+-++
| id   | int(11)  |  | PRI | NULL| auto_increment |
| hostname | varchar(100) |  | | ||
| mac  | varchar(100) |  | | ||
| ip   | varchar(100) |  | | ||
| vlan | varchar(100) |  | | ||
+--+--+--+-+-++
5 rows in set (0.00 sec)
and this is the command I am tying to run to modify the hostname, mac  
ip fields to unique.

alter hosts add unique mac;
etc.
I have such a hard time with mysql's manual.
Jas
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] Checking for duplicate records before update?

2003-12-30 Thread Jas
Problem. I have a database table that looks like this:
eg.
+--+--+---+---+-+
| id   | hostname | mac   | ip| vlan|
+--+--+---+---+-+
| 1014 | MTPC-01  | 00:02:B3:A2:9D:ED | 155.97.15.11  | Vlan-29 |
| 1015 | MTPC-02  | 00:02:B3:A2:B6:F4 | 155.97.15.12  | Vlan-29 |
This table will hold a very large number of entries, all unique.  I have 
created a simple HTML form which updates the entries but before it does 
it checks to see if records already exist that contain either the same 
IP value, the same MAC value or the same Hostname value.  If any of 
these items exist it currently discards the posted informaiton and 
prompts the user to re-enter because I cannot have duplicate entries of 
either the hostname, mac, ip fields.

Here is my function:
eg.
$x = mysql_query(SELECT * FROM $table WHERE hostname = 
'$_POST[hostname]' OR ip = '$_POST[ip]' OR mac = '$_POST[mac]' NOT id = 
'$_SESSION[id01]')or die(mysql_error());
$num = mysql_num_rows($x);
  if($num == 0) {	
unset($_SESSION['search']);
require 'dbase.inc.php';
$table = hosts;
$sql = @mysql_query(UPDATE $table SET hostname = 
\$_POST[hostname]\, mac = \$_POST[mac]\, ip = \$_POST[ip]\, vlan = 
\$_POST[vlan]\ WHERE id = \$_SESSION[id01]\)or die(mysql_error());
echo Form worked!;
} elseif ($num != 0) {
  unset($_SESSION['search']);
  echo Form didn't work because 1 of the 3 fields were present in 
another record!!! Please try again.;
} else {
  echo RTM again please!; }

I think what I really need to know is if there is a quick way to sort 
through the results of the current database records and do comparisons 
against the form.  If any one has done something like this before could 
you please show me an example or point me to a good resource.  Thanks in 
advance.
Jas

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


[PHP-DB] sql errors?

2003-12-15 Thread Jas
I have checked and rechecked my code on these php to mysql statements 
and for some reason I either get no data (through php, where through a 
command line I get all the data I need) or errors on the update 
function.  Could someone tell me what I am doing wrong?

$sql = mysql_query(SELECT hostname FROM $table WHERE vlan = 
$_POST[dhcp_hosts],$db)or die(mysql_error());

from the command line
SELECT hostname FROM hosts WHERE vlan = 'Vlan-22';
And I get results... I don't get it.

And for the update statement I am having problems with...
$sql_global = mysql_query(UPDATE $tble SET dn = '$_POST[dn]' SET lt = 
'$_POST[lt]' SET mlt = '$_POST[mlt]' SET msc01 = '$_POST[msc01]' SET 
msc02 = '$_POST[msc02]' SET msc03 = '$_POST[msc03]' SET msc04 = 
'$_POST[msc04]' WHERE id = '1',$db)or die(mysql_error());

If you echo the posted vars they are all present and the same statement 
works in other places of the script and from the command line.

Any help is appreciated.
Jas
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] form not working...

2003-11-10 Thread jas
For some reason my form to edit selected items is not working, I think I
need a new set of eyes.
Any help is appreciated...
Jas

// inc.php
function db_retrieve() {
 require 'dbase.inc.php';
 $tble = $_SESSION['table'];
 $show = @mysql_query(SELECT * FROM $tble LIMIT 0, 15,$db)or
die(mysql_error());
   while ($row = @mysql_fetch_array($show)) {
@list($nItemSKU, $bActive, $nUserID, $nItemConfig, $tItemType,
$tDepartment, $blSerialNumber, $nPropertyNumber, $blHostName, $nIPID,
$tRoomNumber, $tNotes) = $row;
 $_SESSION['table'] .= tr class=fntMAINtd valign=top
align=left$nItemSKU/td
 td valign=top align=left$bActive/td
 td valign=top align=left$nUserID/td
 td valign=top align=left$nItemConfig/td
 td valign=top align=left$tItemType/td
 td valign=top align=left$tDepartment/td
 td valign=top align=left$blSerialNumber/td
 td valign=top align=left$nPropertyNumber/td
 td valign=top align=left$blHostName/td
 td valign=top align=left$nIPID/td
 td valign=top align=left$tRoomNumber/td
 td valign=top align=left$tNotes/td
 td valign=top align=leftinput name=edit type=checkbox
value=$blSerialNumber/td
/tr; }
 $_SESSION['number'] = mysql_num_rows($show); }

?php
session_start();
require 'scripts/inc.php';
if ((!isset($_POST['edit'])) or ($_POST = )) {
 $_SESSION['table'] = t_items;
 call_user_func(db_retrieve);
} elseif ((isset($_POST['edit'])) or (!$_POST = )) {
 require 'scripts/dbase.inc.php';
  $tble = $_SESSION['table'];
  $edt = mysql_query(SELECT * FROM $tble WHERE
blSerialNumber=\$edit\,$db)or die(mysql_error());
   while ($row = mysql_fetch_array($edt)) {
list($nItemSKU, $bActive, $nUserID, $nItemConfig, $tItemType,
$tDepartment, $blSerialNumber, $nPropertyNumber, $blHostName, $nIPID,
$tRoomNumber, $tNotes) = $row;
$_SESSION['table'] .= tr class=fntMAIN
   td valign=top align=leftinput name=nItemSKU type=text size=30
value=$nItemSKU/td
   td valign=top align=leftinput name=bActive type=text size=30
value=$bActive$bActive/td
   td valign=top align=leftinput name=nUserID type=text size=30
value=$nUserID$nUserID/td
   td valign=top align=leftinput name=nItemConfig type=text
size=30 value=$nItemConfig$nItemConfig/td
   td valign=top align=leftinput name=tItemType type=text size=30
value=$tItemType$tItemType/td
   td valign=top align=leftinput name=tDepartment type=text
size=30 value=$tDepartment$tDepartment/td
   td valign=top align=leftinput name=blSerialNumber type=text
size=30 value=$blSerialNumber$blSerialNumber/td
   td valign=top align=leftinput name=nPropertyNumber type=text
size=30 value=$nPropertyNumber$nPropertyNumber/td
   td valign=top align=leftinput name=blHostName type=text
size=30 value=$blHostName$blHostName/td
   td valign=top align=leftinput name=nIPID type=text size=30
value=$nIPID$nIPID/td
   td valign=top align=leftinput name=tRoomNumber type=text
size=30 value=$tRoomNumber$tRoomNumber/td
   td valign=top align=leftinput name=tNotes type=text size=30
value=$tNotes$tNotes/td
   td valign=top align=leftinput name=save type=button value=Save
class=frmBTNS/td
  /tr; }
}
?
form action=?php echo $_SERVER['PHP_SELF']; ? method=post
?php echo $_SESSION['table']; ?
input name=edit type=button value=edit selected items
class=frmBTNS
/form

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



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

2003-11-10 Thread jas
Yeah, sorry that code wasn't updated... after the $_session['table'] is
called the input button doesn't attempt to post the data form the
$_session['table'] if that makes sense... all the error checking isn't the
problem
jas

Jeffrey N Dyke [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 i'd be curious what your actual problem is?

 here's a question though.,...would these ever work?.
 snip
 if ((!isset($_POST['edit'])) or ($_POST = )) {
  $_SESSION['table'] = t_items;
  call_user_func(db_retrieve);
 } elseif ((isset($_POST['edit'])) or (!$_POST = )) {
 /snip

 You're basically setting a superglobal array equal to an empty string -
  .  this should at least be $_POST == ...but
 instead, i'd use
 if ((!isset($_POST['edit'])) or (empty($_POST)) {
 --and --
 } elseif ((isset($_POST['edit'])) or (!empty($_POST))) {

 hth
 jeff




   jas
   [EMAIL PROTECTED]To:
[EMAIL PROTECTED]
   .comcc:
Subject:  [PHP-DB] form not
working...
   11/10/2003 12:38
   PM






 For some reason my form to edit selected items is not working, I think I
 need a new set of eyes.
 Any help is appreciated...
 Jas

 // inc.php
 function db_retrieve() {
  require 'dbase.inc.php';
  $tble = $_SESSION['table'];
  $show = @mysql_query(SELECT * FROM $tble LIMIT 0, 15,$db)or
 die(mysql_error());
while ($row = @mysql_fetch_array($show)) {
 @list($nItemSKU, $bActive, $nUserID, $nItemConfig, $tItemType,
 $tDepartment, $blSerialNumber, $nPropertyNumber, $blHostName, $nIPID,
 $tRoomNumber, $tNotes) = $row;
  $_SESSION['table'] .= tr class=fntMAINtd valign=top
 align=left$nItemSKU/td
  td valign=top align=left$bActive/td
  td valign=top align=left$nUserID/td
  td valign=top align=left$nItemConfig/td
  td valign=top align=left$tItemType/td
  td valign=top align=left$tDepartment/td
  td valign=top align=left$blSerialNumber/td
  td valign=top align=left$nPropertyNumber/td
  td valign=top align=left$blHostName/td
  td valign=top align=left$nIPID/td
  td valign=top align=left$tRoomNumber/td
  td valign=top align=left$tNotes/td
  td valign=top align=leftinput name=edit type=checkbox
 value=$blSerialNumber/td
 /tr; }
  $_SESSION['number'] = mysql_num_rows($show); }

 ?php
 session_start();
 require 'scripts/inc.php';
 if ((!isset($_POST['edit'])) or ($_POST = )) {
  $_SESSION['table'] = t_items;
  call_user_func(db_retrieve);
 } elseif ((isset($_POST['edit'])) or (!$_POST = )) {
  require 'scripts/dbase.inc.php';
   $tble = $_SESSION['table'];
   $edt = mysql_query(SELECT * FROM $tble WHERE
 blSerialNumber=\$edit\,$db)or die(mysql_error());
while ($row = mysql_fetch_array($edt)) {
 list($nItemSKU, $bActive, $nUserID, $nItemConfig, $tItemType,
 $tDepartment, $blSerialNumber, $nPropertyNumber, $blHostName, $nIPID,
 $tRoomNumber, $tNotes) = $row;
 $_SESSION['table'] .= tr class=fntMAIN
td valign=top align=leftinput name=nItemSKU type=text
size=30
 value=$nItemSKU/td
td valign=top align=leftinput name=bActive type=text size=30
 value=$bActive$bActive/td
td valign=top align=leftinput name=nUserID type=text size=30
 value=$nUserID$nUserID/td
td valign=top align=leftinput name=nItemConfig type=text
 size=30 value=$nItemConfig$nItemConfig/td
td valign=top align=leftinput name=tItemType type=text
size=30
 value=$tItemType$tItemType/td
td valign=top align=leftinput name=tDepartment type=text
 size=30 value=$tDepartment$tDepartment/td
td valign=top align=leftinput name=blSerialNumber type=text
 size=30 value=$blSerialNumber$blSerialNumber/td
td valign=top align=leftinput name=nPropertyNumber type=text
 size=30 value=$nPropertyNumber$nPropertyNumber/td
td valign=top align=leftinput name=blHostName type=text
 size=30 value=$blHostName$blHostName/td
td valign=top align=leftinput name=nIPID type=text size=30
 value=$nIPID$nIPID/td
td valign=top align=leftinput name=tRoomNumber type=text
 size=30 value=$tRoomNumber$tRoomNumber/td
td valign=top align=leftinput name=tNotes type=text size=30
 value=$tNotes$tNotes/td
td valign=top align=leftinput name=save type=button
value=Save
 class=frmBTNS/td
   /tr; }
 }
 ?
 form action=?php echo $_SERVER['PHP_SELF']; ? method=post
 ?php echo $_SESSION['table']; ?
 input name=edit type=button value=edit selected items
 class=frmBTNS
 /form

 --
 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] Add items to field using update?

2002-09-22 Thread Jas

Not sure how to do this but I have a table which looks like:
CREATE TABLE cm_sessions (
  session varchar(255) NOT NULL default '',
  ipaddy varchar(30) NOT NULL default '',
  host varchar(255) NOT NULL default '',
  pages longtext NOT NULL,
  referrer varchar(255) NOT NULL default '',
  hck varchar(15) NOT NULL default '',
  nrml varchar(15) NOT NULL default '',
  hour varchar(15) NOT NULL default '',
  date_stamp varchar(255) NOT NULL default '',
  PRIMARY KEY  (session),
  UNIQUE KEY session (session)
) TYPE=MyISAM;

Now everytime a new page is reached I want to update only the 'pages' field,
here is the current sql statement that overwrites the contents of the
'pages' field.

UPDATE $table SET pages = '.$PHP_SELF.' WHERE session = '$holy_cow'

any help on this would be great.
Jas



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




[PHP-DB] SQL update help

2002-09-20 Thread Jas

Here is my statement
UPDATE $table SET pages = $PHP_SELF WHERE session = $holy_cow
However it will not update I recieve this error:
You have an error in your SQL syntax near '/admin/login.done.php WHERE
session = 5d44389bd70881131b9ea7573eba34d4' at line 1
Any help would be appreciated
Jas



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




[PHP-DB] Whats the best way to update...

2002-08-01 Thread Jas

I need to know the best way to update a record based on something like the
session id being the same, except the other fields are not.  Any examples of
this would help...

$table = cm_sessions;
 $sql_insert_form = INSERT INTO $table
(session,ipaddy,host,referrer,hck,nrml,hour,date_stamp) VALUES
('$holy_cow','$ipaddy','$host','$domain_b','$hck','-','$hour','$date');
 $result = mysql_query($sql_insert_form,$dbh) or die(MYSQL_ERROR());

or

$sql_insert = UPDATE $table WHERE session = $HTTP_SESSION_VARS['session']
or if the session vars are the same it would insert a new row?  I hope I am
asking the question correctly.  Any help, examples would be great!
TIA
Jas



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




[PHP-DB] Re: Benefits of assigning query to variable

2002-07-31 Thread Jas

sure there are, you can call the query in multiple places, for example:

$sql = mysql_query(INSERT INTO $table_name WHERE db_field =
$search_string);

Then say you have a routine to check for missing for elements and you would
like to log failed vs. successfull attempts your code flow would be
something like:

if (!$search_string  !$var02) {
$sql;
} else {
$sql; }
HTH
Jas

Brian Graham [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Are there any benefits to assigning a query to a variable?





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




[PHP-DB] Column count error?

2002-07-26 Thread Jas

I am not sure how to resolve this type of error, any help is appreciated.
TIA
Jas

/* Error message */
Column count doesn't match value count at row 1

/* Code to query db for username and password */
require '/home/bignickel.net/scripts/admin/db.php';
 $db_table = 'auth_users';
 $sql = SELECT * from $db_table WHERE un = \$u_name\ AND pw =
password(\$p_word\);
 $result = @mysql_query($sql,$dbh) or die('Cannot execute query, please try
again later or contact the system administrator by email at
[EMAIL PROTECTED]');
  /* Loop through records for matching pair */
  $num = mysql_numrows($result);
   if ($num !=0) {
print You have a valid username and password combination;
  } else {
header(Location: blank.php); }

/* Table structure of db */
CREATE TABLE auth_users (
 user_id int(11) NOT NULL auto_increment,
   f_name varchar(255) default NULL,
   l_name varchar(255) default NULL,
   email_addy varchar(255) default NULL,
   un text,
   pw text,
   PRIMARY KEY  (user_id)
 ) TYPE=MyISAM;






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




[PHP-DB] Re: Not sure what I am doing wrong here?

2002-07-23 Thread Jas

No kidding huh?  Thanks a ton.

David Robley [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 In article [EMAIL PROTECTED], [EMAIL PROTECTED]
 says...
  Ok, now I am not sure why I cannot get this output into a variable so I
can
  place it into a database table field.  Any help would be greatly
  appreciated.
  ?php
 
  /* Check client info and register */
  if (getenv(HTTP_X_FORWARDED_FOR)){
   $ipaddy = getenv(HTTP_X_FORWARDED_FOR);
  } else {
   $ipaddy = getenv(REMOTE_ADDR);
   $host = gethostbyaddr($REMOTE_ADDR); }
 
  /* Start looking up users IP vs. WHOIS database for logging */
  $nipaddy = ;
  function message($msg){
  echo $msg;
  flush();
  }
  function arin($ipaddy){
  $server = whois.arin.net;
  if (!$ipaddy = gethostbyname($ipaddy))
$msg .= Can't IP Whois without an IP address.;
  else{
if (! $sock = fsockopen($server, 43, $num, $error, 20)){
  unset($sock);
  $msg .= Timed-out connecting to $server (port 43);
  }
else{
  fputs($sock, $ipaddy\n);
  while (!feof($sock))
$buffer .= fgets($sock, 10240);
  fclose($sock);
  }
 if (eregi(RIPE.NET, $buffer))
   $nextServer = whois.ripe.net;
 else if (eregi(whois.apnic.net, $buffer))
   $nextServer = whois.apnic.net;
 else if (eregi(nic.ad.jp, $buffer)){
   $nextServer = whois.nic.ad.jp;
   #/e suppresses Japanese character output from JPNIC
   $extra = /e;
   }
 else if (eregi(whois.registro.br, $buffer))
   $nextServer = whois.registro.br;
 if($nextServer){
   $buffer = ;
   message(Deferred to specific whois server:
$nextServer...brbr);
   if(! $sock = fsockopen($nextServer, 43, $num, $error, 10)){
 unset($sock);
 $msg .= Timed-out connecting to $nextServer (port 43);

 Hmm, seems your message is too long for my newsreader to include the lot.
 However, it seems that you may not be returning a value from the function
 arin(), so whan you do

 /* Place results into a var */
 $whois = arin($ipaddy); // Right now if this is here it will show in two
 areas of the screen

 natuarally nothing is placed in $whois.

 Cheers
 --
 David Robley
 Temporary Kiwi!

 Quod subigo farinam




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




[PHP-DB] Not sure what I am doing wrong here?

2002-07-22 Thread Jas

Ok, now I am not sure why I cannot get this output into a variable so I can
place it into a database table field.  Any help would be greatly
appreciated.
?php

/* Check client info and register */
if (getenv(HTTP_X_FORWARDED_FOR)){
 $ipaddy = getenv(HTTP_X_FORWARDED_FOR);
} else {
 $ipaddy = getenv(REMOTE_ADDR);
 $host = gethostbyaddr($REMOTE_ADDR); }

/* Start looking up users IP vs. WHOIS database for logging */
$nipaddy = ;
function message($msg){
echo $msg;
flush();
}
function arin($ipaddy){
$server = whois.arin.net;
if (!$ipaddy = gethostbyname($ipaddy))
  $msg .= Can't IP Whois without an IP address.;
else{
  if (! $sock = fsockopen($server, 43, $num, $error, 20)){
unset($sock);
$msg .= Timed-out connecting to $server (port 43);
}
  else{
fputs($sock, $ipaddy\n);
while (!feof($sock))
  $buffer .= fgets($sock, 10240);
fclose($sock);
}
   if (eregi(RIPE.NET, $buffer))
 $nextServer = whois.ripe.net;
   else if (eregi(whois.apnic.net, $buffer))
 $nextServer = whois.apnic.net;
   else if (eregi(nic.ad.jp, $buffer)){
 $nextServer = whois.nic.ad.jp;
 #/e suppresses Japanese character output from JPNIC
 $extra = /e;
 }
   else if (eregi(whois.registro.br, $buffer))
 $nextServer = whois.registro.br;
   if($nextServer){
 $buffer = ;
 message(Deferred to specific whois server: $nextServer...brbr);
 if(! $sock = fsockopen($nextServer, 43, $num, $error, 10)){
   unset($sock);
   $msg .= Timed-out connecting to $nextServer (port 43);
   }
 else{
   fputs($sock, $ipaddy$extra\n);
   while (!feof($sock))
 $buffer .= fgets($sock, 10240);
   fclose($sock);
   }
 }
  $buffer = str_replace( , nbsp;, $buffer);
  $msg .= nl2br($buffer);
  }
message($msg);
}
/* Place results into a var */
$whois = arin($ipaddy); // Right now if this is here it will show in two
areas of the screen

/* Start putting the data into the database table */
$table = sessions;
 $sql_insert = INSERT INTO $table (ipaddy,whois) VALUES
('$ipaddy','$whois');
 $result = mysql_query($sql_insert,$dbh) or die(MYSQL_ERROR()); // No error
but what gets entered for the var $whois is arin(66.56.34.32)
?
?php echo $ipaddy; ?
?php echo arin($ipaddy; ? // These results should be placed in $whois
which is empty
?php echo $whois; ? // This returns arin(65.44.33.23) which is wrong
Any help on this would be appreciated!
Jas



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




[PHP-DB] never seen this before..

2002-06-24 Thread Jas

I am getting an error when inserting data into a mysql database table.  It
is telling me that there is a duplicate entry in the database everytime it
gets 10 records inserted to the table, if I flush the table and try it again
it works fine.  Is there some kind of limit on some tables?  Here is the
error php outputs once the table gets 10 records: Duplicate entry '10' for
key 1
Here is the code...
require '/home/web/b/bignickel.net/scripts/admin/db.php';
 $table = demo_sessions;
 $sql_insert = INSERT INTO $table (ipaddy,date) VALUES
('$ipaddy','$date') or die('Could not insert client info');
 $result = mysql_query($sql_insert,$dbh) or die(MYSQL_ERROR());

Any help on this would be great
TIA
Jas



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




[PHP-DB] Re: never seen this before..

2002-06-24 Thread Jas

Here is the db table structure...
CREATE TABLE demo_sessions (
   id varchar(255) NOT NULL auto_increment,
   ipaddy varchar(255) NOT NULL,
   date varchar(255) NOT NULL,
   PRIMARY KEY (id)
);
Let me know if this is correct, I have a feeling that the varchar is my
problem but I could be wrong.
TIA
Jas

[EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 TIA --


 column in your table denotes your primary key? After that, how is it
 incremented? Is it auto or do you have some other form of it.  I think
 your code is correct so the error seems to be how the data ID is
generated.

 gl -- Seth

 Jas wrote:

  I am getting an error when inserting data into a mysql database table.
It
  is telling me that there is a duplicate entry in the database everytime
it
  gets 10 records inserted to the table, if I flush the table and try it
again
  it works fine.  Is there some kind of limit on some tables?  Here is the
  error php outputs once the table gets 10 records: Duplicate entry '10'
for
  key 1
  Here is the code...
  require '/home/web/b/bignickel.net/scripts/admin/db.php';
   $table = demo_sessions;
   $sql_insert = INSERT INTO $table (ipaddy,date) VALUES
  ('$ipaddy','$date') or die('Could not insert client info');
   $result = @mysql_query($sql_insert,$dbh) or die(MYSQL_ERROR());
 
  Any help on this would be great
  TIA
  Jas
 
 
 




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




[PHP-DB] resource id#2 - ????

2002-06-12 Thread Jas

Not sure how to over come this,  the result of a database query keeps giving
me this:
?php
/* Get Ip address, where they came from, and stamp the time */
if (getenv(HTTP_X_FORWARDED_FOR)){
$ipaddy = getenv(HTTP_X_FORWARDED_FOR);
} else {
$ipaddy = getenv(REMOTE_ADDR); }

$referrer = $HTTP_REFERER;
$date_stamp = date(Y-m-d H:i:s);

/* Start session, and check registered variables */
session_start();
if (isset($HTTP_SESSION_VARS['ipaddy']) ||
isset($HTTP_SESSION_VARS['referrer']) ||
isset($HTTP_SESSION_VARS['date_stamp'])) {
 $main = Video clips stored in Database;

/* Insert client info to database table */
 require('/path/to/connection/class/con.inc');
  $table_sessions = dev_sessions;
  $sql_insert = INSERT INTO $table_sessions
(ipaddy,referrer,date_stamp) VALUES ('$ipaddy','$referrer','$date_stamp');
  $result = mysql_query($sql_insert,$dbh) or die(Couldn't execute
insert to database!);

/* Pull video info from database table into an array */
  $table_content = dev_videos;
  $sql_content = mysql_query(SELECT * FROM $table_content,$dbh);
 while ($row = mysql_fetch_array($record)) {
$id = $row['id'];
$file_name = $row['file_name'];
$file_size = $row['file_size'];
$file_properties = $row['file_properties'];
$file_codec = $row['file_codec'];
$file_author = $row['file_author'];
 $result = mysql_query($sql_content,$dbh) or die(Couldn't execute
query on database!);

/* loop through records and print results of array into table */
  $current .=
trtd$id/tdtd$file_name/tdtd$file_size/tdtd$file_properties
/tdtd$file_codec/tdtd$file_author/td/tr; }
  } else {
  /* Start a new session and register variables */
  session_start();
  session_register('ipaddy');
  session_register('referrer');
  session_register('date_stamp'); }
?
Just to make sure everything is working correctly I have echoed every
statement to the screen so I may see what's going on like so:
?php echo $main; ?
table width=75% border=1
?php echo $current; ? // my results should be here but instead I get
Resource ID #2 printed wtf?
/tablebr
?php echo $ipaddy; ?br
?php echo $referrer; ?br
?php echo $date_stamp; ?br
?php echo $sql_insert; ?br
?php echo $sql_content; ?br
?php echo $id; ?br
?php echo $file_name; ?br
?php echo $file_size; ?br

Any help would be great!
Jas



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




Re: [PHP-DB] resource id#2 - ????

2002-06-12 Thread Jas

Thanks a ton, I was really looking right past that variable.
Jas

Paul Dubois [EMAIL PROTECTED] wrote in message
news:p05111763b92d3addd3b4@[192.168.0.33]...
 At 11:42 -0600 6/12/02, Jas wrote:
 Not sure how to over come this,  the result of a database query keeps
giving
 me this:
 ?php
 /* Get Ip address, where they came from, and stamp the time */
 if (getenv(HTTP_X_FORWARDED_FOR)){
  $ipaddy = getenv(HTTP_X_FORWARDED_FOR);
 } else {
  $ipaddy = getenv(REMOTE_ADDR); }
 
 $referrer = $HTTP_REFERER;
 $date_stamp = date(Y-m-d H:i:s);
 
 /* Start session, and check registered variables */
 session_start();
 if (isset($HTTP_SESSION_VARS['ipaddy']) ||
 isset($HTTP_SESSION_VARS['referrer']) ||
 isset($HTTP_SESSION_VARS['date_stamp'])) {
   $main = Video clips stored in Database;
 
 /* Insert client info to database table */
   require('/path/to/connection/class/con.inc');
$table_sessions = dev_sessions;
$sql_insert = INSERT INTO $table_sessions
 (ipaddy,referrer,date_stamp) VALUES
('$ipaddy','$referrer','$date_stamp');
$result = @mysql_query($sql_insert,$dbh) or die(Couldn't execute
 insert to database!);
 
 /* Pull video info from database table into an array */
$table_content = dev_videos;
$sql_content = @mysql_query(SELECT * FROM $table_content,$dbh);
   while ($row = @mysql_fetch_array($record)) {

 $record isn't defined anywhere.  Do you mean $sql_content?

  $id = $row['id'];
  $file_name = $row['file_name'];
  $file_size = $row['file_size'];
  $file_properties = $row['file_properties'];
  $file_codec = $row['file_codec'];
  $file_author = $row['file_author'];
   $result = @mysql_query($sql_content,$dbh) or die(Couldn't execute
 query on database!);
 
 /* loop through records and print results of array into table */
$current .=

trtd$id/tdtd$file_name/tdtd$file_size/tdtd$file_properties

 /tdtd$file_codec/tdtd$file_author/td/tr; }
} else {
/* Start a new session and register variables */
session_start();
session_register('ipaddy');
session_register('referrer');
session_register('date_stamp'); }
 ?
 Just to make sure everything is working correctly I have echoed every
 statement to the screen so I may see what's going on like so:
 ?php echo $main; ?
 table width=75% border=1
 ?php echo $current; ? // my results should be here but instead I get
 Resource ID #2 printed wtf?
 /tablebr
 ?php echo $ipaddy; ?br
 ?php echo $referrer; ?br
 ?php echo $date_stamp; ?br
 ?php echo $sql_insert; ?br
 ?php echo $sql_content; ?br
 ?php echo $id; ?br
 ?php echo $file_name; ?br
 ?php echo $file_size; ?br
 
 Any help would be great!
 Jas
 
 
 
 --
 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] new pair of eyes

2002-05-31 Thread Jas

I think I am missing something:
$db_name = database;
 $table_name = auth_users;
 $sql = DELETE user_id, f_name, l_name, email_addy, un, pw FROM $table_name
WHERE user_id = \$user_id\, $dbh;
 $result = mysql_query($sql, $dbh) or die (Could not execute query.
Please try again later.);
Its not deleting the records based on a hidden field in a form named
$user_id
Any help would be great!
Jas



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




[PHP-DB] Re: new pair of eyes

2002-05-31 Thread Jas

Sorry, got it working, just needed to remove user_id, f_name etc. and it
works fine.

Jas [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I think I am missing something:
 $db_name = database;
  $table_name = auth_users;
  $sql = DELETE user_id, f_name, l_name, email_addy, un, pw FROM
$table_name
 WHERE user_id = \$user_id\, $dbh;
  $result = @mysql_query($sql, $dbh) or die (Could not execute query.
 Please try again later.);
 Its not deleting the records based on a hidden field in a form named
 $user_id
 Any help would be great!
 Jas





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




[PHP-DB] how to pull array out?

2002-05-30 Thread Jas

Not sure how to do this, but I need to pull the contents of an array into
editable text fields...  As of yet I have not found a way to accomplish
this:

$table = auth_users;
 $record = @mysql_query(SELECT * FROM $table WHERE user_id =
'$user_id',$dbh);
   while ($row = mysql_fetch_row($record)) {
$user_id = $row['user_id'];
$f_name = $row['f_name'];
$l_name = $row['l_name'];
$email_addy = $row['email_addy'];
$un = $row['un'];
$pw = $row['pw']; }
$var_form .= table width=\100%\ border=\0\ cellpadding=\7\form
name=\$user_id\ method=\post\ action=\del_account.php\
  trtd width=\20%\ colspan=\2\bEdit Account
$user_id/b/td/tr
trtd width=\20%\First Name:/tdtd width=\80%\input
type=\text\ name=\f_name\ size=\30\ maxlength=\30\
value=\$f_name\font class=\copyright\i.e. John/font/td/tr
trtd width=\20%\Last Name:/tdtd width=\80%\input
type=\text\ name=\l_name\ size=\30\ maxlength=\30\
value=\$l_name\font class=\copyright\i.e. Doe/font/td/tr
  trtd width=\20%\Email:/tdtd width=\80%\input
type=\text\ name=\email_addy\ size=\30\ maxlength=\30\
value=\$email_addy\font class=\copyright\i.e.
[EMAIL PROTECTED]/font/td/tr
trtd width=\20%\User Name:/tdtd width=\80%\input
type=\text\ name=\un\ size=\30\ maxlength=\30\ value=\$un\font
class=\copyright\i.e. j-doe/font/td/tr
trtd width=\20%\Password:/tdtd width=\80%\input
type=\password\ name=\pw\ size=\30\ maxlength=\30\font
class=\copyright\(password must be alpha-numeric, i.e.
pAs5w0rd)/font/td/tr
trtd width=\20%\Confirm Password:/tdtd
width=\80%\input type=\password\ name=\pw\ size=\30\
maxlength=\30\font class=\copyright\please confirm password
entered/font/td/tr
trtd width=\20%\nbsp;/tdtd width=\80%\input
type=\submit\ name=\add\ value=\edit user\nbsp;nbsp;input
type=\reset\ name=\reset\ value=\reset\/td/tr
   /form/table;
echo $record;

It only echoes the resource id, any help or examples would be great
Jas



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




Re: [PHP-DB] how to pull array out?

2002-05-30 Thread Jas

Mr. Wong,
You are no help.  As you can probably see I am NOT an experienced php
developer!!  Posting to this list, reading the manual, and scouring sites
for tutorials is all I have to provide me with a way to maybe begin doing
writting php apps.  I did read your reply about feeding the results into an
array  however I have not been able to accomplish what I have set out to
do.  A GOOD EXPLANATION IS ALL WE NEED!!! You posting stuff on how we should
read the manual does not suffice!  People post to this newsgroup to get
answers to problems they cannot figure out.  I am sure you have been working
with php enough to know how to accomplish anything you need, and for the
rest of us we rely on examples, etc to get it done.  I appriciate you taking
the time to reply to mine and others posts, however if you do not have
anything nice to say please keep it to yourself.  I am trying to find an
answer to a problem and reading your RTFM does not help.  Thannks again,
Jas

Jason Wong [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Friday 31 May 2002 00:19, Jas wrote:
  Not sure how to do this, but I need to pull the contents of an array
into
  editable text fields...  As of yet I have not found a way to accomplish
  this:

 Good grief, I already posted the answer yesterday. Don't you read the
replies?
 Even if you don't, spending a little time googling for mysql php
tutorial
 would get you numerous examples.

  $table = auth_users;
   $record = @mysql_query(SELECT * FROM $table WHERE user_id =
  '$user_id',$dbh);

 [snip]

  echo $record;
 
  It only echoes the resource id, any help or examples would be great

 I repeat, mysql_query() returns a resource-id which you need to feed into
 mysql_fetch_array() to get the actual record.

 --
 Jason Wong - Gremlins Associates - www.gremlins.com.hk
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *


 /*
 The chief danger in life is that you may take too many precautions.
 -- Alfred Adler
 */




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




Re: Re[2]: [PHP-DB] how to pull array out?

2002-05-30 Thread Jas

Ok, given there are people out there that expect people to do the work for
them, however if you look at my original post (today) you will see that I
have queried the database, feed the results into an array, then called the
array elements into my form, however simple this may be for you it is still
not pulling out the results of the array into my form.  I do believe I am
missing something, and doing homework is a part of my everyday routine
trying to develop web based apps.  The code again:

$table = auth_users; // names the table to query correct?
 $record = @mysql_query(SELECT * FROM $table WHERE user_id =
'$user_id',$dbh); // pulls all records in relation to $user_id correct?
   while ($row = mysql_fetch_array($record)) { // pulls results of query
into an array correct?
$user_id = $row['user_id']; // assigns unique names for my different
editable regions correct?
$f_name = $row['f_name'];
$l_name = $row['l_name'];
$email_addy = $row['email_addy'];
$un = $row['un'];
$pw = $row['pw']; }
$var_form .= form name=\$user_id\ method=\post\
action=\del_account.php\
  bEdit Account $user_id/bbr // echoes the $user_id that is going
to be edited correct?
First Name:input type=\text\ name=\f_name\ size=\30\
maxlength=\30\ value=\$f_name\br // displays text box to edit with
$f_name variable from resulting array correct?
Last Name:input type=\text\ name=\l_name\ size=\30\
maxlength=\30\ value=\$l_name\br // displays text box to edit with
$l_name variable from resulting array correct?
Email:input type=\text\ name=\email_addy\ size=\30\
maxlength=\30\ value=\$email_addy\br // displays text box to edit
with $email_addy variable from resulting array correct?
User Name:input type=\text\ name=\un\ size=\30\ maxlength=\30\
value=\$un\br  // displays text box to edit with $un variable from
resulting array correct?
Password:input type=\password\ name=\pw\ size=\30\
maxlength=\30\br // displays text box to edit with $pw variable from
resulting array correct?
Confirm Password:input type=\password\ name=\cpw\ size=\30\
maxlength=\30\
nbsp;input type=\submit\ name=\add\ value=\edit
user\nbsp;nbsp;input type=\reset\ name=\reset\ value=\reset\;

Any help or examples are appreciated.  Please understand I am trying to
learn this scripting language and RTFM does not help as most of the time I
post here as a LAST resort, i.e. after I have indeed RTFM'ed.
Thanks again,
Jas


Julie Meloni [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Jas (and anyone else) -

 With all due respect, you're acting like a troll.  Posting a question,
 getting MANY correct answers, then reposting the question and bitching
 about not understanding the answers, well, that's troll-like.

 Granted, many responses on this list over the past while have been
 sarcastic, but usually also have the answer in them.  The tone comes
 from people asking the questions not doing their own homework.

 e.g. http://www.tuxedo.org/~esr/faqs/smart-questions.html

 Mailing lists such as this one are not intended to give people
 verbatim answers to their problems, such as I have to write an
 application for my university class, please do it for me and the
 like.  Instead, these lists will help those who attempt to help
 themselves.

 The fact of the matter is, RTFM is the right answer.  The very
 simplistic method of reading the results of a MySQL query are right
 there in the manual, in the MySQL query functions section.  Also,
 they're in zillions of tutorials, any basic book on PHP, and so on.

 In short:

 1) connect to db server -- mysql_connect()
 2) select db -- mysql_select_db()
 3) issue query -- mysql_query()
 4) from there you get a result identifier.  You feed that into
 mysql_result() or mysql_fetch_array() or mysql_fetch_row()

 Read the manual for the differences -- including examples.


 You say:
 J rest of us we rely on examples, etc to get it done.

 They ARE in the manual, which is pretty much the best manual out there
 for just about anything.

 Good luck,
 - Julie

 -- Julie Meloni
 -- [EMAIL PROTECTED]
 -- www.thickbook.com

 Find Sams Teach Yourself MySQL in 24 Hours at
 http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20




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




Re: Re[2]: [PHP-DB] how to pull array out?

2002-05-30 Thread Jas

SUCCESS
Ok, I have fixed the problem.  Here is the code, I hope it helps anyone that
comes accross something like this.  Sorry for being a troll.
Jas
// Displays select form of current users in database table for editing
$table = users;
 $record = @mysql_query(SELECT * FROM $table,$dbh);
  while ($row = mysql_fetch_array($record)) {
$user_id = $row['user_id'];
$f_name = $row['f_name'];
$l_name = $row['l_name'];
$email_addy = $row['email_addy'];
$un = $row['un'];
$pw = $row['pw'];
$option .=OPTION VALUE=\$user_id\$f_name $l_name/OPTION;
$var_form = pFORM METHOD=\post\ ACTION=\edit_account.php\
bPlease select the user you would like to edit from the list/bbr
SELECT NAME=\blank\$option/SELECT
INPUT TYPE=\submit\ NAME=\submit\ VALUE=\select\
/FORMbr;
// Takes value of blank and looks for a record matching selected user and
puts the results into a form for editing
$table = auth_users;
 $record = @mysql_query(SELECT * FROM $table WHERE user_id =
'$blank',$dbh);
   while ($row = mysql_fetch_array($record)) {
$user_id = $row['user_id'];
$f_name = $row['f_name'];
$l_name = $row['l_name'];
$email_addy = $row['email_addy'];
$un = $row['un'];
$pw = $row['pw']; }
$var_form .= table width=\100%\ border=\0\ cellpadding=\7\form
name=\$user_id\ method=\post\ action=\del_account.php\
  trtd width=\20%\ colspan=\2\bEdit Account
$user_id/b/td/tr
trtd width=\20%\First Name:/tdtd width=\80%\input
type=\text\ name=\$f_name\ size=\30\ maxlength=\30\
value=\$f_name\font class=\copyright\i.e. John/font/td/tr
trtd width=\20%\Last Name:/tdtd width=\80%\input
type=\text\ name=\$l_name\ size=\30\ maxlength=\30\
value=\$l_name\font class=\copyright\i.e. Doe/font/td/tr
  trtd width=\20%\Email:/tdtd width=\80%\input
type=\text\ name=\$email_addy\ size=\30\ maxlength=\30\
value=\$email_addy\font class=\copyright\i.e.
[EMAIL PROTECTED]/font/td/tr
trtd width=\20%\User Name:/tdtd width=\80%\input
type=\text\ name=\$un\ size=\30\ maxlength=\30\ value=\$un\font
class=\copyright\i.e. j-doe/font/td/tr
trtd width=\20%\Password:/tdtd width=\80%\input
type=\password\ name=\$pw\ size=\30\ maxlength=\30\font
class=\copyright\(password must be alpha-numeric, i.e.
pAs5w0rd)/font/td/tr
trtd width=\20%\Confirm Password:/tdtd
width=\80%\input type=\password\ name=\$pw\ size=\30\
maxlength=\30\font class=\copyright\please confirm password
entered/font/td/tr
trtd width=\20%\nbsp;/tdtd width=\80%\input
type=\submit\ name=\add\ value=\edit user\nbsp;nbsp;input
type=\reset\ name=\reset\ value=\reset\/td/tr
   /form/table;
*** The problem was that I was looking for the variable $user_id in my
select statement not the option name which is blank (just me getting ahead
of myself, sorry once again) ***

Natalie Leotta [EMAIL PROTECTED] wrote in message
7546CB15C0A1D311BF0D0004AC4C4B0C024AC468@SSIMSEXCHNG">news:7546CB15C0A1D311BF0D0004AC4C4B0C024AC468@SSIMSEXCHNG...
 From what I've seen on the PHP.net site, it doesn't look like people use
the
 @ in @mysql_query, and I know that I don't use it for sybase_query.  Where
 did it come from?

 Assuming that's not the problem, I'd try printing out everything.  Right
 after your while, print $row - it should say array, then try printing
 $row[0] and see if that works.  Then try printing $row['user_id'].

 You may also want to try doing a SELECT with the fieldnames, instead of
just
 the *.  Also, make sure you're typing the field names correctly - they are
 case sensitive.

 Hopefully one of these suggestions will help you.

 -Natalie

 -Original Message-
 From: Jas [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, May 30, 2002 2:18 PM
 To: [EMAIL PROTECTED]
 Subject: Re: Re[2]: [PHP-DB] how to pull array out?


 Ok, given there are people out there that expect people to do the work
for
 them, however if you look at my original post (today) you will see that I
 have queried the database, feed the results into an array, then called the
 array elements into my form, however simple this may be for you it is
still
 not pulling out the results of the array into my form.  I do believe I am
 missing something, and doing homework is a part of my everyday routine
 trying to develop web based apps.  The code again:

 $table = auth_users; // names the table to query correct?
  $record = @mysql_query(SELECT * FROM $table WHERE user_id =
 '$user_id',$dbh); // pulls all records in relation to $user_id correct?
while ($row = mysql_fetch_array($record)) { // pulls results of query
 into an array correct?
 $user_id = $row['user_id']; // assigns unique names for my different
 editable regions correct?
 $f_name = $row['f_name'];
 $l_name = $row['l_name'];
 $email_addy = $row['email_addy'];
 $un = $row['un'];
 $pw = $row['pw']; }
 $var_form .= form name=\$user_id\ method=\post\
 action=\del_account.php\
   bEdit Account $user_id/bbr // echoes the 

[PHP-DB] Resource ID#2 ????

2002-05-29 Thread Jas

Ok here is my problem, I set this up so a user selects a name form a select
box and that name or $user_id is then  passed to this page so the user can
edit the contact info etc.  However it does not pull the selected $user_id
and place each field into my form boxes, all I get is a Resource ID #2.  Not
sure how I can over come this...

$table = auth_users;
 $record = @mysql_query(SELECT * FROM $table WHERE user_id =
'$user_id',$dbh);
$var_form .= table width=\100%\ border=\0\ cellpadding=\7\form
name=\$user_id\ method=\post\ action=\del_account.php\
  trtd width=\20%\ colspan=\2\bEdit Account
$user_id/b/td/tr
trtd width=\20%\First Name:/tdtd width=\80%\input
type=\text\ name=\$f_name\ size=\30\ maxlength=\30\
value=\$f_name\font class=\copyright\i.e. John/font/td/tr
trtd width=\20%\Last Name:/tdtd width=\80%\input
type=\text\ name=\$l_name\ size=\30\ maxlength=\30\
value=\$l_name\font class=\copyright\i.e. Doe/font/td/tr
  trtd width=\20%\Email:/tdtd width=\80%\input
type=\text\ name=\$email_addy\ size=\30\ maxlength=\30\
value=\$email_addy\font class=\copyright\i.e.
[EMAIL PROTECTED]/font/td/tr
trtd width=\20%\User Name:/tdtd width=\80%\input
type=\text\ name=\$un\ size=\30\ maxlength=\30\ value=\$un\font
class=\copyright\i.e. j-doe/font/td/tr
trtd width=\20%\Password:/tdtd width=\80%\input
type=\password\ name=\$pw\ size=\30\ maxlength=\30\font
class=\copyright\(password must be alpha-numeric, i.e.
pAs5w0rd)/font/td/tr
trtd width=\20%\Confirm Password:/tdtd
width=\80%\input type=\password\ name=\$pw\ size=\30\
maxlength=\30\font class=\copyright\please confirm password
entered/font/td/tr
trtd width=\20%\nbsp;/tdtd width=\80%\input
type=\submit\ name=\add\ value=\edit user\nbsp;nbsp;input
type=\reset\ name=\reset\ value=\reset\/td/tr
   /form/table;
echo $record;
} else {
blah blah
}
Thanks in advance,
Jas




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




Re: [PHP-DB] Resource ID#2 ????

2002-05-29 Thread Jas

If you look at the previously posted code at the bottom of the form there is
a echo for the sql select statement that is echoing Resource id #2 on the
page.  Now that error is the correct field id number in the database, I am
just not sure how to itemize the data from that table, at least I think.
Any help would be great!
Jas

Jason Wong [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Thursday 30 May 2002 00:17, Jas wrote:
  Ok here is my problem, I set this up so a user selects a name form a
select
  box and that name or $user_id is then  passed to this page so the user
can
  edit the contact info etc.  However it does not pull the selected
$user_id
  and place each field into my form boxes, all I get is a Resource ID #2.
  Not sure how I can over come this...
 
  $table = auth_users;
   $record = @mysql_query(SELECT * FROM $table WHERE user_id =
  '$user_id',$dbh);

 Make liberal use of error checking (see manual) and mysql_error().

 --
 Jason Wong - Gremlins Associates - www.gremlins.com.hk
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *


 /*
 grep me no patterns and I'll tell you no lines.
 */




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




Re: [PHP-DB] Resource ID#2 ????

2002-05-29 Thread Jas

How can I get the form below to list the single record in a db that matches
the request of $user_id?
$table = auth_users;
 $record = @mysql_query(SELECT * FROM $table WHERE user_id =
'$user_id',$dbh);
   while ($row = mysql_fetch_row($record)) {
$user_id = $row['user_id'];
$f_name = $row['f_name'];
$l_name = $row['l_name'];
$email_addy = $row['email_addy'];
$un = $row['un'];
$pw = $row['pw']; }
$var_form .= table width=\100%\ border=\0\ cellpadding=\7\form
name=\$user_id\ method=\post\ action=\del_account.php\
  trtd width=\20%\ colspan=\2\bEdit Account
$user_id/b/td/tr
trtd width=\20%\First Name:/tdtd width=\80%\input
type=\text\ name=\f_name\ size=\30\ maxlength=\30\
value=\$f_name\font class=\copyright\i.e. John/font/td/tr
trtd width=\20%\Last Name:/tdtd width=\80%\input
type=\text\ name=\l_name\ size=\30\ maxlength=\30\
value=\$l_name\font class=\copyright\i.e. Doe/font/td/tr
  trtd width=\20%\Email:/tdtd width=\80%\input
type=\text\ name=\email_addy\ size=\30\ maxlength=\30\
value=\$email_addy\font class=\copyright\i.e.
[EMAIL PROTECTED]/font/td/tr
trtd width=\20%\User Name:/tdtd width=\80%\input
type=\text\ name=\un\ size=\30\ maxlength=\30\ value=\$un\font
class=\copyright\i.e. j-doe/font/td/tr
trtd width=\20%\Password:/tdtd width=\80%\input
type=\password\ name=\pw\ size=\30\ maxlength=\30\font
class=\copyright\(password must be alpha-numeric, i.e.
pAs5w0rd)/font/td/tr
trtd width=\20%\Confirm Password:/tdtd
width=\80%\input type=\password\ name=\pw\ size=\30\
maxlength=\30\font class=\copyright\please confirm password
entered/font/td/tr
trtd width=\20%\nbsp;/tdtd width=\80%\input
type=\submit\ name=\add\ value=\edit user\nbsp;nbsp;input
type=\reset\ name=\reset\ value=\reset\/td/tr
   /form/table;
echo $record;
Thanks in advance,
Jas


Natalie Leotta [EMAIL PROTECTED] wrote in message
7546CB15C0A1D311BF0D0004AC4C4B0C024AC420@SSIMSEXCHNG">news:7546CB15C0A1D311BF0D0004AC4C4B0C024AC420@SSIMSEXCHNG...
 I could be missing something, but it looks like you are using the result
of
 the mysql_query as the actual result.  It actually returns some weird
 identifier.  To access the real info you'd have to use something like
 mysql_fetch_array to get it.

 Check out this and see if it helps:

 http://www.php.net/manual/en/function.mysql-query.php

 -Natalie

 -Original Message-
 From: Jas [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, May 29, 2002 12:18 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Resource ID#2 


 Ok here is my problem, I set this up so a user selects a name form a
select
 box and that name or $user_id is then  passed to this page so the user can
 edit the contact info etc.  However it does not pull the selected $user_id
 and place each field into my form boxes, all I get is a Resource ID #2.
Not
 sure how I can over come this...

 $table = auth_users;
  $record = @mysql_query(SELECT * FROM $table WHERE user_id =
 '$user_id',$dbh);
 $var_form .= table width=\100%\ border=\0\
cellpadding=\7\form
 name=\$user_id\ method=\post\ action=\del_account.php\
   trtd width=\20%\ colspan=\2\bEdit Account
 $user_id/b/td/tr
 trtd width=\20%\First Name:/tdtd width=\80%\input
 type=\text\ name=\$f_name\ size=\30\ maxlength=\30\
 value=\$f_name\font class=\copyright\i.e. John/font/td/tr
 trtd width=\20%\Last Name:/tdtd width=\80%\input
 type=\text\ name=\$l_name\ size=\30\ maxlength=\30\
 value=\$l_name\font class=\copyright\i.e. Doe/font/td/tr
   trtd width=\20%\Email:/tdtd width=\80%\input
 type=\text\ name=\$email_addy\ size=\30\ maxlength=\30\
 value=\$email_addy\font class=\copyright\i.e.
 [EMAIL PROTECTED]/font/td/tr
 trtd width=\20%\User Name:/tdtd width=\80%\input
 type=\text\ name=\$un\ size=\30\ maxlength=\30\
value=\$un\font
 class=\copyright\i.e. j-doe/font/td/tr
 trtd width=\20%\Password:/tdtd width=\80%\input
 type=\password\ name=\$pw\ size=\30\ maxlength=\30\font
 class=\copyright\(password must be alpha-numeric, i.e.
 pAs5w0rd)/font/td/tr
 trtd width=\20%\Confirm Password:/tdtd
 width=\80%\input type=\password\ name=\$pw\ size=\30\
 maxlength=\30\font class=\copyright\please confirm password
 entered/font/td/tr
 trtd width=\20%\nbsp;/tdtd width=\80%\input
 type=\submit\ name=\add\ value=\edit user\nbsp;nbsp;input
 type=\reset\ name=\reset\ value=\reset\/td/tr
/form/table;
 echo $record;
 } else {
 blah blah
 }
 Thanks in advance,
 Jas




 --
 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] Error? new set of eyes...

2002-05-28 Thread Jas

Hello all,
I have an error and I will be darned if I know why.  Here is the code:
?php
require '/path/to/database/connection/class/db.php';
$table = portfolio;
$portfolio = mysql_query(SELECT * FROM $table,$dbh);
while ($sections = mysql_fetch_array($portfolio)) {
 list($id, $2d, $3d, $web, $prog, $tut, $proj) = $sections; // I think the
error is on this line.
}
?
Then I just echo the contents of the database array like so.
?php echo $2d; ? // this is line 69
And this is the error I am recieving:
Parse error: parse error, expecting `T_VARIABLE' or `'$'' in
/localhost/portfolio.php on line 169
Any help would be great!!
Jas



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




[PHP-DB] How to store results into a session variable..

2002-04-30 Thread Jas

I need a tutorial or example on how to take a result from an mysql query and
place it into a session variable.  Please help?
Thanks in advance,
Jas



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




[PHP-DB] mysql results to a session variable?

2002-04-27 Thread Jas

I am just wondering if there is a way to pull the results from an mysql
query into an session variable that can be passed from page to page.  If
there is a way to do this could someone please point out a good tutorial on
this specific function or maybe an example of how to accomplish this.  Any
help would be great.
thanks in advance,
Jas



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




[PHP-DB] Unique Field for text field...

2002-04-20 Thread Jas

Here is my problem:
?php
/* Connecting, selecting database */
$link = mysql_connect(localhost, , )
or die(Could not connect);
mysql_select_db(shopping) or die(Could not select database);

/* Performing SQL query */
$query = SELECT * FROM cart;
$result = mysql_query($query) or die(Query failed);

/* Printing results in HTML */
print table width=\100%\ border=\0\ cellspacing=\0\
cellpadding=\3\\ntr
  td colspan=\6\bSelect item(s) for
purchase/b/td
/trtr
  td width=\3%\
bgcolor=\#e4e4e4\uID/u/td
  td width=\10%\
bgcolor=\#e4e4e4\uName/u/td
  td width=\15%\
bgcolor=\#e4e4e4\uItem Number/u/td
  td width=\18%\
bgcolor=\#e4e4e4\uDescription/u/td
  td width=\3%\
bgcolor=\#e4e4e4\uCost/u/td
  td width=\3%\ bgcolor=\#e4e4e4\uSale/u/td
  td width=\8%\ bgcolor=\#e4e4e4\uAdd Item/u/td
/tr;
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
print \ttr\n;
foreach ($line as $col_value) {
print \t\ttd$col_value/td\n;
}
print td width=\10%\ form name=\add_item\ method=\post\
action=\add_item\
/form
input type=\text\ name=\add_num\
size=\3\ maxlength=\6\
input type=\submit\ name=\add\
value=\add\/form
  /td\t/tr\n;
}
print /table\n;

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

/* Closing connection */
mysql_close($link);
?
I use this to query the database and put the results into a form for later
use... The problem I am having is how would I assign a unique field name for
each entry displayed?  I am not sure how I can do this with the $col_value
simply echoing the results onto the page, if anyone could shed some light on
this I would appreciate it.  Thanks in advance,
Jas



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




[PHP-DB] If statement for sql statement

2002-04-09 Thread jas

Ok here is my question... I have a form that reads the contents of a
directory, places the resulting files into a select box within a form for
further processing, code is as follows:
?php
$dir_name = /virtual/path/to/images/directory/;
$dir = opendir($dir_name);
$file_list .= pFORM METHOD=\post\ ACTION=\index_done.php3\
SELECT NAME=\files\OPTION VALUE=\--\
NAME=\--\--/OPTION;
 while ($file_name = readdir($dir)) {
  if (($file_name != .)  ($file_name !=..)) {
  $file_list .= OPTION VALUE=\$file_name\
NAME=\$file_name\$file_name/OPTION;
  }
 }
 $file_list .= /SELECTbrbrINPUT TYPE=\submit\ NAME=\submit\
VALUE=\select\/FORM/p;
 closedir($dir);
?
This portion works great... now on index_done.php3 it takes the resulting
selection and places it into the db table, code is as follows:
?php
$file_var = http://localhost/images/;;
$db_name = database;
$table_name = image_path;
$connection = mysql_connect(localhost, user_name, password) or die
(Could not connect to database.  Please try again later.);
$db = mysql_select_db($db_name,$connection) or die (Could not select
database table. Please try again later.);
$sql = UPDATE $table_name SET image01_t=\$file_var$files\;
$result = mysql_query($sql, $connection) or die (Could not execute query.
Please try again later.);
?
What I need to know is if there is a way to create an if statement that
would either update or not update a selected field in the database.  Below
is a piece I would assume would work however I am not sure of the mysql
command to not update anything.  Any help would be great.
Jas

if( $file_name = '--' ) $sql = dont update table;
else $sql = UPDATE $table_name SET image01_t = \$files\;




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




[PHP-DB] Stuck on db entry from select box...

2002-04-05 Thread Jas

Ok here is my problem and where I am at this far, first thing I needed to do
is to read the contents of a directory and place the results into a select
box in a form (accomplished), now where I am stuck is passing the selection
from said select box to another script so it may be put into a mysql
database table... my code is as follows:
?php
$dir_name = /path/to/images/directory/;
$dir = opendir($dir_name);
$file_list .= pFORM METHOD=\post\ ACTION=\index_done.php3\
SELECT NAME=\files\$file_name;
 while ($file_name = readdir($dir)) {
  if (($file_name != .)  ($file_name !=..)) {
  $file_list .= OPTION VALUE=\$file_name\
NAME=\$file_name\$file_name/OPTION;
  }
 }
 $file_list .= /SELECTbrbrINPUT TYPE=\submit\ NAME=\submit\
VALUE=\select\/FORM/p;
 closedir($dir);
?
within the page... I echo the results like so:
? echo $file_list; ?
so far so good, now on the index_done.php3 my code is put into a require
statement and the required file code is as follows...
?php
$db_name = database_name;
$table_name = cm_index;
$connection = mysql_connect(localhost, username, password) or die
(Could not connect to database.  Please try again later.);
$db = mysql_select_db($db_name,$connection) or die (Could not select
database table. Please try again later.);
$sql = UPDATE $table_name SET file_name=\$file_name\;
$result = mysql_query($sql, $connection) or die (Could not execute query.
Please try again later.);
?
I think I need a new pair of eyes to review this and let me know where I am
going wrong, also on another note I don't want to put the file in the
database table I want to put the path to the file in the database table, any
help would be greatly appriciated. =)
Jas



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




Re: [PHP-DB] Stuck on db entry from select box...

2002-04-05 Thread Jas

Ok I made the changes you suggested and unfortunately I am getting the same
results... Could not execute query, I manually put entries into the tables
so that the update command would just overwrite the current contents.  Here
is my code this far, I think my problem (correct me if I am wrong) lies in
the fact that each of select boxes does not contain a unique name, needless
to say I am stuck:
?php
$dir_name = /path/to/images/directory/;
$dir = opendir($dir_name);
$file_list .= pFORM METHOD=\post\ ACTION=\index_done.php3\
SELECT NAME=\files\;
 while ($file_name = readdir($dir)) {
  if (($file_name != .)  ($file_name !=..)) {
  $file_list .= OPTION VALUE=\$file_name\
NAME=\$file_name\$file_name/OPTION;
  }
 }
 $file_list .= /SELECTbrbrINPUT TYPE=\submit\ NAME=\submit\
VALUE=\select\/FORM/p;
 closedir($dir);
?
Select boxes are filled with files from specified folder... then echoed to
screen
? echo $file_list; ?
Working fine... when user click on image using said select box it links to
this file, code is as follows:
?php
$db_name = db_name;
$table_name = cm_index;
$connection = mysql_connect(localhost, user_name, password) or die
(Could not connect to database.  Please try again later.);
$db = mysql_select_db($db_name,$connection) or die (Could not select
database table. Please try again later.);
$sql = UPDATE $table_name SET file_name=\$files\;
$result = mysql_query($sql, $connection) or die (Could not execute query.
Please try again later.);
?
Still getting could not execute query... sorry about not knowing where I am
going wrong but still new to these advanced functions.  Thanks in advance,
Jas



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




Re: [PHP-DB] Stuck on db entry from select box...

2002-04-05 Thread Jas

Upon doing a print $sql before the mysql_querie I get this output;
UPDATE cm_index SET ad01_t=$filesCould not execute query. Please try again
later



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




[PHP-DB] how to question...

2002-04-04 Thread jas

Ok here is what I would like to accomplish, I am sure someone has done
something like this but I need an example to go from since I am still not
able to write php from scratch...
I need to write a function to count the contents of a directory, like the
file names and place them into an array so I can use a select box to select
the file path in which I would like to save to database, like I said I don't
want someone to do it for me, I just need a resource such as a tutorial or
example to run with. Thanks a ton,
Jas



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




[PHP-DB] calculations based on checkbox value

2002-03-22 Thread jas

Ok here is my problem, currently I have a form that calculates the number of
words in a given textarea.  Now what I need to accomplish is using a
checkbox to subtract a value based on said checkbox.  I have looked for a
tutorial on such an item and did not find one so I am asking if anyone out
there has accomplished a similar function and if so could you point out a
good tutorial or let me see some sample code?  Thanks in advance,
Jas



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




[PHP-DB] textarea and mysql query

2002-03-18 Thread jas

I need some help with a query to place the results within a text area...
here is the code and so far every time I try it out all that happens is it
displays the textbox but not the results of the query.
form name=wel_area method=post action=index_confirm.php3 target=box
?php
$record = mysql_fetch_array(mysql_query(SELECT wel_area FROM
cm_index,$dbh));
echo textarea name='wel_area' value='{$record['wel_area']}' cols='25'
rows='8'/textareabrinput type='submit' name='save'
value='save'br\n;
?
  /form
Any help would be great.
Jas



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




Re: [PHP-DB] textarea and mysql query

2002-03-18 Thread jas

Yeah that didn't work either... If I put the same value (
value=\{$record['wel_area']}\ ) on a text line it works just fine however
using the same value for a textarea doesnt give me any results nor does it
give me an error message to go on, if there is a way to output the code to
the screen like a dos echo command that would help out alot.  Thanks in
advance,
Jas
Ray Hunter [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Try this:

 form name=wel_area method=post action=index_confirm.php3
target=box
 ?php
 $record = mysql_fetch_array(@mysql_query(SELECT wel_area FROM
 cm_index,$dbh));
 echo textarea name='wel_area' value='.$record['wel_area'].' cols='25'
 rows='8'/textareabrinput type='submit' name='save'
 value='save'br\n;
 ?
 /form

 If not then let me know...


 Thank you,

 Ray Hunter
 Firmware Engineer

 ENTERASYS NETWORKS


 -Original Message-
 From: jas [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, March 17, 2002 11:54 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] textarea and mysql query


 I need some help with a query to place the results within a text area...
 here is the code and so far every time I try it out all that happens is it
 displays the textbox but not the results of the query. form
name=wel_area
 method=post action=index_confirm.php3 target=box
 ?php
 $record = mysql_fetch_array(@mysql_query(SELECT wel_area FROM
 cm_index,$dbh)); echo textarea name='wel_area'
 value='{$record['wel_area']}' cols='25' rows='8'/textareabrinput
 type='submit' name='save' value='save'br\n; ?
   /form
 Any help would be great.
 Jas



 --
 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] textarea and mysql query

2002-03-18 Thread jas

Sorry, the connection is established already so that part works just fine.
It is getting the results of said connection \ query to appear in a textarea
vs. a text line.
Jason Wong [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]...
 On Monday 18 March 2002 14:53, jas wrote:

  I need some help with a query to place the results within a text area...
  here is the code and so far every time I try it out all that happens is
it
  displays the textbox but not the results of the query.
  form name=wel_area method=post action=index_confirm.php3
  target=box ?php
  $record = mysql_fetch_array(@mysql_query(SELECT wel_area FROM
  cm_index,$dbh));
  echo textarea name='wel_area' value='{$record['wel_area']}' cols='25'
  rows='8'/textareabrinput type='submit' name='save'
  value='save'br\n;
  ?
/form


 If this is *all* your code then you're missing the important step of
 connecting to the mysql server and selecting a database.

 Have a look at the examples in the manual.


 --
 Jason Wong - Gremlins Associates - www.gremlins.com.hk

 /*
 Most people don't need a great deal of love nearly so much as they need
 a steady supply.
 */



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




Re: [PHP-DB] textarea and mysql query

2002-03-18 Thread jas

Yeah it is not multidimensional at all, a simple text blob is what should be
pulled into the textarea.  I am not trying to query multipled record fields
at all.  One field per textarea.  Do you know of a good tutorial on pulling
sql queries into textareas?  If you do please let me know as I have searched
php.net and other sites for a tutorial on textarea's but have not found any
nor is there any reference to such a problem in any of the php or mysql
books i have.
Ray Hunter [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 What is the result of $record['wel_area'].  If this is a multidimensional
 array then you will need to access it differently...

 Example:
 echo $record[0][0].\n;

 Try this is your text area and see if that comes out...



 Thank you,

 Ray Hunter
 Firmware Engineer

 ENTERASYS NETWORKS


 -Original Message-
 From: jas [mailto:[EMAIL PROTECTED]]
 Sent: Monday, March 18, 2002 12:07 AM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] textarea and mysql query


 Yeah that didn't work either... If I put the same value (
 value=\{$record['wel_area']}\ ) on a text line it works just fine
however
 using the same value for a textarea doesnt give me any results nor does it
 give me an error message to go on, if there is a way to output the code to
 the screen like a dos echo command that would help out alot.  Thanks in
 advance, Jas Ray Hunter [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Try this:
 
  form name=wel_area method=post action=index_confirm.php3
 target=box
  ?php
  $record = mysql_fetch_array(@mysql_query(SELECT wel_area FROM
  cm_index,$dbh)); echo textarea name='wel_area'
  value='.$record['wel_area'].' cols='25'
  rows='8'/textareabrinput type='submit' name='save'
  value='save'br\n; ?
  /form
 
  If not then let me know...
 
 
  Thank you,
 
  Ray Hunter
  Firmware Engineer
 
  ENTERASYS NETWORKS
 
 
  -Original Message-
  From: jas [mailto:[EMAIL PROTECTED]]
  Sent: Sunday, March 17, 2002 11:54 PM
  To: [EMAIL PROTECTED]
  Subject: [PHP-DB] textarea and mysql query
 
 
  I need some help with a query to place the results within a text
  area... here is the code and so far every time I try it out all that
  happens is it displays the textbox but not the results of the query.
  form
 name=wel_area
  method=post action=index_confirm.php3 target=box
  ?php
  $record = mysql_fetch_array(@mysql_query(SELECT wel_area FROM
  cm_index,$dbh)); echo textarea name='wel_area'
  value='{$record['wel_area']}' cols='25' rows='8'/textareabrinput
  type='submit' name='save' value='save'br\n; ?
/form
  Any help would be great.
  Jas
 
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 



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




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




[PHP-DB] text area

2002-03-11 Thread jas

I am wondering where I could find a good tutorial on displaying the contents
of a database field within a textarea for editing.  Any help would be great!
Thanks in advance,
Jas



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




[PHP-DB] Monitor files

2002-03-07 Thread jas

I am wondering if there is a way to monitor the contents of a directory for
changes and if a change is made, to record the name of the file changed the
date etc and send it to a database and also an email... has anyone every
seen anything like this and if so are there any intrustion detection open
source s/w that is commercially available for download etc.  Maybe a
tutorial on the subject would be great.
Thanks
Jas



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




[PHP-DB] records into an editable box

2002-03-06 Thread jas

How would I change this sql statement to pull the db table and display it
within an editable box within a form?  Any help or tutorials would be great.
?php
$result = mysql_query(SELECT $table FROM $field,$dbh) or die(Could not
execute query, please try again later);
echo Btext:/Bbr\n;
printf(mysql_result($result,wel_area));
?
Thanks in advance,
Jas



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




Re: [PHP-DB] records into an editable box

2002-03-06 Thread jas

No dan I mean textbox... but I am assuming you dont have any idea where a
good tutorial would be then.  Thanks anyways.
Jas
Dan Brunner [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hello!!

 Do you mean a textarea??

 And you want to populate the textarea with the data, right?


 Dan


 On Wednesday, March 6, 2002, at 01:34 AM, [EMAIL PROTECTED] wrote:

  How would I change this sql statement to pull the db table and display
  it
  within an editable box within a form?  Any help or tutorials would be
  great.
  ?php
  $result = mysql_query(SELECT $table FROM $field,$dbh) or die(Could
  not
  execute query, please try again later);
  echo Btext:/Bbr\n;
  printf(mysql_result($result,wel_area));
  ?
  Thanks in advance,
  Jas
 
 
 
  --
  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] security

2002-03-05 Thread jas

how can you find out what the php.ini is looking like?  is there a way to
use php to get that info.  i have used phpinfo() but i cannot see whether or
not file_uploads is disabled
Jas
Paul Burney [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED];
on 3/3/02 7:39 PM, Ric Mañalac at [EMAIL PROTECTED] appended
the following bits to my mbox:

 i personally think that the developer still has
 the control in making his php code secure. but how do you
 think will this news affect php as one of the most popular
 choice for web developers?

Probably doesn't belong so much on the PHP-DB list, since databases not
involved, but since some of you on the list may not be aware

In most cases, PHP security can be controlled by the developer, but *not* in
this case.

Basically, most php security problems stem from someone not properly
checking input and being sloppy when connecting to databases, etc.

This case, however, is an actual problem in the PHP server code, not
anything you would write.  To summarize, if you have file_uploads enabled on
the server, php parses multipart/form-data data that is sent to the
script.

It does this for *any* file, not just the ones that have file uploads in
them.  The bug is in that code and can be used by malicious parties to do
evil things on your server.  It can be used against you even if you only
have one page on your server parsed by PHP and the hacker can find it.

The original report is here:

http://security.e-matters.de/advisories/012002.html

Basically you have three options:

1) Disable file_uploads, if you're not using them, in the php.ini file.
This works for PHP 4.0.3 or greater.

2) Apply the source patch to your source tree and rebuild.  Works for PHP
3.0.18, 4.06, 4.1.0 and 4.1.1.

3) Upgrade to PHP 4.1.2

You should really do this as soon as possible.  I'm sure someone will make a
Code Red type of infestation soon to exploit this bug soon.  Evidently,
there is a crude exploit circulating.

Hope that helps.

Paul

?php
while ($self != asleep) {
$sheep_count++;
}
?




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




[PHP-DB] Re: why won't session_start() work?

2002-02-28 Thread jas

Ryan,
Do you have anything else between your ?php and ?.  Need more code to
determine why.
Jas
Ryan Snow [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED];

 when I do:
   session_start();
   session_register('signor');
   session_register('username');


 I get:

 Warning: Cannot send session cookie - headers already sent by (output
 started at /var/www/html/index.php:3) in
 /var/www/html/index.php on line 14

 Warning: Cannot send session cache limiter - headers already sent (output
 started at /var/www/html/index.php:3) in
 /var/www/html/index.php on line 14

 Anybody know why?

 Thanks.

 Ry



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




[PHP-DB] Re: why won't session_start() work?

2002-02-28 Thread jas

Not to mention that you are registering two different variables... try
combining the two by putting a coma between them. i.e.
session_register('signor','username');
HTH
Jas

Jas [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED];
 Ryan,
 Do you have anything else between your ?php and ?.  Need more code
to
 determine why.
 Jas
 Ryan Snow [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED];
 
  when I do:
session_start();
session_register('signor');
session_register('username');
 
 
  I get:
 
  Warning: Cannot send session cookie - headers already sent by (output
  started at /var/www/html/index.php:3) in
  /var/www/html/index.php on line 14
 
  Warning: Cannot send session cache limiter - headers already sent
(output
  started at /var/www/html/index.php:3) in
  /var/www/html/index.php on line 14
 
  Anybody know why?
 
  Thanks.
 
  Ry





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




[PHP-DB] forced page links...

2002-02-27 Thread jas

I am wondering if there is a good tutorial on how to use php to make users
come from a page before they can access another.  For instance, say you have
one page called index.php which contains a form that once filled in links to
a confirmation page to verify the users data was entered correctly then from
there links to a page that stores the users data into a database table.  The
problem I would like to alleviate is to make sure the users cannot just type
in the name of the last page in the url and put a blank entry into the
database.  I have read a few tutorials on using sessions but I am unclear on
how the use of sessions would require the user to visit each page in
succession.  Thanks in advance,
Jas



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




[PHP-DB] Re: forced page links...

2002-02-27 Thread jas

Can you accomplish this without having the user logged in?  I am unconcerned
with whether or not the user has logged in, I simply need the user to not be
able to bypass a page with a form to go directly to the end page which will
connect and store the form contents into a db.
Thanks in advance,
Jas
Lerp [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi there :) I use session variables to do this, once the user has logged
in
 and you know they are who they say they are, set a session variable using

 session_register(isloggedin);
 $isloggedin = yes;


 And at the top of every page you want protected simply do a check to see
if
 it is set or not. Below code checks to see if that var is set and if not
it
 redirects them to another page.

 ?php session_start(); ?
 ?php

 if (!isset($HTTP_SESSION_VARS[islogged])){

 header(Location:index.php);
 }

 ?


 Hope this helps, Joe :)


 Jas [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  I am wondering if there is a good tutorial on how to use php to make
users
  come from a page before they can access another.  For instance, say you
 have
  one page called index.php which contains a form that once filled in
links
 to
  a confirmation page to verify the users data was entered correctly then
 from
  there links to a page that stores the users data into a database table.
 The
  problem I would like to alleviate is to make sure the users cannot just
 type
  in the name of the last page in the url and put a blank entry into the
  database.  I have read a few tutorials on using sessions but I am
unclear
 on
  how the use of sessions would require the user to visit each page in
  succession.  Thanks in advance,
  Jas
 
 





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




Re: [PHP-DB] Passing contents of array on as variables...

2002-02-26 Thread jas

Would you have an example of that?
Jas
Beau Lebens [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 rather than all the hidden fields and stuff you guys are trying to do -
why
 not just build the array variable you want, then save it into a session,
on
 the next page, access the session variable and wallah - there's your
array,
 still in tact and just as you left it (ie. containing all the info you
want,
 not the word Array)

 HTH

 beua

 // -Original Message-
 // From: jas [mailto:[EMAIL PROTECTED]]
 // Sent: Monday, 25 February 2002 5:50 PM
 // To: [EMAIL PROTECTED]
 // Subject: Re: [PHP-DB] Passing contents of array on as variables...
 //
 //
 // Bjorn,
 // I just wanted to thank you for giving me alot of insight
 // into what I was
 // trying to accomplish however, due to time restraints I have
 // decided to do it
 // a different way by pulling the entries into a select box
 // that a customer can
 // use to delete the different items.  Once again, thanks a ton!!!!
 // Jas
 //
 // Jas [EMAIL PROTECTED] wrote in message
 // [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 //  Ok, I think I understand what you are talking about.  So
 // now I know what I
 //  need to accomplish, and would you happen to know of a good
 // place to learn
 //  about something like this?  For some reason this function
 // keeps seeming to
 //  elude me and if you know of a good tutorial on how to
 // accomplish this I
 //  would appreciate it.  Thanks again,
 //  Jas
 //  [EMAIL PROTECTED] wrote in message
 //  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 //   One problem I see is that you are sending all of the
 // values for all of
 //  your
 //   fields (except the id field) from the first page to the
 // second page, not
 //  just
 //   the ones that are checked, so even if it was working
 // properly, you would
 //  get
 //   a list of all items in the table, not just the checked
 // items.  You need
 // to
 //   send the array of id's (since this is the name for the
 // checkbox) from
 // the
 //   first page to the second one (again in the checkbox form
 // element, you
 // did
 //  not
 //   put a value on it).
 //  
 //   What your first page is currently doing is pulling all of the
 // information
 //  out
 //   of the database.  Then as soon as you pull each item out, you are
 // putting
 //  it
 //   into an hidden form element array, ie.  $car_type[],
 // $car_model[], etc.
 //   regardless of whether the checkbox is checked or not to
 // pass to the next
 //   page.  You do not know if the checkbox is checked or not
 // until the next
 //  page
 //   when it looks at the values in the id array.  On the
 // second page, you
 // need
 //  to
 //   look at the id array and then (through a database call)
 // pull the row
 // from
 //  the
 //   table for each id in the array.
 //  
 //   HTH
 //  
 //   MB
 //  
 //   jas [EMAIL PROTECTED] said:
 //  
 //$i=0;
 //while
 //   
 // ($car_type[$i],$car_model[$i],$car_year[$i],$car_price[$i],$c
 // ar_vin[$i])
 //  {
 //$i ++;
 //}
 //Is what I added and this is what is being output to
 // the screen at this
 //point...
 //=0; while () { ++; }
 //now i am still too new to php to understand why it is
 // not putting the
 //contents of the array into my hidden fields like it
 // does on my first
 //  page (i
 //can see them when I view source).
 //[EMAIL PROTECTED] wrote in message
 //[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 // When you call your $car_type in the second page, you
 // need to set a
 //variable
 // starting at 0 and call it as $car_type[0] and loop
 // through all of
 // the
 //values
 // in the array.
 //
 // ie.
 //
 // $i=0;
 // while ($car_type[$i]) {
 //
 // I have added more code below that should help.
 //
 //     MB
 //
 //
 // jas [EMAIL PROTECTED] said:
 //
 //  Yeah, tried that and it still isnt passing the
 // contents of the
 // array
 //  as
 //a
 //  varible to the confirmation page for deletion.  I
 // am at a loss on
 //  this
 //one.
 //  [EMAIL PROTECTED] wrote in message
 //  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 //   You didn't add the value part of the hidden element, ie.
 //  
 //   INPUT TYPE=\hidden\ NAME=\car_type\
 //  value=\$myrow[car_type]\
 //  
 //   You were naming the field as an array with no value.
 //  
 //   if you want to pass this as an array of values,
 // you would need
 // to
 //  use:
 //  
 //   INPUT TYPE=\hidden\ NAME=\car_type[]\
 //  value=\$myrow[car_type]\
 //  
 //   Give that a try and see if it works.
 //  
 //   HTH
 //  
 //   MB
 //  
 //  
 //   jas [EMAIL PROTECTED] said:
 //  
 //As of right now if you run the php script and
 // view source on
 // the
 //page
 //  y

[PHP-DB] Passing contents of array on as variables...

2002-02-25 Thread jas

Ok to this point I have been able to query a database table, display the
results in tables and within a form.  As of yet I have been able to insert
the contents of the db query into an array for further processing.  However,
when I try to pass the contents of that array on to another page to delete
selected records from the db it only displays the word array.  Not quite
sure where I need to go from here... Any insight would be a great help.
Thanks in advance,
Jas



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




Re: [PHP-DB] Passing contents of array on as variables...

2002-02-25 Thread jas

Oops... yeah its a monday.
Bjorn, I reverted back to my original code because I was getting confused...
Here is page one...
?php
// Database connection paramaters
require '../path/to/db.php';
// SQL statement to get current inventory
$result = @mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not
execute query, please try again later);
// Creating table to make data look pretty
echo table border=\0\ class=\table-body\ width=\100%\form
name=\rem_inv\ method=\post\ action=\rem_conf.php3\
trtd align=\center\ colspan=\3\font size=\4\BCurrent
Inventory/B/fonthr color=\33\/td/tr;
// Start to count number of records in selected table and loop until done
$count = -1;
while ($myrow = mysql_fetch_array($result)) {
$count ++;
// Begin placing them into an hidden fields and then array
echo 
INPUT TYPE=\hidden\ NAME=\car_type[.$myrow[car_type].]\
INPUT TYPE=\hidden\ NAME=\car_model[.$myrow[car_model].]\
INPUT TYPE=\hidden\ NAME=\car_year[.$myrow[car_year].]\
INPUT TYPE=\hidden\ NAME=\car_price[.$myrow[car_price].]\
INPUT TYPE=\hidden\ NAME=\car_vin[.$myrow[car_vin].]\
// Place items on separate cells in html table
trtd width=\30%\BType Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_type));
// Create checkbox so user can delete items if needed
echo /tdtdinput type=\checkbox\
name=\id[.$myrow[id].]\remove/td/tr\n;
echo trtd width=\30%\BModel Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_model));
echo /td/tr\n;
echo trtd width=\30%\BYear Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_year));
echo /td/tr\n;
echo trtd width=\30%\BPrice Of Car: /B/tdtd$;
printf(mysql_result($result,$count,car_price));
echo /td/tr\n;
echo trtd width=\30%\BVIN Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_vin));
echo /td/trtrtd colspan=\3\hr color=\33\/td/tr\n;
}
// End loop and print the infamous delete button
echo trtdinput type=\submit\ name=\delete\
value=\delete\/td/tr/form/table;
?
Here is page two...
?php
print(
table border=\0\ class=\table-body\ width=\100%\
form name=\rem_inv\ method=\post\ action=\done2.php3\
INPUT TYPE=\hidden\ NAME=\car_type[.$myrow[car_type].]\
INPUT TYPE=\hidden\ NAME=\car_model[.$myrow[car_model].]\
INPUT TYPE=\hidden\ NAME=\car_year[.$myrow[car_year].]\
INPUT TYPE=\hidden\ NAME=\car_price[.$myrow[car_price].]\
INPUT TYPE=\hidden\ NAME=\car_vin[.$myrow[car_vin].]\
  tr
td align=\center\ colspan=\3\font size=\4\BConfirm Record
Deletion/B/fonthr color=\33\/td
  /tr
  tr
td width=\30%\BType Of Car: /B/td
 td$car_type/td // here is where it prints the word array instead of
type of car
  /tr
  tr
td width=\30%\BModel Of Car: /B/td
 td$car_model/td
  /tr
  tr
td width=\30%\BYear Of Car: /B/td
 td$car_year/td
  /tr
  tr
td width=\30%\BPrice Of Car: /B/td
 td$car_price/td
  /tr
  tr
td width=\30%\BVIN Of Car: /B/td
 td$car_vin/td
  /tr
  tr
td colspan=\3\hr color=\33\/td
  /tr
  tr
tdinput type=\submit\ name=\delete\ value=\delete\/td
  /tr
/form
/table);
?

[EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Let's see what your code looks like now and where it is returning the
 word array.  That might help determine where the problem lies now.

 MB

 jas [EMAIL PROTECTED] said:

  Ok to this point I have been able to query a database table, display the
  results in tables and within a form.  As of yet I have been able to
insert
  the contents of the db query into an array for further processing.
However,
  when I try to pass the contents of that array on to another page to
delete
  selected records from the db it only displays the word array.  Not
quite
  sure where I need to go from here... Any insight would be a great help.
  Thanks in advance,
  Jas
 
 
 
  --
  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] Passing contents of array on as variables...

2002-02-25 Thread jas

As of right now if you run the php script and view source on the page you
can see that it does place the content of db table into array... ex.
BCurrent Inventory/B/fonthr color=33/td/tr
INPUT TYPE=hidden NAME=car_type[Ford]
INPUT TYPE=hidden NAME=car_model[Ranger]
INPUT TYPE=hidden NAME=car_year[1999]
INPUT TYPE=hidden NAME=car_price[5600]
INPUT TYPE=hidden NAME=car_vin[no vin]
trtd width=30%BType Of Car: /B/tdtdFord/tdtdinput
type=checkbox name=id[1]remove/td/tr
but on the following page (after selecting items to delete) it just displays
the word array for each field (i.e. car_type etc.)

Jas [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Oops... yeah its a monday.
 Bjorn, I reverted back to my original code because I was getting
confused...
 Here is page one...
 ?php
 // Database connection paramaters
 require '../path/to/db.php';
 // SQL statement to get current inventory
 $result = @mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not
 execute query, please try again later);
 // Creating table to make data look pretty
 echo table border=\0\ class=\table-body\ width=\100%\form
 name=\rem_inv\ method=\post\ action=\rem_conf.php3\
 trtd align=\center\ colspan=\3\font size=\4\BCurrent
 Inventory/B/fonthr color=\33\/td/tr;
 // Start to count number of records in selected table and loop until done
 $count = -1;
 while ($myrow = mysql_fetch_array($result)) {
 $count ++;
 // Begin placing them into an hidden fields and then array
 echo 
 INPUT TYPE=\hidden\ NAME=\car_type[.$myrow[car_type].]\
 INPUT TYPE=\hidden\ NAME=\car_model[.$myrow[car_model].]\
 INPUT TYPE=\hidden\ NAME=\car_year[.$myrow[car_year].]\
 INPUT TYPE=\hidden\ NAME=\car_price[.$myrow[car_price].]\
 INPUT TYPE=\hidden\ NAME=\car_vin[.$myrow[car_vin].]\
 // Place items on separate cells in html table
 trtd width=\30%\BType Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_type));
 // Create checkbox so user can delete items if needed
 echo /tdtdinput type=\checkbox\
 name=\id[.$myrow[id].]\remove/td/tr\n;
 echo trtd width=\30%\BModel Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_model));
 echo /td/tr\n;
 echo trtd width=\30%\BYear Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_year));
 echo /td/tr\n;
 echo trtd width=\30%\BPrice Of Car: /B/tdtd$;
 printf(mysql_result($result,$count,car_price));
 echo /td/tr\n;
 echo trtd width=\30%\BVIN Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_vin));
 echo /td/trtrtd colspan=\3\hr color=\33\/td/tr\n;
 }
 // End loop and print the infamous delete button
 echo trtdinput type=\submit\ name=\delete\
 value=\delete\/td/tr/form/table;
 ?
 Here is page two...
 ?php
 print(
 table border=\0\ class=\table-body\ width=\100%\
 form name=\rem_inv\ method=\post\ action=\done2.php3\
 INPUT TYPE=\hidden\ NAME=\car_type[.$myrow[car_type].]\
 INPUT TYPE=\hidden\ NAME=\car_model[.$myrow[car_model].]\
 INPUT TYPE=\hidden\ NAME=\car_year[.$myrow[car_year].]\
 INPUT TYPE=\hidden\ NAME=\car_price[.$myrow[car_price].]\
 INPUT TYPE=\hidden\ NAME=\car_vin[.$myrow[car_vin].]\
   tr
 td align=\center\ colspan=\3\font size=\4\BConfirm Record
 Deletion/B/fonthr color=\33\/td
   /tr
   tr
 td width=\30%\BType Of Car: /B/td
  td$car_type/td // here is where it prints the word array instead of
 type of car
   /tr
   tr
 td width=\30%\BModel Of Car: /B/td
  td$car_model/td
   /tr
   tr
 td width=\30%\BYear Of Car: /B/td
  td$car_year/td
   /tr
   tr
 td width=\30%\BPrice Of Car: /B/td
  td$car_price/td
   /tr
   tr
 td width=\30%\BVIN Of Car: /B/td
  td$car_vin/td
   /tr
   tr
 td colspan=\3\hr color=\33\/td
   /tr
   tr
 tdinput type=\submit\ name=\delete\ value=\delete\/td
   /tr
 /form
 /table);
 ?

 [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Let's see what your code looks like now and where it is returning the
  word array.  That might help determine where the problem lies now.
 
  MB
 
  jas [EMAIL PROTECTED] said:
 
   Ok to this point I have been able to query a database table, display
the
   results in tables and within a form.  As of yet I have been able to
 insert
   the contents of the db query into an array for further processing.
 However,
   when I try to pass the contents of that array on to another page to
 delete
   selected records from the db it only displays the word array.  Not
 quite
   sure where I need to go from here... Any insight would be a great
help.
   Thanks in advance,
   Jas
  
  
  
   --
   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] Passing contents of array on as variables...

2002-02-25 Thread jas

Yeah, tried that and it still isnt passing the contents of the array as a
varible to the confirmation page for deletion.  I am at a loss on this one.
[EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 You didn't add the value part of the hidden element, ie.

 INPUT TYPE=\hidden\ NAME=\car_type\ value=\$myrow[car_type]\

 You were naming the field as an array with no value.

 if you want to pass this as an array of values, you would need to use:

 INPUT TYPE=\hidden\ NAME=\car_type[]\ value=\$myrow[car_type]\

 Give that a try and see if it works.

 HTH

 MB


 jas [EMAIL PROTECTED] said:

  As of right now if you run the php script and view source on the page
you
  can see that it does place the content of db table into array... ex.
  BCurrent Inventory/B/fonthr color=33/td/tr
  INPUT TYPE=hidden NAME=car_type[Ford]
  INPUT TYPE=hidden NAME=car_model[Ranger]
  INPUT TYPE=hidden NAME=car_year[1999]
  INPUT TYPE=hidden NAME=car_price[5600]
  INPUT TYPE=hidden NAME=car_vin[no vin]
  trtd width=30%BType Of Car: /B/tdtdFord/tdtdinput
  type=checkbox name=id[1]remove/td/tr
  but on the following page (after selecting items to delete) it just
displays
  the word array for each field (i.e. car_type etc.)
 
  Jas [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   Oops... yeah its a monday.
   Bjorn, I reverted back to my original code because I was getting
  confused...
   Here is page one...
   ?php
   // Database connection paramaters
   require '../path/to/db.php';
   // SQL statement to get current inventory
   $result = @mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not
   execute query, please try again later);
   // Creating table to make data look pretty
   echo table border=\0\ class=\table-body\ width=\100%\form
   name=\rem_inv\ method=\post\ action=\rem_conf.php3\
   trtd align=\center\ colspan=\3\font size=\4\BCurrent
   Inventory/B/fonthr color=\33\/td/tr;
   // Start to count number of records in selected table and loop until
done
   $count = -1;
   while ($myrow = mysql_fetch_array($result)) {
   $count ++;
   // Begin placing them into an hidden fields and then array
   echo 
   INPUT TYPE=\hidden\ NAME=\car_type[.$myrow[car_type].]\
   INPUT TYPE=\hidden\ NAME=\car_model[.$myrow[car_model].]\
   INPUT TYPE=\hidden\ NAME=\car_year[.$myrow[car_year].]\
   INPUT TYPE=\hidden\ NAME=\car_price[.$myrow[car_price].]\
   INPUT TYPE=\hidden\ NAME=\car_vin[.$myrow[car_vin].]\
   // Place items on separate cells in html table
   trtd width=\30%\BType Of Car: /B/tdtd;
   printf(mysql_result($result,$count,car_type));
   // Create checkbox so user can delete items if needed
   echo /tdtdinput type=\checkbox\
   name=\id[.$myrow[id].]\remove/td/tr\n;
   echo trtd width=\30%\BModel Of Car: /B/tdtd;
   printf(mysql_result($result,$count,car_model));
   echo /td/tr\n;
   echo trtd width=\30%\BYear Of Car: /B/tdtd;
   printf(mysql_result($result,$count,car_year));
   echo /td/tr\n;
   echo trtd width=\30%\BPrice Of Car: /B/tdtd$;
   printf(mysql_result($result,$count,car_price));
   echo /td/tr\n;
   echo trtd width=\30%\BVIN Of Car: /B/tdtd;
   printf(mysql_result($result,$count,car_vin));
   echo /td/trtrtd colspan=\3\hr
color=\33\/td/tr\n;
   }
   // End loop and print the infamous delete button
   echo trtdinput type=\submit\ name=\delete\
   value=\delete\/td/tr/form/table;
   ?
   Here is page two...
   ?php
   print(
   table border=\0\ class=\table-body\ width=\100%\
   form name=\rem_inv\ method=\post\ action=\done2.php3\
   INPUT TYPE=\hidden\ NAME=\car_type[.$myrow[car_type].]\
   INPUT TYPE=\hidden\ NAME=\car_model[.$myrow[car_model].]\
   INPUT TYPE=\hidden\ NAME=\car_year[.$myrow[car_year].]\
   INPUT TYPE=\hidden\ NAME=\car_price[.$myrow[car_price].]\
   INPUT TYPE=\hidden\ NAME=\car_vin[.$myrow[car_vin].]\
 tr
   td align=\center\ colspan=\3\font size=\4\BConfirm
Record
   Deletion/B/fonthr color=\33\/td
 /tr
 tr
   td width=\30%\BType Of Car: /B/td
td$car_type/td // here is where it prints the word array
instead of
   type of car
 /tr
 tr
   td width=\30%\BModel Of Car: /B/td
td$car_model/td
 /tr
 tr
   td width=\30%\BYear Of Car: /B/td
td$car_year/td
 /tr
 tr
   td width=\30%\BPrice Of Car: /B/td
td$car_price/td
 /tr
 tr
   td width=\30%\BVIN Of Car: /B/td
td$car_vin/td
 /tr
 tr
   td colspan=\3\hr color=\33\/td
 /tr
 tr
   tdinput type=\submit\ name=\delete\ value=\delete\/td
 /tr
   /form
   /table);
   ?
  
   [EMAIL PROTECTED] wrote in message
   [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
Let's see what your code looks like now and where it is returning
the
word array.  That might help determine where the problem lies now.
   
MB
   
jas [EMAIL PROTECTED] said:
   
 Ok to this point I have been able to query a database table,
display
  th

Re: [PHP-DB] Passing contents of array on as variables...

2002-02-25 Thread jas

$i=0;
while
($car_type[$i],$car_model[$i],$car_year[$i],$car_price[$i],$car_vin[$i]) {
$i ++;
}
Is what I added and this is what is being output to the screen at this
point...
=0; while () { ++; }
now i am still too new to php to understand why it is not putting the
contents of the array into my hidden fields like it does on my first page (i
can see them when I view source).
[EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 When you call your $car_type in the second page, you need to set a
variable
 starting at 0 and call it as $car_type[0] and loop through all of the
values
 in the array.

 ie.

 $i=0;
 while ($car_type[$i]) {

 I have added more code below that should help.

 MB


 jas [EMAIL PROTECTED] said:

  Yeah, tried that and it still isnt passing the contents of the array as
a
  varible to the confirmation page for deletion.  I am at a loss on this
one.
  [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   You didn't add the value part of the hidden element, ie.
  
   INPUT TYPE=\hidden\ NAME=\car_type\ value=\$myrow[car_type]\
  
   You were naming the field as an array with no value.
  
   if you want to pass this as an array of values, you would need to use:
  
   INPUT TYPE=\hidden\ NAME=\car_type[]\ value=\$myrow[car_type]\
  
   Give that a try and see if it works.
  
   HTH
  
   MB
  
  
   jas [EMAIL PROTECTED] said:
  
As of right now if you run the php script and view source on the
page
  you
can see that it does place the content of db table into array... ex.
BCurrent Inventory/B/fonthr color=33/td/tr
INPUT TYPE=hidden NAME=car_type[Ford]
INPUT TYPE=hidden NAME=car_model[Ranger]
INPUT TYPE=hidden NAME=car_year[1999]
INPUT TYPE=hidden NAME=car_price[5600]
INPUT TYPE=hidden NAME=car_vin[no vin]
trtd width=30%BType Of Car: /B/tdtdFord/tdtdinput
type=checkbox name=id[1]remove/td/tr
but on the following page (after selecting items to delete) it just
  displays
the word array for each field (i.e. car_type etc.)
   
Jas [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Oops... yeah its a monday.
 Bjorn, I reverted back to my original code because I was getting
confused...
 Here is page one...
 ?php
 // Database connection paramaters
 require '../path/to/db.php';
 // SQL statement to get current inventory
 $result = @mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could
not
 execute query, please try again later);
 // Creating table to make data look pretty
 echo table border=\0\ class=\table-body\
width=\100%\form
 name=\rem_inv\ method=\post\ action=\rem_conf.php3\
 trtd align=\center\ colspan=\3\font size=\4\BCurrent
 Inventory/B/fonthr color=\33\/td/tr;
 // Start to count number of records in selected table and loop
until
  done
 $count = -1;
 while ($myrow = mysql_fetch_array($result)) {
 $count ++;
 // Begin placing them into an hidden fields and then array
 echo 
 INPUT TYPE=\hidden\ NAME=\car_type[.$myrow[car_type].]\
 INPUT TYPE=\hidden\ NAME=\car_model[.$myrow[car_model].]\
 INPUT TYPE=\hidden\ NAME=\car_year[.$myrow[car_year].]\
 INPUT TYPE=\hidden\ NAME=\car_price[.$myrow[car_price].]\
 INPUT TYPE=\hidden\ NAME=\car_vin[.$myrow[car_vin].]\
 // Place items on separate cells in html table
 trtd width=\30%\BType Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_type));
 // Create checkbox so user can delete items if needed
 echo /tdtdinput type=\checkbox\
 name=\id[.$myrow[id].]\remove/td/tr\n;
 echo trtd width=\30%\BModel Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_model));
 echo /td/tr\n;
 echo trtd width=\30%\BYear Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_year));
 echo /td/tr\n;
 echo trtd width=\30%\BPrice Of Car: /B/tdtd$;
 printf(mysql_result($result,$count,car_price));
 echo /td/tr\n;
 echo trtd width=\30%\BVIN Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_vin));
 echo /td/trtrtd colspan=\3\hr
  color=\33\/td/tr\n;
 }
 // End loop and print the infamous delete button
 echo trtdinput type=\submit\ name=\delete\
 value=\delete\/td/tr/form/table;
 ?
 Here is page two...
 ?php
 print(
 table border=\0\ class=\table-body\ width=\100%\
 form name=\rem_inv\ method=\post\ action=\done2.php3\
 INPUT TYPE=\hidden\ NAME=\car_type[.$myrow[car_type].]\
 INPUT TYPE=\hidden\ NAME=\car_model[.$myrow[car_model].]\
 INPUT TYPE=\hidden\ NAME=\car_year[.$myrow[car_year].]\
 INPUT TYPE=\hidden\ NAME=\car_price[.$myrow[car_price].]\
 INPUT TYPE=\hidden\ NAME=\car_vin[.$myrow[car_vin].]\
   tr
 td align=\center\ colspan=\3\font size=\4\BConfirm
  Record
 Deletion/B/fonthr color=\33\/td
   /tr

 Here is where 

Re: [PHP-DB] Passing contents of array on as variables...

2002-02-25 Thread jas

Ok, I think I understand what you are talking about.  So now I know what I
need to accomplish, and would you happen to know of a good place to learn
about something like this?  For some reason this function keeps seeming to
elude me and if you know of a good tutorial on how to accomplish this I
would appreciate it.  Thanks again,
Jas
[EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 One problem I see is that you are sending all of the values for all of
your
 fields (except the id field) from the first page to the second page, not
just
 the ones that are checked, so even if it was working properly, you would
get
 a list of all items in the table, not just the checked items.  You need to
 send the array of id's (since this is the name for the checkbox) from the
 first page to the second one (again in the checkbox form element, you did
not
 put a value on it).

 What your first page is currently doing is pulling all of the information
out
 of the database.  Then as soon as you pull each item out, you are putting
it
 into an hidden form element array, ie.  $car_type[], $car_model[], etc.
 regardless of whether the checkbox is checked or not to pass to the next
 page.  You do not know if the checkbox is checked or not until the next
page
 when it looks at the values in the id array.  On the second page, you need
to
 look at the id array and then (through a database call) pull the row from
the
 table for each id in the array.

 HTH

 MB

 jas [EMAIL PROTECTED] said:

  $i=0;
  while
  ($car_type[$i],$car_model[$i],$car_year[$i],$car_price[$i],$car_vin[$i])
{
  $i ++;
  }
  Is what I added and this is what is being output to the screen at this
  point...
  =0; while () { ++; }
  now i am still too new to php to understand why it is not putting the
  contents of the array into my hidden fields like it does on my first
page (i
  can see them when I view source).
  [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   When you call your $car_type in the second page, you need to set a
  variable
   starting at 0 and call it as $car_type[0] and loop through all of the
  values
   in the array.
  
   ie.
  
   $i=0;
   while ($car_type[$i]) {
  
   I have added more code below that should help.
  
   MB
  
  
   jas [EMAIL PROTECTED] said:
  
Yeah, tried that and it still isnt passing the contents of the array
as
  a
varible to the confirmation page for deletion.  I am at a loss on
this
  one.
[EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 You didn't add the value part of the hidden element, ie.

 INPUT TYPE=\hidden\ NAME=\car_type\
value=\$myrow[car_type]\

 You were naming the field as an array with no value.

 if you want to pass this as an array of values, you would need to
use:

 INPUT TYPE=\hidden\ NAME=\car_type[]\
value=\$myrow[car_type]\

 Give that a try and see if it works.

 HTH

     MB


 jas [EMAIL PROTECTED] said:

  As of right now if you run the php script and view source on the
  page
you
  can see that it does place the content of db table into array...
ex.
  BCurrent Inventory/B/fonthr color=33/td/tr
  INPUT TYPE=hidden NAME=car_type[Ford]
  INPUT TYPE=hidden NAME=car_model[Ranger]
  INPUT TYPE=hidden NAME=car_year[1999]
  INPUT TYPE=hidden NAME=car_price[5600]
  INPUT TYPE=hidden NAME=car_vin[no vin]
  trtd width=30%BType Of Car:
/B/tdtdFord/tdtdinput
  type=checkbox name=id[1]remove/td/tr
  but on the following page (after selecting items to delete) it
just
displays
  the word array for each field (i.e. car_type etc.)
 
  Jas [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   Oops... yeah its a monday.
   Bjorn, I reverted back to my original code because I was
getting
  confused...
   Here is page one...
   ?php
   // Database connection paramaters
   require '../path/to/db.php';
   // SQL statement to get current inventory
   $result = @mysql_query(SELECT * FROM cur_inv,$dbh) or
die(Could
  not
   execute query, please try again later);
   // Creating table to make data look pretty
   echo table border=\0\ class=\table-body\
  width=\100%\form
   name=\rem_inv\ method=\post\ action=\rem_conf.php3\
   trtd align=\center\ colspan=\3\font
size=\4\BCurrent
   Inventory/B/fonthr color=\33\/td/tr;
   // Start to count number of records in selected table and loop
  until
done
   $count = -1;
   while ($myrow = mysql_fetch_array($result)) {
   $count ++;
   // Begin placing them into an hidden fields and then array
   echo 
   INPUT TYPE=\hidden\
NAME=\car_type[.$myrow[car_type].]\
   INPUT TYPE=\hidden\
NAME=\car_model[.$myrow[car_model].]\
   INPUT TYPE=\hidden\

Re: [PHP-DB] Passing contents of array on as variables...

2002-02-25 Thread jas

Bjorn,
I just wanted to thank you for giving me alot of insight into what I was
trying to accomplish however, due to time restraints I have decided to do it
a different way by pulling the entries into a select box that a customer can
use to delete the different items.  Once again, thanks a ton
Jas

Jas [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Ok, I think I understand what you are talking about.  So now I know what I
 need to accomplish, and would you happen to know of a good place to learn
 about something like this?  For some reason this function keeps seeming to
 elude me and if you know of a good tutorial on how to accomplish this I
 would appreciate it.  Thanks again,
 Jas
 [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  One problem I see is that you are sending all of the values for all of
 your
  fields (except the id field) from the first page to the second page, not
 just
  the ones that are checked, so even if it was working properly, you would
 get
  a list of all items in the table, not just the checked items.  You need
to
  send the array of id's (since this is the name for the checkbox) from
the
  first page to the second one (again in the checkbox form element, you
did
 not
  put a value on it).
 
  What your first page is currently doing is pulling all of the
information
 out
  of the database.  Then as soon as you pull each item out, you are
putting
 it
  into an hidden form element array, ie.  $car_type[], $car_model[], etc.
  regardless of whether the checkbox is checked or not to pass to the next
  page.  You do not know if the checkbox is checked or not until the next
 page
  when it looks at the values in the id array.  On the second page, you
need
 to
  look at the id array and then (through a database call) pull the row
from
 the
  table for each id in the array.
 
  HTH
 
  MB
 
  jas [EMAIL PROTECTED] said:
 
   $i=0;
   while
  
($car_type[$i],$car_model[$i],$car_year[$i],$car_price[$i],$car_vin[$i])
 {
   $i ++;
   }
   Is what I added and this is what is being output to the screen at this
   point...
   =0; while () { ++; }
   now i am still too new to php to understand why it is not putting the
   contents of the array into my hidden fields like it does on my first
 page (i
   can see them when I view source).
   [EMAIL PROTECTED] wrote in message
   [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
When you call your $car_type in the second page, you need to set a
   variable
starting at 0 and call it as $car_type[0] and loop through all of
the
   values
in the array.
   
ie.
   
$i=0;
while ($car_type[$i]) {
   
I have added more code below that should help.
   
MB
   
   
jas [EMAIL PROTECTED] said:
   
 Yeah, tried that and it still isnt passing the contents of the
array
 as
   a
 varible to the confirmation page for deletion.  I am at a loss on
 this
   one.
 [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  You didn't add the value part of the hidden element, ie.
 
  INPUT TYPE=\hidden\ NAME=\car_type\
 value=\$myrow[car_type]\
 
  You were naming the field as an array with no value.
 
  if you want to pass this as an array of values, you would need
to
 use:
 
  INPUT TYPE=\hidden\ NAME=\car_type[]\
 value=\$myrow[car_type]\
 
  Give that a try and see if it works.
 
  HTH
     
  MB
 
 
  jas [EMAIL PROTECTED] said:
 
   As of right now if you run the php script and view source on
the
   page
 you
   can see that it does place the content of db table into
array...
 ex.
   BCurrent Inventory/B/fonthr color=33/td/tr
   INPUT TYPE=hidden NAME=car_type[Ford]
   INPUT TYPE=hidden NAME=car_model[Ranger]
   INPUT TYPE=hidden NAME=car_year[1999]
   INPUT TYPE=hidden NAME=car_price[5600]
   INPUT TYPE=hidden NAME=car_vin[no vin]
   trtd width=30%BType Of Car:
 /B/tdtdFord/tdtdinput
   type=checkbox name=id[1]remove/td/tr
   but on the following page (after selecting items to delete) it
 just
 displays
   the word array for each field (i.e. car_type etc.)
  
   Jas [EMAIL PROTECTED] wrote in message
   [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
Oops... yeah its a monday.
Bjorn, I reverted back to my original code because I was
 getting
   confused...
Here is page one...
?php
// Database connection paramaters
require '../path/to/db.php';
// SQL statement to get current inventory
$result = @mysql_query(SELECT * FROM cur_inv,$dbh) or
 die(Could
   not
execute query, please try again later);
// Creating table to make data look pretty
echo table border=\0\ class=\table-body\
   width=\100%\form
name=\rem_inv\ method=\post\ action=\rem_conf.p

Re: [PHP-DB] Passing contents of array on as variables...

2002-02-25 Thread jas

Awesome... Thanks alot Natalie!
I actually decided to pull the contents of the table into a select list as
my option to delete the items, out of frustration.  In any event I would
love to take a look at your code to see a different approach to
accomplishing my original problem.  Thanks again everyone.
Jas
Natalie Leotta [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Jas,

 I've run into the same kind of problem with the site I'm doing for work.

 My first solution was to use the query string to pass contents of an array
 (array[0]array[1]...) but I got to the point where I was passing too much
 information and it wouldn't work.  Now I use hidden data in my form and I
 dynamically name the fields in a loop.  Then in the next page I use the
 get_post_vars and use substring so I can say if the first part of the var
 name is my array name then I get the position from the next part of the
var
 name (array0, array1...) and use that position to put it in the new array.

 I definitely wouldn't assume it's the cleanest way to do it, but I didn't
 want to use sessions (if they'd even work) and the query string had some
 problems with confidential data anyway (the users can see it and we aren't
 supposed to display data in certain situations).

 If you'd like to go with this method and want some pointers let me know
and
 I'll send you some of my code.

 Good luck!

 -Natalie

  -Original Message-
  From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]]
  Sent: Monday, February 25, 2002 1:01 PM
  To: [EMAIL PROTECTED]
  Subject: Re: [PHP-DB] Passing contents of array on as variables...
 
  Let's see what your code looks like now and where it is returning the
  word array.  That might help determine where the problem lies now.
 
  MB
 
  jas [EMAIL PROTECTED] said:
 
   Ok to this point I have been able to query a database table, display
the
   results in tables and within a form.  As of yet I have been able to
  insert
   the contents of the db query into an array for further processing.
  However,
   when I try to pass the contents of that array on to another page to
  delete
   selected records from the db it only displays the word array.  Not
  quite
   sure where I need to go from here... Any insight would be a great
help.
   Thanks in advance,
   Jas
  
  
  
   --
   PHP Database Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
 
 
 
  --
 
 
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php



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




[PHP-DB] Associating table id...

2002-02-22 Thread jas

Ok I have been working on this function to delete an item from a mysql
database and so far I have not had any success.  Here is the problem I am
having (after alot of headaches), I need to be able to associate a checkbox
to a record or a set of records... For example, page 1 queries a database
and pulls the results into a table and in that table is a form with a
checkbox for each record pulled from said database... code is here...
?php
require '../path/to/db.php'; //connection script
$result = @mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not
execute query, please try again later);
echo table border=\0\ class=\table-body\ width=\100%\form
name=\rem_inv\ method=\post\ action=\done2.php3\
trtd align=\center\ colspan=\3\font size=\4\BCurrent
Inventory/B/fonthr color=\33\/td/tr;
$count = -1;
while ($myrow = mysql_fetch_row($result)) {
$count ++;
echo trtd width=\30%\BType Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_type));
echo /tdtdinput type=\checkbox\ name=\id\
value=\id\remove/td/tr\n;
echo rest of fields in database;
}
echo trtdinput type=\submit\ name=\delete\
value=\delete\/td/tr/form/table;
?
Now what I need to do is to have the checkbox item be associated with all
one record set.  Table structure is here
-
| id | car_model | car_type | car_year | car_price | car_vin | dlr_num |
-
| 0 | ford   | bronco| 1997  | 6700   | vin#   | dlr
# |
-
etc. etc.
From the first page it links to page which queries the db and deletes the
selected records... however, I am not able to get the id to be associated
with the records in the table... the deletion script is as follows
?php
require '../path/to/db.php';
$table_name = cur_inv;
$sql = DELETE FROM $table_name WHERE id = '$id';
echo($sql);
$result = mysql_query($sql,$dbh) or die(mysql_error());
print(record deleted);
?
If anyone has ever run into this please help... I am still fairly new to php
and mysql and there is definately something I am missing here and I think
its because I need to associate the checkbox with the id and the id field
from the database does not seem to be linked to the rest of the record in
said fields...
Thanks in advance,
Jas
And yes I do know I posted the same question yesterday... I still cannot
figure this one out.





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




[PHP-DB] Re: Associating table id...

2002-02-22 Thread jas

I sincerely wish someone could give me some insight as to what I am doing
wrong here.  I have been scouring php.net for any website that has a good
tutorial or article on how to pass the variables from page to page while
assigning a variable a whole record set from a database.  If anyone has run
into the same problem that I am having please give me a shove in the right
direction.  Thanks in advance,
Jas
Jas [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Ok I have been working on this function to delete an item from a mysql
 database and so far I have not had any success.  Here is the problem I am
 having (after alot of headaches), I need to be able to associate a
checkbox
 to a record or a set of records... For example, page 1 queries a database
 and pulls the results into a table and in that table is a form with a
 checkbox for each record pulled from said database... code is here...
 ?php
 require '../path/to/db.php'; //connection script
 $result = @mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not
 execute query, please try again later);
 echo table border=\0\ class=\table-body\ width=\100%\form
 name=\rem_inv\ method=\post\ action=\done2.php3\
 trtd align=\center\ colspan=\3\font size=\4\BCurrent
 Inventory/B/fonthr color=\33\/td/tr;
 $count = -1;
 while ($myrow = mysql_fetch_row($result)) {
 $count ++;
 echo trtd width=\30%\BType Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_type));
 echo /tdtdinput type=\checkbox\ name=\id\
 value=\id\remove/td/tr\n;
 echo rest of fields in database;
 }
 echo trtdinput type=\submit\ name=\delete\
 value=\delete\/td/tr/form/table;
 ?
 Now what I need to do is to have the checkbox item be associated with all
 one record set.  Table structure is here
 -
 | id | car_model | car_type | car_year | car_price | car_vin | dlr_num |
 -
 | 0 | ford   | bronco| 1997  | 6700   | vin#   |
dlr
 # |
 -
 etc. etc.
 From the first page it links to page which queries the db and deletes the
 selected records... however, I am not able to get the id to be
associated
 with the records in the table... the deletion script is as follows
 ?php
 require '../path/to/db.php';
 $table_name = cur_inv;
 $sql = DELETE FROM $table_name WHERE id = '$id';
 echo($sql);
 $result = mysql_query($sql,$dbh) or die(mysql_error());
 print(record deleted);
 ?
 If anyone has ever run into this please help... I am still fairly new to
php
 and mysql and there is definately something I am missing here and I think
 its because I need to associate the checkbox with the id and the id field
 from the database does not seem to be linked to the rest of the record in
 said fields...
 Thanks in advance,
 Jas
 And yes I do know I posted the same question yesterday... I still cannot
 figure this one out.







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




[PHP-DB] Array HELL!!!!

2002-02-22 Thread jas

I don't know what it is but I am having a hell of a time trying to get some
results of a query setup into an array or variable (too much of a newbie to
know which) that can be passed to a confirmation page before deleting the
record from a table.  I have given up working on this but for those of you
that want to finish it here is the code and the table structure...

[Table Structure]
id int(30) DEFAULT '0' NOT NULL auto_increment,
   car_type varchar(30),
   car_model varchar(30),
   car_year varchar(15),
   car_price varchar(15),
   car_vin varchar(25),
   dlr_num varchar(25),
   PRIMARY KEY (id)

[Page 1 - Queries DB table for records]
?php
require '../path/to/db.php';
$result = @mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not
execute query, please try again later);
echo table border=\0\ class=\table-body\ width=\100%\form
name=\rem_inv\ method=\post\ action=\rem_conf.php3\
trtd align=\center\ colspan=\3\font size=\4\BCurrent
Inventory/B/fonthr color=\33\/td/tr;
$count = -1;
while ($myrow = mysql_fetch_array($result)) {
 $id = $row[id];
 $car_type = $row[car_type];
 $car_model = $row[car_model];
 $car_year = $row[car_year];
 $car_price = $row[car_price];
 $car_vin = $row[car_vin];
 $count ++;
echo trtd width=\30%\BType Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_type));
echo /tdtdinput type=\checkbox\ name=\id[]\
value=\.$myrow[id].\remove/td/tr\n;
echo trtd width=\30%\BModel Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_model));
echo /td/tr\n;
echo trtd width=\30%\BYear Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_year));
echo /td/tr\n;
echo trtd width=\30%\BPrice Of Car: /B/tdtd$;
printf(mysql_result($result,$count,car_price));
echo /td/tr\n;
echo trtd width=\30%\BVIN Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_vin));
echo /td/trtrtd colspan=\3\hr color=\33\/td/tr\n;
}
echo trtdinput type=\submit\ name=\delete\
value=\delete\/td/tr/form/table;
?

[Page 2 - Takes records and confirms which ones to be deleted]
?php
print(
table border=\0\ class=\table-body\ width=\100%\
form name=\rem_inv\ method=\post\ action=\done2.php3\
INPUT TYPE=\hidden\ NAME=\id\ VALUE=\$id\
INPUT TYPE=\hidden\ NAME=\car_type\ VALUE=\$car_type\
INPUT TYPE=\hidden\ NAME=\car_model\ VALUE=\$car_model\
INPUT TYPE=\hidden\ NAME=\car_year\ VALUE=\$car_year\
INPUT TYPE=\hidden\ NAME=\car_price\ VALUE=\$car_price\
INPUT TYPE=\hidden\ NAME=\car_vin\ VALUE=\$car_vin\
  tr
td align=\center\ colspan=\3\font size=\4\BConfirm Record
Deletion/B/fonthr color=\33\/td
  /tr
  tr
td width=\30%\BType Of Car: /B/td
 td$car_type/td
  /tr
  tr
td width=\30%\BModel Of Car: /B/td
 td$car_model/td
  /tr
  tr
td width=\30%\BYear Of Car: /B/td
 td$car_year/td
  /tr
  tr
td width=\30%\BPrice Of Car: /B/td
 td$car_price/td
  /tr
  tr
td width=\30%\BVIN Of Car: /B/td
 td$car_vin/td
  /tr
  tr
td colspan=\3\hr color=\33\/td
  /tr
  tr
tdinput type=\submit\ name=\delete\ value=\delete\/td
  /tr
/form
/table);
?

[Page 3 - Connects to DB and deletes selected records]
?php
require '../path/to/db.php';
$table_name = cur_inv;
$sql = DELETE FROM $table_name WHERE id = '$id';
echo($sql);
$result = mysql_query($sql,$dbh) or die(mysql_error());
print(body bgcolor=\ff9900\p class=\done\You have successfully
removed your items from the database.);
?

If anyone has the time to finish it or give me some pointers on what the
hell I am doing wrong please let me know, I would be very glad to hear your
opinion and the correct way to accomplish this.  (And, yes I went through
just about every tutorial I could find on how to delete records, which by
the way did nothing for putting the results of a select statement into an
array or variable for futher processing.) Have a good weekend everyone!!!
Pissed and frustrated...
Jas



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




Re: [PHP-DB] Array HELL!!!!

2002-02-22 Thread jas

Well ok now that I know it isn't an array I am having problems with, how
exactly am I supposed to create a variable (that can be passed to another
page) from a selected set of records?
Thanks again for the politeness,
Jas
Spyproductions Support Team [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

 That's not Array Hell, this is Array Hell:

 $Hell = array(satan,fire,brimstone);

 -Mike


  -Original Message-
  From: jas [mailto:[EMAIL PROTECTED]]
  Sent: Friday, February 22, 2002 4:37 AM
  To: [EMAIL PROTECTED]
  Subject: [PHP-DB] Array HELL
 
 
  I don't know what it is but I am having a hell of a time trying
  to get some
  results of a query setup into an array or variable (too much of a
  newbie to
  know which) that can be passed to a confirmation page before deleting
the
  record from a table.  I have given up working on this but for those of
you
  that want to finish it here is the code and the table structure...
 
  [Table Structure]
  id int(30) DEFAULT '0' NOT NULL auto_increment,
 car_type varchar(30),
 car_model varchar(30),
 car_year varchar(15),
 car_price varchar(15),
 car_vin varchar(25),
 dlr_num varchar(25),
 PRIMARY KEY (id)
 
  [Page 1 - Queries DB table for records]
  ?php
  require '../path/to/db.php';
  $result = @mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not
  execute query, please try again later);
  echo table border=\0\ class=\table-body\ width=\100%\form
  name=\rem_inv\ method=\post\ action=\rem_conf.php3\
  trtd align=\center\ colspan=\3\font size=\4\BCurrent
  Inventory/B/fonthr color=\33\/td/tr;
  $count = -1;
  while ($myrow = mysql_fetch_array($result)) {
   $id = $row[id];
   $car_type = $row[car_type];
   $car_model = $row[car_model];
   $car_year = $row[car_year];
   $car_price = $row[car_price];
   $car_vin = $row[car_vin];
   $count ++;
  echo trtd width=\30%\BType Of Car: /B/tdtd;
  printf(mysql_result($result,$count,car_type));
  echo /tdtdinput type=\checkbox\ name=\id[]\
  value=\.$myrow[id].\remove/td/tr\n;
  echo trtd width=\30%\BModel Of Car: /B/tdtd;
  printf(mysql_result($result,$count,car_model));
  echo /td/tr\n;
  echo trtd width=\30%\BYear Of Car: /B/tdtd;
  printf(mysql_result($result,$count,car_year));
  echo /td/tr\n;
  echo trtd width=\30%\BPrice Of Car: /B/tdtd$;
  printf(mysql_result($result,$count,car_price));
  echo /td/tr\n;
  echo trtd width=\30%\BVIN Of Car: /B/tdtd;
  printf(mysql_result($result,$count,car_vin));
  echo /td/trtrtd colspan=\3\hr
color=\33\/td/tr\n;
  }
  echo trtdinput type=\submit\ name=\delete\
  value=\delete\/td/tr/form/table;
  ?
 
  [Page 2 - Takes records and confirms which ones to be deleted]
  ?php
  print(
  table border=\0\ class=\table-body\ width=\100%\
  form name=\rem_inv\ method=\post\ action=\done2.php3\
  INPUT TYPE=\hidden\ NAME=\id\ VALUE=\$id\
  INPUT TYPE=\hidden\ NAME=\car_type\ VALUE=\$car_type\
  INPUT TYPE=\hidden\ NAME=\car_model\ VALUE=\$car_model\
  INPUT TYPE=\hidden\ NAME=\car_year\ VALUE=\$car_year\
  INPUT TYPE=\hidden\ NAME=\car_price\ VALUE=\$car_price\
  INPUT TYPE=\hidden\ NAME=\car_vin\ VALUE=\$car_vin\
tr
  td align=\center\ colspan=\3\font size=\4\BConfirm
Record
  Deletion/B/fonthr color=\33\/td
/tr
tr
  td width=\30%\BType Of Car: /B/td
   td$car_type/td
/tr
tr
  td width=\30%\BModel Of Car: /B/td
   td$car_model/td
/tr
tr
  td width=\30%\BYear Of Car: /B/td
   td$car_year/td
/tr
tr
  td width=\30%\BPrice Of Car: /B/td
   td$car_price/td
/tr
tr
  td width=\30%\BVIN Of Car: /B/td
   td$car_vin/td
/tr
tr
  td colspan=\3\hr color=\33\/td
/tr
tr
  tdinput type=\submit\ name=\delete\ value=\delete\/td
/tr
  /form
  /table);
  ?
 
  [Page 3 - Connects to DB and deletes selected records]
  ?php
  require '../path/to/db.php';
  $table_name = cur_inv;
  $sql = DELETE FROM $table_name WHERE id = '$id';
  echo($sql);
  $result = mysql_query($sql,$dbh) or die(mysql_error());
  print(body bgcolor=\ff9900\p class=\done\You have successfully
  removed your items from the database.);
  ?
 
  If anyone has the time to finish it or give me some pointers on what the
  hell I am doing wrong please let me know, I would be very glad to
  hear your
  opinion and the correct way to accomplish this.  (And, yes I went
through
  just about every tutorial I could find on how to delete records, which
by
  the way did nothing for putting the results of a select statement into
an
  array or variable for futher processing.) Have a good weekend
everyone!!!
  Pissed and frustrated...
  Jas
 
 
 
  --
  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] Parse Error

2002-02-21 Thread jas

I hate to post this again but I have looked in a couple of php and mysql
books but cannot seem to figure this one out.  I am getting a parse error
when trying to use php to delete records from a table.  The error I am
recieving is as follows

Parse error: parse error in /path/to/php/done2.php3 on line 22

Here is the file that is giving me the error, any help would be great... I
think that my problem is that I left out a variable to hold the $cars data
but I am not sure.  Here is the code...

$db_name = test;
$table_name = inventory;
$connection = @mysql_connect(localhost, root, password) or die
(Could
not connect to database.  Please try again later.);
$db = @mysql_select_db($db_name,$connection) or die (Could not select
database table. Please try again later.);
$sql = DELETE FROM $table_name WHERE $cars =
\$car_type\,\$car_model\,\$car_year\,\$car_price\,\$car_vin\,\$dl
r_num\);
$result = @mysql_query($sql, $connection) or die (Could not execute
query.

Any insight would be great... thanks again.
Jas




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




Re: [PHP-DB] Parse Error

2002-02-21 Thread jas

Here is the code from the file that queries the db and pulls the current
contents of the db and provides a check box form for each record to delete
the items in the db.  I dont know if this will help but like I said before
any insight would be great.  Thanks in advance.
Jas

?php
require '../scripts/db.php';
$result = mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not
execute query, please try again later);
echo table border=\0\ class=\table-body\ width=\100%\form
name=\rem_inv\ method=\post\ action=\done2.php3\
trtd align=\center\ colspan=\3\font size=\4\BCurrent
Inventory/B/fonthr color=\33\/td/tr;
$count = -1;
while ($myrow = mysql_fetch_row($result)) {
$count ++;
echo trtd width=\30%\BType Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_type));
echo /tdtdinput type=\checkbox\ name=\cars\
value=\checkbox\remove/td
/tr\n;
echo trtd width=\30%\BModel Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_model));
echo /td/tr\n;
echo trtd width=\30%\BYear Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_year));
echo /td/tr\n;
echo trtd width=\30%\BPrice Of Car: /B/tdtd$;
printf(mysql_result($result,$count,car_price));
echo /td/tr\n;
echo trtd width=\30%\BVIN Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_vin));
echo /td/trtrtd colspan=\3\hr color=\33\/td/tr\n;
}
echo trtdinput type=\submit\ name=\delete\
value=\delete\/td/tr/form/table;
?

After this file is pulled and the user selects which record to delete it
jumps to the other snippit of code in done2.php3 which is

  $db_name = test;
  $table_name = inventory;
  $connection = @mysql_connect(localhost, root, password) or die
  (Could
  not connect to database.  Please try again later.);
  $db = @mysql_select_db($db_name,$connection) or die (Could not select
  database table. Please try again later.);
  $sql = DELETE FROM $table_name WHERE $cars =
 
\$car_type\,\$car_model\,\$car_year\,\$car_price\,\$car_vin\,\$dl
  r_num\);
  $result = @mysql_query($sql, $connection) or die (Could not execute
  query.
 
  Any insight would be great... thanks again.
  Jas
 
 
 
 
  --
  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] Parse Error

2002-02-21 Thread jas

Here is the dump for the cars table...
test (
   id varchar(30) NOT NULL auto_increment,
   car_type varchar(30),
   car_model varchar(30),
   car_year varchar(15),
   car_price varchar(15),
   car_vin varchar(25),
   dlr_num varchar(25),
   PRIMARY KEY (id),
   KEY id (id)
test VALUES ('1', 'Ford', 'Bronco', '1969', '4500', 'vin897655', 'none');

Sorry about that... still a bit of a newbie here. =)
Jas

Gurhan Ozen [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Jas..
 First of all you don't have the variable $cars assigned..
 Second of all, we still don't know what the test table looks like? Does
it
 only have one column with all the infos about cars populated in it???

 Gurhan


 -Original Message-
 From: jas [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, February 21, 2002 12:48 AM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] Parse Error


 Here is the code from the file that queries the db and pulls the current
 contents of the db and provides a check box form for each record to delete
 the items in the db.  I dont know if this will help but like I said before
 any insight would be great.  Thanks in advance.
 Jas

 ?php
 require '../scripts/db.php';
 $result = mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not
 execute query, please try again later);
 echo table border=\0\ class=\table-body\ width=\100%\form
 name=\rem_inv\ method=\post\ action=\done2.php3\
 trtd align=\center\ colspan=\3\font size=\4\BCurrent
 Inventory/B/fonthr color=\33\/td/tr;
 $count = -1;
 while ($myrow = mysql_fetch_row($result)) {
 $count ++;
 echo trtd width=\30%\BType Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_type));
 echo /tdtdinput type=\checkbox\ name=\cars\
 value=\checkbox\remove/td
 /tr\n;
 echo trtd width=\30%\BModel Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_model));
 echo /td/tr\n;
 echo trtd width=\30%\BYear Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_year));
 echo /td/tr\n;
 echo trtd width=\30%\BPrice Of Car: /B/tdtd$;
 printf(mysql_result($result,$count,car_price));
 echo /td/tr\n;
 echo trtd width=\30%\BVIN Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_vin));
 echo /td/trtrtd colspan=\3\hr color=\33\/td/tr\n;
 }
 echo trtdinput type=\submit\ name=\delete\
 value=\delete\/td/tr/form/table;
 ?

 After this file is pulled and the user selects which record to delete it
 jumps to the other snippit of code in done2.php3 which is

   $db_name = test;
   $table_name = inventory;
   $connection = @mysql_connect(localhost, root, password) or die
   (Could
   not connect to database.  Please try again later.);
   $db = @mysql_select_db($db_name,$connection) or die (Could not
select
   database table. Please try again later.);
   $sql = DELETE FROM $table_name WHERE $cars =
  

\$car_type\,\$car_model\,\$car_year\,\$car_price\,\$car_vin\,\$dl
   r_num\);
   $result = @mysql_query($sql, $connection) or die (Could not execute
   query.
  
   Any insight would be great... thanks again.
   Jas
  
  
  
  
   --
   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] Parse Error

2002-02-21 Thread jas

Could you maybe give me an example of how to associate the checkbox with the
id?  Thanks again,
Jas
Gurhan Ozen [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Ok then it sure will not work.. because you have :

 DELETE FROM $table_name WHERE $cars

=\$car_type\,\$car_model\,\$car_year\,\$car_price\,\$car_vin\,\$d
 lr_num\);

 1- $cars is set to the value checkbox which doesn't exist in your test
 table
 2- The end of the statement $dlr_num\);  is not right , that
 parenthesis isn't supposed to be there
 3- The delete statement is wrong...You are storing all that info in the
 separate fields but you are giving all combined as a condition in only one
 field ($cars).
 3- Rewrite your delete statement to delete the rows identified by the id
 column as DELETE FROM $table WHERE id ='id'; Of course in the page where
 you list the cars to be deleted associate each checkbox with the car's id.

 Hope this helps..

 Gurhan


 -Original Message-
 From: jas [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, February 21, 2002 1:02 AM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] Parse Error


 Here is the dump for the cars table...
 test (
id varchar(30) NOT NULL auto_increment,
car_type varchar(30),
car_model varchar(30),
car_year varchar(15),
car_price varchar(15),
car_vin varchar(25),
dlr_num varchar(25),
PRIMARY KEY (id),
KEY id (id)
 test VALUES ('1', 'Ford', 'Bronco', '1969', '4500', 'vin897655', 'none');

 Sorry about that... still a bit of a newbie here. =)
 Jas

 Gurhan Ozen [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Jas..
  First of all you don't have the variable $cars assigned..
  Second of all, we still don't know what the test table looks like?
Does
 it
  only have one column with all the infos about cars populated in it???
 
  Gurhan
 
 
  -Original Message-
  From: jas [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, February 21, 2002 12:48 AM
  To: [EMAIL PROTECTED]
  Subject: Re: [PHP-DB] Parse Error
 
 
  Here is the code from the file that queries the db and pulls the current
  contents of the db and provides a check box form for each record to
delete
  the items in the db.  I dont know if this will help but like I said
before
  any insight would be great.  Thanks in advance.
  Jas
 
  ?php
  require '../scripts/db.php';
  $result = mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not
  execute query, please try again later);
  echo table border=\0\ class=\table-body\ width=\100%\form
  name=\rem_inv\ method=\post\ action=\done2.php3\
  trtd align=\center\ colspan=\3\font size=\4\BCurrent
  Inventory/B/fonthr color=\33\/td/tr;
  $count = -1;
  while ($myrow = mysql_fetch_row($result)) {
  $count ++;
  echo trtd width=\30%\BType Of Car: /B/tdtd;
  printf(mysql_result($result,$count,car_type));
  echo /tdtdinput type=\checkbox\ name=\cars\
  value=\checkbox\remove/td
  /tr\n;
  echo trtd width=\30%\BModel Of Car: /B/tdtd;
  printf(mysql_result($result,$count,car_model));
  echo /td/tr\n;
  echo trtd width=\30%\BYear Of Car: /B/tdtd;
  printf(mysql_result($result,$count,car_year));
  echo /td/tr\n;
  echo trtd width=\30%\BPrice Of Car: /B/tdtd$;
  printf(mysql_result($result,$count,car_price));
  echo /td/tr\n;
  echo trtd width=\30%\BVIN Of Car: /B/tdtd;
  printf(mysql_result($result,$count,car_vin));
  echo /td/trtrtd colspan=\3\hr
color=\33\/td/tr\n;
  }
  echo trtdinput type=\submit\ name=\delete\
  value=\delete\/td/tr/form/table;
  ?
 
  After this file is pulled and the user selects which record to delete it
  jumps to the other snippit of code in done2.php3 which is
 
$db_name = test;
$table_name = inventory;
$connection = @mysql_connect(localhost, root, password) or die
(Could
not connect to database.  Please try again later.);
$db = @mysql_select_db($db_name,$connection) or die (Could not
 select
database table. Please try again later.);
$sql = DELETE FROM $table_name WHERE $cars =
   
 

\$car_type\,\$car_model\,\$car_year\,\$car_price\,\$car_vin\,\$dl
r_num\);
$result = @mysql_query($sql, $connection) or die (Could not execute
query.
   
Any insight would be great... thanks again.
Jas
   
   
   
   
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
   
  
  
  
   --
  
  
  
 
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 



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




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




[PHP-DB] debugging?

2002-02-21 Thread jas

Can someone tell me how I can find out why I am getting errors executing
queries when I try to delete items from a table?  I have 2 files...
file 1. - Queries database, displays results with option to delete record
using a check box, code is as follows...
?php
require '../scripts/db.php';
$result = mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not
execute query, please try again later);
echo table border=\0\ class=\table-body\ width=\100%\form
name=\rem_inv\ method=\post\ action=\done2.php3\
trtd align=\center\ colspan=\3\font size=\4\BCurrent
Inventory/B/fonthr color=\33\/td/tr;
$count = -1;
while ($myrow = mysql_fetch_row($result)) {
$count ++;
echo trtd width=\30%\BType Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_type));
echo /tdtdinput type=\checkbox\ name=\cars\
value=\.$myrow[id].\remove/td
/tr\n;
echo trtd width=\30%\BModel Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_model));
echo /td/tr\n;
echo trtd width=\30%\BYear Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_year));
echo /td/tr\n;
echo trtd width=\30%\BPrice Of Car: /B/tdtd$;
printf(mysql_result($result,$count,car_price));
echo /td/tr\n;
echo trtd width=\30%\BVIN Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_vin));
echo /td/trtrtd colspan=\3\hr color=\33\/td/tr\n;
}
echo trtdinput type=\submit\ name=\delete\
value=\delete\/td/tr/form/table;
?
file 2. - takes variable of checkbox and then queries db trying to delete
any record based on the id.  code is as follows...
?php
require '../scripts/db.php';
$sql = @mysql_query(DELETE FROM $table_name WHERE $id = 'id',$dbh) or
die(Could not execute query, please try again later);
print(changes made);
?
I have been trying everything under the sun and cannot get this to work.
please help.
Jas



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




[PHP-DB] Errors Deleting...

2002-02-21 Thread jas

Can someone tell me how I can find out why I am getting errors executing
queries when I try to delete items from a table?  I have 2 files...
file 1. - Queries database, displays results with option to delete record
using a check box, code is as follows...
?php
require '../scripts/db.php';
$result = mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not
execute query, please try again later);
echo table border=\0\ class=\table-body\ width=\100%\form
name=\rem_inv\ method=\post\ action=\done2.php3\
trtd align=\center\ colspan=\3\font size=\4\BCurrent
Inventory/B/fonthr color=\33\/td/tr;
$count = -1;
while ($myrow = mysql_fetch_row($result)) {
$count ++;
echo trtd width=\30%\BType Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_type));
echo /tdtdinput type=\checkbox\ name=\cars\
value=\.$myrow[id].\remove/td
/tr\n;
echo trtd width=\30%\BModel Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_model));
echo /td/tr\n;
echo trtd width=\30%\BYear Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_year));
echo /td/tr\n;
echo trtd width=\30%\BPrice Of Car: /B/tdtd$;
printf(mysql_result($result,$count,car_price));
echo /td/tr\n;
echo trtd width=\30%\BVIN Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_vin));
echo /td/trtrtd colspan=\3\hr color=\33\/td/tr\n;
}
echo trtdinput type=\submit\ name=\delete\
value=\delete\/td/tr/form/table;
?
file 2. - takes variable of checkbox and then queries db trying to delete
any record based on the id.  code is as follows...
?php
require '../scripts/db.php';
$table_name = cur_inv;
$sql = @mysql_query(DELETE FROM $table_name WHERE $id = 'id',$dbh) or
die(Could not execute query, please try again later);
print(changes made);
?
I have been trying everything under the sun and cannot get this to work.
please help.
Jas





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




Re: [PHP-DB] Errors Deleting...

2002-02-21 Thread jas

I wish I could get this to work... it has not been able to work at all.  I
made the changes you have suggested and tried different variations
concerning the results items and so far no dice.
Here is my delete sql statement as of right now...

?php
require '../scripts/db.php';
$table_name = cur_inv;
$sql = DELETE FROM $table_name WHERE $id = 'id';
$result = @mysql_query($sql, $dbh) or die(Could not execute query, please
try again later);
?

I keep getting an error on the result portion, I have double, and triple
checked my table names, my db connection (which has error checking on it so
I know I am connecting fine).  I am wondering would it be beneficial to
actually put a select statement in for the database table?  I would think
declaring the variable would work fine.  In any event I also changed the
checkbox name to id to match the variable in the delete statement.  For
readability sake here is the form code as well

?php
require '../scripts/db.php';
$result = mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not
execute query, please try again later);
echo table border=\0\ class=\table-body\ width=\100%\form
name=\rem_inv\ method=\post\ action=\done2.php3\
trtd align=\center\ colspan=\3\font size=\4\BCurrent
Inventory/B/fonthr color=\33\/td/tr;
$count = -1;
while ($myrow = mysql_fetch_row($result)) {
$count ++;
echo trtd width=\30%\BType Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_type));
echo /tdtdinput type=\checkbox\ name=\id\
value=\.$myrow[id].\remove/td
/tr\n;
echo rest of table and cell output;
}
echo trtdinput type=\submit\ name=\delete\
value=\delete\/td/tr/form/table;
?

Gurhan Ozen [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Jas,
 You still have cars as your checkbox name.. change it to id..
 and make sure that you assign $table_name to the table name you want to
 delete from in your done2.php3 file..

 Gurhan

 -Original Message-
 From: jas [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, February 21, 2002 3:28 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Errors Deleting...


 Can someone tell me how I can find out why I am getting errors executing
 queries when I try to delete items from a table?  I have 2 files...
 file 1. - Queries database, displays results with option to delete record
 using a check box, code is as follows...
 ?php
 require '../scripts/db.php';
 $result = mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not
 execute query, please try again later);
 echo table border=\0\ class=\table-body\ width=\100%\form
 name=\rem_inv\ method=\post\ action=\done2.php3\
 trtd align=\center\ colspan=\3\font size=\4\BCurrent
 Inventory/B/fonthr color=\33\/td/tr;
 $count = -1;
 while ($myrow = mysql_fetch_row($result)) {
 $count ++;
 echo trtd width=\30%\BType Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_type));
 echo /tdtdinput type=\checkbox\ name=\cars\
 value=\.$myrow[id].\remove/td
 /tr\n;
 echo trtd width=\30%\BModel Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_model));
 echo /td/tr\n;
 echo trtd width=\30%\BYear Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_year));
 echo /td/tr\n;
 echo trtd width=\30%\BPrice Of Car: /B/tdtd$;
 printf(mysql_result($result,$count,car_price));
 echo /td/tr\n;
 echo trtd width=\30%\BVIN Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_vin));
 echo /td/trtrtd colspan=\3\hr color=\33\/td/tr\n;
 }
 echo trtdinput type=\submit\ name=\delete\
 value=\delete\/td/tr/form/table;
 ?
 file 2. - takes variable of checkbox and then queries db trying to delete
 any record based on the id.  code is as follows...
 ?php
 require '../scripts/db.php';
 $table_name = cur_inv;
 $sql = @mysql_query(DELETE FROM $table_name WHERE $id = 'id',$dbh) or
 die(Could not execute query, please try again later);
 print(changes made);
 ?
 I have been trying everything under the sun and cannot get this to work.
 please help.
 Jas





 --
 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] debugging?

2002-02-21 Thread jas

Ok now that I can see the error message how can I fix it... the syntax looks
correct and the error I am recieving is as follows

You have an error in your SQL syntax near '= 'id'' at line 1

And this is my statement,
$sql = mysql_query(DELETE FROM $table_name WHERE $id = 'id',$dbh) or
die(mysql_error());
Is there anywhere on php.net or mysql.org that give exact error meanings?
Thanks again,
Jas
Olinux [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 jas,

 Try this:
 - Remove the @, it suppresses the error
 - change die(Could not execute query, please try
 again later); to die(mysql_error());


 $sql = mysql_query(DELETE FROM $table_name WHERE $id
 = 'id',$dbh) or
 die(mysql_error());

 olinux

 --- jas [EMAIL PROTECTED] wrote:
  Can someone tell me how I can find out why I am
  getting errors executing
  queries when I try to delete items from a table?  I
  have 2 files...
  file 1. - Queries database, displays results with
  option to delete record
  using a check box, code is as follows...
  ?php
 snip


 __
 Do You Yahoo!?
 Yahoo! Sports - Coverage of the 2002 Olympic Games
 http://sports.yahoo.com



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




Re: [PHP-DB] debugging?

2002-02-21 Thread jas

Ok now that the sql statement is working I am getting an error on my result
function... here is the result function
$result = mysql_query($sql, $dbh) or die(mysql_error());
and here is the error I am recieving
You have an error in your SQL syntax near '1, 1' at line 1
I dont know enough about php and mysql to understand what this means... is
there some kind of chart or definitions for error messages?  I tried looking
on mysql.org and couldnt find anything specific. In any event, thanks in
advance.
Jas
[EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Here is what your delete statement should look like:

 $sql = mysql_query(DELETE FROM $table_name WHERE id = '$id',$dbh) or
 die(mysql_error());

 Note the field name without the $ in front of it and the variable you are
 comparing it to with the $.

 One other note, in your table, you have id as a varchar(30)
auto_increment.
 As far as I know, auto_increment can only be used on INT() field types,
 unless I missed something there.  If you do end up changing the field type
to
 INT, make sure you take the '' around the $id out.

 HTH

 MB




 jas [EMAIL PROTECTED] said:

  Ok now that I can see the error message how can I fix it... the syntax
looks
  correct and the error I am recieving is as follows
 
  You have an error in your SQL syntax near '= 'id'' at line 1
 
  And this is my statement,
  $sql = mysql_query(DELETE FROM $table_name WHERE $id = 'id',$dbh) or
  die(mysql_error());
  Is there anywhere on php.net or mysql.org that give exact error
meanings?
  Thanks again,
  Jas
  Olinux [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   jas,
  
   Try this:
   - Remove the @, it suppresses the error
   - change die(Could not execute query, please try
   again later); to die(mysql_error());
  
  
   $sql = mysql_query(DELETE FROM $table_name WHERE $id
   = 'id',$dbh) or
   die(mysql_error());
  
   olinux
  
   --- jas [EMAIL PROTECTED] wrote:
Can someone tell me how I can find out why I am
getting errors executing
queries when I try to delete items from a table?  I
have 2 files...
file 1. - Queries database, displays results with
option to delete record
using a check box, code is as follows...
?php
   snip
  
  
   __
   Do You Yahoo!?
   Yahoo! Sports - Coverage of the 2002 Olympic Games
   http://sports.yahoo.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-DB] Deleting records...

2002-02-20 Thread jas

Ok I am trying to delete records from a database using an html form.  I have
2 files, file one = remove.php3 which queries the database table and
displays the current contents.  Code is as follows.
?php
require '../scripts/db.php';
$result = mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not
execute query, please try again later);
echo table border=\0\ class=\table-body\ width=\100%\form
name=\rem_inv\ method=\post\ action=\done2.php3\
trtd align=\center\ colspan=\3\font size=\4\BCurrent
Inventory/B/fonthr color=\33\/td/tr;
$count = -1;
while ($myrow = mysql_fetch_row($result)) {
$count ++;
echo trtd width=\30%\BType Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_type));
echo /tdtdinput type=\checkbox\ name=\cars\
value=\checkbox\remove/td
/tr\n;
echo trtd width=\30%\BModel Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_model));
echo /td/tr\n;
echo trtd width=\30%\BYear Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_year));
echo /td/tr\n;
echo trtd width=\30%\BPrice Of Car: /B/tdtd$;
printf(mysql_result($result,$count,car_price));
echo /td/tr\n;
echo trtd width=\30%\BVIN Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_vin));
echo /td/trtrtd colspan=\3\hr color=\33\/td/tr\n;
}
echo trtdinput type=\submit\ name=\delete\
value=\delete\/td/tr/form/table;
?
Once it queries the database it gives the user an option to check the
checkbox and delete that record.  Here is the done2.php3 page that actually
contains the delete sql statement
$db_name = test;
$table_name = inventory;
$connection = @mysql_connect(localhost, root, password) or die (Could
not connect to database.  Please try again later.);
$db = @mysql_select_db($db_name,$connection) or die (Could not select
database table. Please try again later.);
$sql = DELETE FROM $table_name WHERE $cars =
\$car_type\,\$car_model\,\$car_year\,\$car_price\,\$car_vin\,\$dl
r_num\);
$result = @mysql_query($sql, $connection) or die (Could not execute query.
Please try again later.);



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




[PHP-DB] Re: Deleting records...

2002-02-20 Thread jas

I forgot to include the error message I am recieving when trying to remove
records using the check box.
Parse error: parse error in /path/to/php/done2.php3 on line 22
Thanks in advance.
Jas

Jas [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Ok I am trying to delete records from a database using an html form.  I
have
 2 files, file one = remove.php3 which queries the database table and
 displays the current contents.  Code is as follows.
 ?php
 require '../scripts/db.php';
 $result = mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not
 execute query, please try again later);
 echo table border=\0\ class=\table-body\ width=\100%\form
 name=\rem_inv\ method=\post\ action=\done2.php3\
 trtd align=\center\ colspan=\3\font size=\4\BCurrent
 Inventory/B/fonthr color=\33\/td/tr;
 $count = -1;
 while ($myrow = mysql_fetch_row($result)) {
 $count ++;
 echo trtd width=\30%\BType Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_type));
 echo /tdtdinput type=\checkbox\ name=\cars\
 value=\checkbox\remove/td
 /tr\n;
 echo trtd width=\30%\BModel Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_model));
 echo /td/tr\n;
 echo trtd width=\30%\BYear Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_year));
 echo /td/tr\n;
 echo trtd width=\30%\BPrice Of Car: /B/tdtd$;
 printf(mysql_result($result,$count,car_price));
 echo /td/tr\n;
 echo trtd width=\30%\BVIN Of Car: /B/tdtd;
 printf(mysql_result($result,$count,car_vin));
 echo /td/trtrtd colspan=\3\hr color=\33\/td/tr\n;
 }
 echo trtdinput type=\submit\ name=\delete\
 value=\delete\/td/tr/form/table;
 ?
 Once it queries the database it gives the user an option to check the
 checkbox and delete that record.  Here is the done2.php3 page that
actually
 contains the delete sql statement
 $db_name = test;
 $table_name = inventory;
 $connection = @mysql_connect(localhost, root, password) or die
(Could
 not connect to database.  Please try again later.);
 $db = @mysql_select_db($db_name,$connection) or die (Could not select
 database table. Please try again later.);
 $sql = DELETE FROM $table_name WHERE $cars =

\$car_type\,\$car_model\,\$car_year\,\$car_price\,\$car_vin\,\$dl
 r_num\);
 $result = @mysql_query($sql, $connection) or die (Could not execute
query.
 Please try again later.);





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




[PHP-DB] formating problem

2002-02-19 Thread jas

I feel kinda dumb for posting this but here it is... I am trying to query a
table then format the results so it looks like the rest of the site and the
darn delete button to remove db entries keeps showing up at the top.  Here
is the code... Thanks in advance.
Jas
?php
require '../scripts/db.php';
$result = mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not
execute query, please try again later);
echo table border=\0\ class=\table-body\ width=\100%\form
name=\rem_inv\ method=\post\ action=\done2.php3\
trtd align=\center\ colspan=\2\font size=\4\BCurrent
Inventory/B/fonthr color=\33\/td/tr;
$count = -1;
while ($myrow = mysql_fetch_row($result)) {
$count ++;
echo trtd width=\30%\BType Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_type));
echo /tdtdinput type=\checkbox\ name=\car_type\
value=\checkbox\remove/td
/tr\n;
echo trtd width=\30%\BModel Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_model));
echo /td/tr\n;
echo trtd width=\30%\BYear Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_year));
echo /td/tr\n;
echo trtd width=\30%\BPrice Of Car: /B/tdtd$;
printf(mysql_result($result,$count,car_price));
echo /td/tr\n;
echo trtd width=\30%\BVIN Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_vin));
echo /td/trtrtd colspan=\3\hr color=\33\/td/tr\n;
}
echo input type=\submit\ name=\delete\
value=\delete\/form/table;
?



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




[PHP-DB] optimizing script...

2002-02-15 Thread jas

I have a script that prevents invalid characters from being passed from a
html form to a mysql database using php and I am wondering if there is a way
to condense it so instead of declaring the ereg_replace for each field in
the html form, to simply use one function to remove invalid characters and
html markup from all the fields in the form at once... here is my code, any
insight would be great.  I am not asking you to do it for me, I just want to
know how and what the best way to condense it would be. Thanks in advance.
Jas

# - Error correction for car_type field 
$car_type = ereg_replace (\, q, $car_type);
$car_type = ereg_replace (', a, $car_type);
$car_type = ereg_replace (%, p, $car_type);
$car_type = ereg_replace (, bs, $car_type);
# - Error correction for car_model field 
$car_model = ereg_replace (\, q, $car_model);
$car_model = ereg_replace (', a, $car_model);
$car_model = ereg_replace (%, p, $car_model);
$car_model = ereg_replace (, bs, $car_model);
# - Error correction for car_year field 
$car_year = ereg_replace (\, q, $car_year);
$car_year = ereg_replace (', a, $car_year);
$car_year = ereg_replace (%, p, $car_year);
$car_year = ereg_replace (, bs, $car_year);



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




[PHP-DB] formating w/ table

2002-02-15 Thread jas

I am having a little problem formating data retrieved from a database into
table cells... So far after connecting and querying the database table the
data is put into table cells, however after the first entry is displayed in
the table all the other entries loose the formating, HELP?
?php
require 'scripts/db.php';
$result = mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not
execute query, please try again later);
echo table border=\0\ class=\newhead\ width=\100%\trtd
align=\center\ colspan=\2\BCurrent Inventory/Bhr
color=\33\/td/tr;
$count = -1;
while ($myrow = mysql_fetch_row($result)) {
$count ++;
echo trtd width=\30%\BType Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_type));
echo /td/tr\n;
echo trtd width=\30%\BModel Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_model));
echo /td/tr\n;
echo trtd width=\30%\BYear Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_year));
echo /td/tr\n;
echo trtd width=\30%\BPrice Of Car: /B/tdtd$;
printf(mysql_result($result,$count,car_price));
echo /td/tr\n;
echo trtd width=\30%\BVIN Of Car: /B/tdtd;
printf(mysql_result($result,$count,car_vin));
echo /td/trtrtd colspan=\2\hr
color=\33\/td/tr/table\n;
}
?



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




[PHP-DB] Disable Right click w/ php?

2002-02-14 Thread jas

I have been looking on php.net for a function to disallow people to right
click to view source... anyone have a good idea of how to accomplish this
without using java-script?
Thanks in advance,
Jas



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




[PHP-DB] Form Validation

2002-02-14 Thread jas

Anyone know of a good function to strip characters and stuff that would
cause mysql to crash from forms?
Jas



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




[PHP-DB] Required pages...

2002-02-12 Thread jas

I am wondering if there is a way to force users to come from a certain page.
For an example I am using a login page which once authenticated allows users
to change the contents of a web site without knowing alot of code etc.  What
I would like to do is make sure that the content management system will not
be accessed unless the user logs in.  I am certain sessions is the way to go
on this, however I am still new enough to not understand exactly how they
work and how to impliment them on a site.  I have read a little bit on a
tutorial on php.net.  If anyone can give me an example of how this could be
accomplished I would appriciate it.
Jas



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




[PHP-DB] Updating Database problem...

2002-02-06 Thread jas

I am having a problem with a script that simply updates a few fields in a
database however, I am having a problem having the script to not update the
database fields if the form is invalid... Here is my script, I don't want
you to fix it for me unless you show me where I am going wrong or can point
me to a good tutorial on this type of function.   Thanks in advance,
Jas
?php
# trim extra spaces from these variables
$c_name = trim($c_name);
$s_addy = trim($s_addy);
$city = trim($city);
$state = trim($state);
$zip = trim($zip);
$phone = trim($phone);
if($c_name == )
 {
   $c_nameerr = Please enter your Company Namebr;
   $formerr = $formerr + 1;

 }
if($s_addy == )
 {
   $s_addyerr = Please enter your Street Addressbr;
   $formerr = $formerr + 1;

 }
if($city == )
 {
   $cityerr = Please enter your Citybr;
   $formerr = $formerr + 1;

 }
if($state == )
 {
   $stateerr = Please enter your Statebr;
   $formerr = $formerr + 1;

 }
if($zip == )
 {
   $ziperr = Please enter your Zip Codebr;
   $formerr = $formerr + 1;

 }
if($phone == )
 {
   $phoneerr = Please enter your Phone Numberbr;
   $formerr = $formerr + 1;

 }
# - connects to the mysql database to edit information
$db_name = test;
$table_name = www_demo;
$connection = @mysql_connect(localhost, user, password) or die (Could
not connect to database.  Please try again later.);
$db = @mysql_select_db($db_name,$connection) or die (Could not select
database table. Please try again later.);
$sql = UPDATE $table_name SET
c_name=\$c_name\,s_addy=\$s_addy\,city=\$city\,state=\state\,zip=\z
ip\,phone=\$phone\;
$result = @mysql_query($sql, $connection) or die (Could not execute query.
Please try again later.);
# --
?



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




Re: [PHP-DB] Updating Database problem...

2002-02-06 Thread jas

Sorry, but I figured it out.  You were right, I do need to call the sql
update function after the error field returns a 0.  Here is the code if any
one else out there is having the same problem.
?php
# trim extra spaces from these variables
$c_name = trim($c_name);
$s_addy = trim($s_addy);
$city = trim($city);
$state = trim($state);
$zip = trim($zip);
$phone = trim($phone);
if($c_name == )
 {
   $c_nameerr = Please enter your Company Namebr;
   $formerr = $formerr + 1;

 }
if($s_addy == )
 {
   $s_addyerr = Please enter your Street Addressbr;
   $formerr = $formerr + 1;

 }
if($city == )
 {
   $cityerr = Please enter your Citybr;
   $formerr = $formerr + 1;

 }
if($state == )
 {
   $stateerr = Please enter your Statebr;
   $formerr = $formerr + 1;

 }
if($zip == )
 {
   $ziperr = Please enter your Zip Codebr;
   $formerr = $formerr + 1;

 }
if($phone == )
 {
   $phoneerr = Please enter your Phone Numberbr;
   $formerr = $formerr + 1;

 }
?
- Then in body of document --
?php

if($formerr  0)
{
print('You need to fill out the form completely.  Click the back button on
your browser to make the necessary changes.br');
 echo $c_nameerr;
 echo $s_addyerr;
 echo $cityerr;
 echo $stateerr;
 echo $ziperr;
 echo $phoneerr;
}

if($formerr == 0)
 {
  print(pYour changes have been saved to the database/p);
# - connects to the mysql database to edit information
$db_name = test;
$table_name = www_demo;
$connection = @mysql_connect(localhost, user, password) or die (Could
not connect to database.  Please try again later.);
$db = @mysql_select_db($db_name,$connection) or die (Could not select
database table. Please try again later.);
$sql = UPDATE $table_name SET
c_name=\$c_name\,s_addy=\$s_addy\,city=\$city\,state=\state\,zip=\z
ip\,phone=\$phone\;
$result = @mysql_query($sql, $connection) or die (Could not execute query.
Please try again later.);
# --
}
?
Rick Emery [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Jas,

 Why are you initiating an UPDATE command when you've not changed the
 information you wish to update?
 For instance, if $c_name is blank, you display a message to enter the
data;
 yet, you DO NOT ASK the user to enter the correct information.  Then, you
do
 an UPDATE statment to enter that blank info into the record.

 You also update $formerr, yet do not use it.

 I've got a feeling you're not sharing all your code.  Please do so if we
are
 to help.

 You also need a WHERE clause in you UPDATE; otherwise, ALL records will be
 changed

 -Original Message-
 From: jas [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, January 31, 2002 11:14 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Updating Database problem...


 I am having a problem with a script that simply updates a few fields in a
 database however, I am having a problem having the script to not update
the
 database fields if the form is invalid... Here is my script, I don't want
 you to fix it for me unless you show me where I am going wrong or can
point
 me to a good tutorial on this type of function.   Thanks in advance,
 Jas
 ?php
 # trim extra spaces from these variables
 $c_name = trim($c_name);
 $s_addy = trim($s_addy);
 $city = trim($city);
 $state = trim($state);
 $zip = trim($zip);
 $phone = trim($phone);
 if($c_name == )
  {
$c_nameerr = Please enter your Company Namebr;
$formerr = $formerr + 1;

  }
 if($s_addy == )
  {
$s_addyerr = Please enter your Street Addressbr;
$formerr = $formerr + 1;

  }
 if($city == )
  {
$cityerr = Please enter your Citybr;
$formerr = $formerr + 1;

  }
 if($state == )
  {
$stateerr = Please enter your Statebr;
$formerr = $formerr + 1;

  }
 if($zip == )
  {
$ziperr = Please enter your Zip Codebr;
$formerr = $formerr + 1;

  }
 if($phone == )
  {
$phoneerr = Please enter your Phone Numberbr;
$formerr = $formerr + 1;

  }
 # - connects to the mysql database to edit information
 $db_name = test;
 $table_name = www_demo;
 $connection = @mysql_connect(localhost, user, password) or die
(Could
 not connect to database.  Please try again later.);
 $db = @mysql_select_db($db_name,$connection) or die (Could not select
 database table. Please try again later.);
 $sql = UPDATE $table_name SET

c_name=\$c_name\,s_addy=\$s_addy\,city=\$city\,state=\state\,zip=\z
 ip\,phone=\$phone\;
 $result = @mysql_query($sql, $connection) or die (Could not execute
query.
 Please try again later.);
 # --
 ?



 --
 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] query error...

2002-02-05 Thread jas

Ok what is wrong with this sql statement?
$sql = UPDATE $table_name SET
c_name=\$c_name\,s_addy=\$s_addy\,city=\$city\,state=\state\zip=\zi
p\,phone=\$phone\;

The error I recieve is as follows
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in
/path/to/wwwdemo_change.php3 on line 22

Parse error: parse error in /path/to/wwwdemo_change.php3 on line 22

I have looked on MySQL.com at the update function and it states I can use
the SET under UPDATE for multiple fields separated by a , and it is not
working... Any insight would be great.
Thanks in advance,
Jas



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




[PHP-DB] Combined sql statement

2002-02-04 Thread jas

I would like to know how to have a php script loop through two different sql
statements and use one according to a yes or no answer.  I am still kinda
new to php and I already have my sql statements, but I dont know how to use
php to tell it to use one of the other.  My sql statements are as follows...

$sql = INSERT INTO $table_name
(our_serv)
VALUES
(\$our_serv\)
;

$sql = UPDATE $table_name SET our_serv=\$our_serv\;

 How can I get it to pick one of these... for instance if there is no entry
in the unique table to enter one using the first sql statement, or if there
is already an entry to simply update and overwrite the current table entry.
Any help would be appriciated and if you could please document it so I
understand and dont have to ask again.  Thanks,
jas













WOW, your neat




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




Re: [PHP-DB] phpMyAdmin Problem....

2002-02-01 Thread jas

yeah that sounds like apache not being setup right
Matt Williams [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  I just added phpMyAdmin to a new Apache Server, and I'm getting
  this error:
 
  cannot load MySQL extension,
  please check PHP Configuration.
 
  I did some research on the web, but couldn't come up with a
  solution to this
  error and couldn't find anyone listing it.
 
  Does anyone know if this is a problem with conf.inc.php in phpMyAdmin or
  with the MySQL set up in PHP on the server?
 
  Any suggestions from there?
 

 Sound like you need to recompile with mysql support.

 check phpinfo()

 to see if mysql is missing.

 m:



-- 
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] DB Connection Class

2002-01-31 Thread jas

Ok, I hate to ask this again but I am having a hard time developing a
connection class to be reused.  I need to be able to just connect to the
database for several pages because I have multiple queries per page.
Unfortunately I do not know enough about php to effictively do this.  I have
read a few tutorials on the subject but they keep going way over my head, I
need a simple to understand method of reusing a connection for each query.
Please help! Thanks in advance!
Jas



-- 
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] DB Connections

2002-01-31 Thread jas

Ok, I am having a hard time coming up with a mysql connection class that
simply allows me to setup a require(db_connection.inc) at the top of my php
pages that allows a consistent connection to the mysql db and allows
multiple queries thoughout the php page in question.  I have read a few
tutorials on it and as of yet they all seem to go over my head.  If someone
could give me some more insight into this area I would greatly appriciate
it.
Jas



-- 
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] MySQL Connections

2002-01-31 Thread jas

Ok how can I find some good resources on how to create a db connection class
that doesnt go over my head?  I need to be able to connect to a mysql
database as the page loads and thoughout the page run 6 separate queries on
different fields.  please help!
jas



-- 
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] Connection class

2002-01-31 Thread jas

Well it was acutally so that I can create a content management system for my
employer.  Another gentleman helped me with it and it is working great I
simply created a file *.php with all my connection commands then did a
require on the page(s) that needed to query the db to pull information about
what is currently inserted into different fields.  My NEW problem has to do
with getting my INSERT statements to overwrite the distinctive fields when
storing updates etc.  I am looking into how to accomplish this at the
moment.  Sorry again for posting the same question a few times, it seems my
email editor choked.  =)  Thanks again.
Jas
Rick Emery [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 huh?

 You open the connection once for the page and then you CAN make multiple
 queries to it from the same page.  Why are you trying to create a class to
 do this (unless it's simply an intellectual exercise to create a class)?


 -Original Message-
 From: jas [mailto:[EMAIL PROTECTED]]
 Sent: Saturday, January 26, 2002 12:08 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Connection class


 Ok well I am in a little over my head with a connection class that I can
use
 over and over for multiple queries against a mysql db on one page.  I have
 read a few tutorials on the subject of how to use class files but I still
 dont understand php enough to know how to make a connection class that
 simply allows me to connect to a mysql database once the page loads and
 keeps the connection to run multiple queries on the same page.  HELP!!!
 Thanks again in advance...
 Jas



 --
 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] MySQL Connection Class

2002-01-30 Thread jas

I know this may seem a little vague but I would like to know where a good
tutorial on creating database connection class files would be.  I have been
looking and as of yet I have not found one that deals specifically with this
question.  Thanks in advance.
Jas



-- 
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]




  1   2   >