[PHP-DB] Re: DataObject feature request
On 9/13/05, Alessandro Pasotti [EMAIL PROTECTED] wrote: Hello, This is just an idea, DataObject already store most information about the fields, there is still a feature that is really useful during input validation, this is field max length for varchar fields. Do you think it is possibile to store also this important piece of information into .ini file? Such values could be used in the validate() function to check user input length on text fields. The PHP-DB list is not the right place for this request. Please send it to the PEAR-general list. I am also not a DB_DataObject developer, although I know a lot about it. -- Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Pear DB and DB_DataObject : recommended?
On Tue, 31 Aug 2004 08:14:17 -0500, Bob Sherer [EMAIL PROTECTED] wrote: Howdy. The question: How commonly accepted and recommended are the PEAR packages DB and DB_DataObject? Anybody have some warnings or encouraging stories from projects done with these php enhancement packs? I'm about to get started on a php and postgreSQL project that is starting from scratch. I'm relatively new to php, having only done code maintenance on other projects while working in a variety of other development environments (mainly .asp.) So, I'd rather not waste time learning to use these tools if they aren't something that other developers will be happy using as others are brought onto this project. In general, PHP developers are happy to use PEAR classes as they are well coded and (mostly) well documented. I use DB_DataObject quite a bit and have run into very few problems. You can also submit a bug report or ask for help on the PEAR-General list for more help regarding them. Thanks for your thoughts and opinions, Bob S. -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Array
$arr = array('key' = array('key2' = 'value', 'key3' = 'value', ...), ...); $arr['key2'] = array('key2' = 'value', ...); $arr['key3]['key2'] = 'value'; On Thu, 26 Aug 2004 16:11:27 -0500, Miguel Guirao [EMAIL PROTECTED] wrote: Hi!! I have a table with many options from when the user can select them, after that, his/her selections will be stored in a database. In the mean time, I want to store his/her selections in an array like this one: PN DescQty |---|--|---| |---|--|---| |---|--|---| How do I declare Duch an array like this??, let's call it Parts. Miguel Guirao Servicios Datacard www.SIASA.com.mx -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php !DSPAM:412dfd2d29942082615647! -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] letting a table name be a constant
On Mon, 23 Aug 2004 17:06:40 -0700, Ben Galin [EMAIL PROTECTED] wrote: Hello, Regarding this code: [PHP code] // This works $name=name; $table=mytable; $mysql_connect(localhost,,) or die(Error: .mysql_error()); $mysql_select_db(mydb) or die(Error: .mysql_error()); $mysql_query(INSERT INTO $table (`id`,`name`) VALUES ('','$name')); [/PHP code] I want to define() TABLE as a constant instead of using the variable $table [PHP code] // This runs without an error but does *not* insert a new row $name=name; define(TABLE, mytable); $mysql_connect(localhost,,) or die(Error: .mysql_error()); $mysql_select_db(mydb) or die(Error: .mysql_error()); $mysql_query(INSERT INTO TABLE (`id`,`name`) VALUES ('','$name')); [/PHP code] Changing the query line to $mysql_query(INSERT INTO `TABLE` (`id`,`name`) VALUES ('','$name')); Well, of course PHP isn't going to change your strings. That would be a bit intrusive and make some things real hard to do. C won't even do this. Here's what you want: $mysql_query('INSERT INTO `'.TABLE.'` (`id`,`name`) VALUES (,'.$name.')'); or $mysql_query(INSERT INTO 'TABLE' (`id`,`name`) VALUES ('','$name')); has no effect. I also tried to define(TABLE, `mytable`); which, too, didn't work. Would appreciate any advice, Ben -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] retrieved data from mysql to be shown in spreadsheet
On Sat, 21 Aug 2004 09:51:51 +0530, balwantsingh [EMAIL PROTECTED] wrote: May pls. advise me. I am developing a page using PHP for entering the data into tables made in mysql. I want that when user click on Reports button the data (which will retrieve from mysql) should be shown in Spreadshee (Calc) of Open Office. Pls. tell how it can be done. balwant Perhaps try making a CSV and have the user download it. -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql query
On Fri, 13 Aug 2004 19:39:59 +0200, Torsten Roehr [EMAIL PROTECTED] wrote: Justin Patrin [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Fri, 13 Aug 2004 15:20:36 +0200, Quentin Cotillard [EMAIL PROTECTED] wrote: Consider a table similar to the one below. What I want to do is to get ONE random record from categories(cat) A and 5 random record from category B | ID | computer | name | cat |... 1dell 834A 2ibm526A 3apple 134B 4sony 333A 5dell 834B 6ibm556A 7apple 534B 8sony 233A 9dell 874A How could I construct my query to the mysql? This is an SQL question, not a PHP question. order by rand limit 5 Hi Justin, this won't work because he needs to make sure to get 1 from category A *AND* 5 from category B with one query. I had a similar problem some weeks ago and even though a lot of people from the list were trying to help we didn't find a solution. In the end I had to do seperate queries. I actually assumed that. This *can* be done in a query, but it requires sub-queriesunions. Something like this: SELECT * FROM computer WHERE cat = 'A' ORDER BY rand() LIMIT 1 UNION SELECT * FROM computer WHERE cat = 'B' ORDER BY rand() LIMIT 5 -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] How to do an update with arithmetic from a user input
On Thu, 12 Aug 2004 12:46:19 -0700, Chip Wiegand [EMAIL PROTECTED] wrote: I have an existing database and web page showing the query results. I have added another field to allow a user to input a two digit number. I want that number to change the number in one of the existing columns for the item it was input next to. I have these columns - Part Number Description QuantityList Price Put on hold I want the Quantity column changed according to the number the user input in the Put on hold column. I'm stuck in the query to write, trying to do $sql1 = update refurbs set qty(qty - $qty) order by 'description'; Perhaps: $sql1 = update refurbs set qty = qty - $qty; Also, 1) you have no WHERE there, so this will update *all* records. 2) why are you trying to order an update?? but that doesn't work. I have pasted in the main part of the code below... Thanks for any help you can provide, Chip Wiegand Computer Services Simrad, Inc 425-778-8821 425-771-7211 (FAX) BTW, thanks for the replys to the first message, I was expecting the list to be much more busy. === form action=? PHP_SELF ? method=post name=refurbs table summary= border=1 cellpadding=5 cellspacing=0 width=90% align=center tr td class=small bgcolor=#ffPart Number/td td class=small bgcolor=#ffDescription/td td class=small bgcolor=#ffQuantity/td td class=small bgcolor=#ffList Price/td td class=small bgcolor=#ffSpecial Price/td td class=small bgcolor=#ffPut on Hold /td /tr ? if (isset($submit)): $sql = update refurbs set qty(qty - '$buy') order by 'description'; $result = mysql_query($sql); $Colors = array('#ffcc99','#ffcc33'); $I = 0; while ( $row = mysql_fetch_array($result)) { printf(tr bgcolor= . $Colors[ $I ++ % count( $Colors ) ] . td%s\n/td\n, $row[part_number]); printf(td%s\n/td\n, $row[description]); printf(td%s\n/td\n, $row[qty]); printf(td%s\n/td\n, $row[list]); printf(td%s\n/td\n, $row[special]); printf(tdinput type=\text\ name=\buy\ size=\2\ maxlength=\2\ /td/tr\n); } ? /table table summary= border=0 cellpadding=5 cellspacing=0 width=90% align=center tr tdbr /div align=centerinput type=submit name=submit value=Submit //div/td /tr /table /form -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] How to do an update with arithmetic from a user input
Unless $part_number is a number, you're going to want to put quotes around it. Well, actually, you want to run mysql_real_escape_string() on it. You also don't seem to have an end to that if statement. Usually, people use curly braces around those: if(true) { //do something } - Original Message - From: Chip Wiegand [EMAIL PROTECTED] Date: Thu, 12 Aug 2004 13:24:05 -0700 Subject: Re: [PHP-DB] How to do an update with arithmetic from a user input To: [EMAIL PROTECTED] Cc: PHP DB [EMAIL PROTECTED] Justin Patrin [EMAIL PROTECTED] wrote on 08/12/2004 12:55:24 PM: On Thu, 12 Aug 2004 12:46:19 -0700, Chip Wiegand [EMAIL PROTECTED] wrote: I have an existing database and web page showing the query results. I have added another field to allow a user to input a two digit number. I want that number to change the number in one of the existing columns for the item it was input next to. I have these columns - Part Number Description QuantityList Price Put on hold I want the Quantity column changed according to the number the user input in the Put on hold column. I'm stuck in the query to write, trying to do $sql1 = update refurbs set qty(qty - $qty) order by 'description'; Perhaps: $sql1 = update refurbs set qty = qty - $qty; Also, 1) you have no WHERE there, so this will update *all* records. 2) why are you trying to order an update?? Thanks for the quick reply. The order by stuff is gone now, it was an 'artifact'. hehe. Anyway, I added the where clause so my query looks like this: $sql = update refurbs set qty = qty - $buy where part_number = $part_number; But when I try to run this I get an error - Parse error: parse error, unexpected $ in /usr/local/www/data-dist/auth_dealers/refurbs-test.php on line 102 I don't see an rogue $'s in the code. (Eventually the form will submit to another page which will email the info to a person here in our office). -- Chip Now the code looks like this - === form action=? PHP_SELF ? method=post name=refurbs table summary= border=1 cellpadding=5 cellspacing=0 width=90% align=center tr td class=small bgcolor=#ffPart Number/td td class=small bgcolor=#ffDescription/td td class=small bgcolor=#ffQuantity/td td class=small bgcolor=#ffList Price/td td class=small bgcolor=#ffSpecial Price/td td class=small bgcolor=#ffPut on Hold /td /tr ? if (isset($submit)): $sql = update refurbs set qty = qty - $buy where part_number = $part_number; $result = mysql_query($sql); $Colors = array('#ffcc99','#ffcc33'); $I = 0; while ( $row = mysql_fetch_array($result)) { printf(tr bgcolor= . $Colors[ $I ++ % count( $Colors ) ] . td%s\n/td\n, $row[part_number]); printf(td%s\n/td\n, $row[description]); printf(td%s\n/td\n, $row[qty]); printf(td%s\n/td\n, $row[list]); printf(td%s\n/td\n, $row[special]); printf(tdinput type=\text\ name=\buy\ size=\2\ maxlength=\2\ /td/tr\n); } ? /table table summary= border=0 cellpadding=5 cellspacing=0 width=90% align=center tr tdbr /div align=centerinput type=submit name=submit value=Submit //div/td /tr /table /form !DSPAM:411bcfbf286175080220868! -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] How to do an update with arithmetic from a user input
You don't need the colon as well as the curly brace on your if. Again: if (isset($submit)) { //do stuff } Your update query doesn't say anything about the description, I don't see how it could eb affected. Also, looks like you're using register_globals. Check out this page and the links for more info on why this is bad: https://www.reversefold.com/tikiwiki/tiki-index.php?page=PHPFAQs - Original Message - From: Chip Wiegand [EMAIL PROTECTED] Date: Thu, 12 Aug 2004 14:10:00 -0700 Subject: Re: [PHP-DB] How to do an update with arithmetic from a user input To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED], PHP DB [EMAIL PROTECTED] Justin Patrin [EMAIL PROTECTED] wrote on 08/12/2004 01:37:35 PM: Unless $part_number is a number, you're going to want to put quotes around it. Well, actually, you want to run mysql_real_escape_string() on it. You also don't seem to have an end to that if statement. Usually, people use curly braces around those: if(true) { //do something } Thanks, I'm making headway. This time when I entered a value and submitted, the database value for the qty field was not changed, but instead the description field was cleared. The database table has columns titled qty as well as description and others. Regards, Chip The newest version of the code is this - form action=refurbs-send.php method=post name=refurbs table summary= border=1 cellpadding=5 cellspacing=0 width=90% align=center tr td class=small bgcolor=#ffPart Number/td td class=small bgcolor=#ffDescription/td td class=small bgcolor=#ffQuantity/td td class=small bgcolor=#ffList Price/td td class=small bgcolor=#ffSpecial Price/td td class=small bgcolor=#ffPut on Hold /td /tr ? if (isset($submit)): { $sql = update refurbs set qty = qty - '$buy' where part_number = '$part_number'; $result = mysql_query($sql); } else: $sql = select * from refurbs order by description; $result = mysql_query($sql); $Colors = array('#ffcc99','#ffcc33'); $I = 0; while ( $row = mysql_fetch_array($result)) { printf(tr bgcolor= . $Colors[ $I ++ % count( $Colors ) ] . td%s\n/td\n, $row[part_number]); printf(td%s\n/td\n, $row[description]); printf(td%s\n/td\n, $row[qty]); printf(td%s\n/td\n, $row[list]); printf(td%s\n/td\n, $row[special]); printf(tdinput type=\text\ name=\buy\ size=\2\ maxlength=\2\ /td/tr\n); } ? /table table summary= border=0 cellpadding=5 cellspacing=0 width=90% align=center tr tdbr /div align=centerinput type=submit name=submit value=Submit //div/td /tr /table /form !DSPAM:411bda82311752080024828! -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] RE: [SPAM] Re: [PHP-DB] Intellectual property rights
, visit: http://www.php.net/unsub.php !DSPAM:41180b0a313921571316053! -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] bags o beans - filtering rows/array by value of an aggregated attribute
On Thu, 5 Aug 2004 17:26:05 -0500, Grant Listhandle [EMAIL PROTECTED] wrote: In the database beans i have a table bags_o_beans where each row represents a single bag, and columns named bean_type and number_o_beans My teenage son is having several thousand hungry friends over in half an hour, and I'm stuck making the bean dip... I'm going to need 1 million beans of a single type to make the dip. My goal, before I start cooking, is to filter from the following query: SELECT bean_type, sum(number_o_beans) FROM bags_o_beans GROUP BY bean_type Use a column alias: SELECT bean_type, sum(number_o_beans) AS total_number_of_beans FROM bags_o_beans GROUP BY bean_type into an html table such that only 'bean types' with 'sum(number_of_beans)' greater than 1 million are displayed. I have tried inserting the following snippet into the table-generating php code, with no luck: while ($row = @ mysql_fetch_row($result)) { foreach($row as $data) if ({sum(number_o_beans)} (100)) if($row['total_number_of_beans']) 100) print \n\ttd {$data} /td; print \n/tr; } Thanks ahead of time for your thoughts and recipes :) Grant -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php !DSPAM:4112b26a148642019194572! -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Web page paginator that doesn't rely on the LIMIT clause
On Tue, 03 Aug 2004 20:52:23 +1000, Ross Honniball [EMAIL PROTECTED] wrote: Hi all, I use the LIMIT statement to control paging of data, which works really well. I now have a situation where I need to use some logic in addition to the query that will result in NOT ALL records being spat out. ie. select * from x where y; foreach result if (some condition) output; endif endfor So problem is I can't say LIMIT 20,20 on the query as logic may result in less than 20 records being spat out to screen. I was planning on coding up a solution so that i just keep a count myself of how many records I have output myself and break at appropriate paging points, but I am probably re-inventing the wheel. Anyone know of any good classes they are using that do this sort of thing already? Just a quick note as no one else suggested it. You could also used stored procedures for this sort of thing if you can't get a good SQL solution. Even if you get an SQL solution, stored procedures can easily be faster (as they use program code). It would also be dropping records on the server side so that it doesn't have to be sent to your PHP app. My $0.02. -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Urgent JOIN help needed
On Fri, 30 Jul 2004 23:25:57 -0400, Chris Payne [EMAIL PROTECTED] wrote: Hi there everyone, I'm new to JOINS and have followed some info in the MySQL manual but I'm at a loss, using the code I'll paste below, I get each result 4 times and I am confused as to why? Basically I'm trying to display ALL fields from the vendorprices table, and grab just the Description column from the fooditems table, the factor which joins them both is the string $VendorID which in the vendorprices table is VendorNumber and in the fooditems table is CategoryNumber. $sql = SELECT * FROM vendorprices LEFT JOIN fooditems on (vendorprices.VendorNumber = fooditems.CategoryNumber AND fooditems.CategoryNumber = '$VendorID') WHERE vendorprices.VendorNumber='$VendorID' AND fooditems.CategoryNumber='$VendorID'; Can anyone see where I'm going wrong? This is driving me nuts and I need to figure it out urgently. You should / can only join ON columns. You're putting fooditems.CategoryNumber='$VendorID' twice, you only need / should have it in the WHERE clause. -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] php mysql dates
On Wed, 28 Jul 2004 14:39:01 -0700, Irm Jr [EMAIL PROTECTED] wrote: Sure I understand Y-m-d. But won't the database cry because the Month is in text format? (January, february)? Thanks again. Whoops, I should read *all* the text of the question... Easiest way to deal with that, IMHO, is strtotime and date. $mysqlDate = date('Y-m-d', strtotime($month.' '.$day.', '.$year)); If you're using dates far in the past or future, though, this won't work. Better to use a date handling class, such as: http://pear.php.net/package/Date Subject: Re: [PHP-DB] php mysql dates On Wed, 28 Jul 2004 14:30:24 -0700, Irm Jr [EMAIL PROTECTED] wrote: Hi all, currently I have a form which prompts for the user to choose a date. The dropdown lists are stored into variables: $month//e.g. January, February, ... $day //e.g 1 - 31 $year //e.g. 2004 (four digits) then combined into $articleDate How can I manipulate this variable to be in such a format that I can insert the information into a DATE column in a mySQL database. Dates are a bit of a mystery to me as PHP and MySQL handle them differently. Your help is appreciated. Y-m-d -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Unable to parse message
What mail program are you using? I'm getting mail parsing errors. In addition, you have your From set as: Harry G harry (removethis)@gabha.net Likely, ( and ) aren't supposed to be in there (invalid chars) and it also makes it impossible to reply to you. There is no other from or reply to in the headers. Answer to your question inline below. On Mon, 26 Jul 2004 08:47:08 +1000, wrote: Hi, I want to run a query on a table while joining it with other tables. Table 1- members id - firstname - middlename - - country - region3 Fields country and region3 hold the integer codes for country and region3 is state Table 2- country id - countryname Countryname is where the actual Country name is stored and id is the country code Similarly Table 3 - region3 id - region3 where region3 is the state name and id is the region code. I perform the following query to search the names in the database but the result only gives me the integer values for Country and Region3. That's because, the code is only stored in the database. But I need to join the table 23 with 1 so I can extract names of country or region3 rather than integer values. How would I modify the query below? $keywords are the search words. You want a JOIN, obviously. I'm assuming you're using Mysql. If you aren't, you may need a different syntax. $query = SELECT id, firstname, familyname, middlename, fathername, region3, region4, country, country.countryname MATCH(firstname, middlename, familyname, fathername) AGAINST ('$keywords' IN BOOLEAN MODE) AS score FROM members LEFT JOIN country ON members.country = country.id WHERE MATCH(firstname, middlename, familyname, fathername) AGAINST ('$keywords' IN BOOLEAN MODE) ORDER BY score DESC; And do the same kind of thing for region3. -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Query returns duplicate rows
On Wed, 21 Jul 2004 16:29:37 -0400, Brock Jimmy D Contr 74 MDSS/SGSI [EMAIL PROTECTED] wrote: My query is returning duplicates rows. table: elements elementId standardId elementtext category mcode linenum table: scores scoreId taskId scores Here's my query: SELECT distinct elementtext,cateogy,mcode,linenum,scores,scoreId FROM elements, scores WHERE scores.taskId='12' AND elements.standardId='APR.05' This is returning duplicate rows, even though I'm using the DISTINCT keyword. If I remove the field scoreId it is fine. Any suggestions? Should you perhaps be doing some kind of ON clause to that join? It's joining every record in elements with every element in scores. You need to tell it what fields to join on. Also, doing a distinct on that many fields at once could be very expensive. Better tp refine your query or data model. -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Query returns duplicate rows
On Wed, 21 Jul 2004 17:09:35 -0400, Brock Jimmy D Contr 74 MDSS/SGSI [EMAIL PROTECTED] wrote: These two tables do not have a relation, so there is nothing to join. Basically, what I'm trying to is this: Users need to score elements. The elements are assoicatied with standards. A standard may have 1 to 29 elements associated with it. For users to score the elements they need to see the criteria for that particular element. Thanks for the help though. You may want to try selecting all selected elements, then all selected scores, then loop through them individually. Doing a join without an ON clause is IMHO not a good choice. -Original Message- From: Justin Patrin To: Brock Jimmy D Contr 74 MDSS/SGSI Cc: [EMAIL PROTECTED] Sent: 7/21/2004 5:02 PM Subject: Re: [PHP-DB] Query returns duplicate rows On Wed, 21 Jul 2004 16:29:37 -0400, Brock Jimmy D Contr 74 MDSS/SGSI [EMAIL PROTECTED] wrote: My query is returning duplicates rows. table: elements elementId standardId elementtext category mcode linenum table: scores scoreId taskId scores Here's my query: SELECT distinct elementtext,cateogy,mcode,linenum,scores,scoreId FROM elements, scores WHERE scores.taskId='12' AND elements.standardId='APR.05' This is returning duplicate rows, even though I'm using the DISTINCT keyword. If I remove the field scoreId it is fine. Any suggestions? Should you perhaps be doing some kind of ON clause to that join? It's joining every record in elements with every element in scores. You need to tell it what fields to join on. Also, doing a distinct on that many fields at once could be very expensive. Better tp refine your query or data model. -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Bogus List Messages
On Mon, 19 Jul 2004 07:47:38 -0700, Cole S. Ashcraft [EMAIL PROTECTED] wrote: Are the messages with the subject line IMPORTANT: Please Verify Your Message bogus? They do not come from the ezmlm mailer at lists.php.net. They do not have the [PHP-DB] prefix. Have the owners of the list requested this? No, this is not a feature of the PHP lists. However, these messages are not bogus. They're from a service that one of the subscribers is using to stop spam. Just click the link and they'll go away. -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: REG_BADRPT error
In this case, it seems like you're looking for a lot of different and exclusive things at once. I would suggest not using a huge regex as they can be hard to create, harder to read, and impossible to maintain. That said, I do use regexes in some of my code, just not for something this simple. ;-) I generally use Perl Compatible Regexes as I understand them better. Try: if(strlen($pass) 6 || !preg_match('/[a-z]/i', $pass) || !preg_match('/[0-9]/', $pass)) { //bad password } On Mon, 19 Jul 2004 11:10:47 -0400, Aaron Todd [EMAIL PROTECTED] wrote: Hello, Ive been trying a few things and finally I did get rid of the error. I changed the code to: if (!ereg('^(!?=.*[0-9]+.*)(!?=.*[a-zA-Z]+.*)[0-9a-zA-Z]{6,}$', $pass)){ Notice the ! before the two ? This got rid of the error, but it still isnt working the way I want it to. That line should validate the variable $pass, which should be greater than 6 characters and contain at least one numbers and one letter. That line should be true if $pass does not equil 6 characters and contain at least one numbers and one letter. Can someone correct me on this. I am new to PHP so I am still trying to get the hang of it. Any help will be appreciated. Thanks, Aaron Aaron Todd [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello, I am getting an REG_BADRPT error when I use ereg. The line of code that errors is: if (!ereg('^(?=.*[0-9]+.*)(?=.*[a-zA-Z]+.*)[0-9a-zA-Z]{8,}$', $pass)){ I got this regex from regexlib.com and tried to impliment it, but no matter what I do it always returns the error. I did a google search and the only suggestion I found was to make sure that the variable contains data. So I echoed the variable and it did have data in it. Does anyone know why I might be getting this? Thanks, Aaron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php !DSPAM:40fbe26957361384218867! -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Begining PHP...Have Questions
You should generally $_POST for all posted variables, $_GET for all get variables (in the query string / url), and the other superglobals for other such things. If you don't care if it's POST, GET, or a cookie, you can use $_REQUEST. register_globals is a setting in your php.ini. It's best practice to set this to off. What this means for you is that variables sent by the user are not registered as global variables. i.e. $username will no longer work, you have to use $_POST['username']. Search the php lists for lots more discussion on this matter. For more on superglobals: http://www.php.net/manual/en/language.variables.predefined.php For the list archives, click the Archive links here: http://www.php.net/mailing-lists.php On Mon, 19 Jul 2004 13:27:15 -0400, Aaron Todd [EMAIL PROTECTED] wrote: Jon, Thanks for the info. I did change the LIKE to =. This was done just for my debugging. I do have it set to = on a normal basis. I am a little unsure what you mean at the end of your reply about register globals. Are you saying that everywhere I use $username to refer to the users inputed username I should use $_POST['username'] instead? Or are you suggesting to use this in one location. Thanks again for the reply, Aaron Jonathan Haddad [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] if you have shell access, please do the following describe users; select * from users; also, why are you using LIKE instead of =? use this instead: $query = SELECT * FROM users WHERE email = '.$username.'; i would also suggest turning off register globals and using $_POST['username'] and not $username. (i'm assuming it's on given your code) Jon Aaron Todd wrote: I am just starting out with PHP and I have created a simple login program that is supposed to check users input with a mysql database. I am doing 5 verifications before the program is completed...Check for the Submit button, check for a valid email address(which is the username), check for a valid password, check to see if the username exists in the database, and finally check to see if the password matches the database for the coresponding username. Currently you dont get access to a site you only get told what your password is in the database. Everything is technically working, but its not perfect and I think I need some help. I have entered 2 records in the database for testing purposes. When I put in username1 and password1 it works. The program returns the coresponding password. When I change to username2 and still put in password1 it will return password1. I have done some debuging and I am unsure of what is really happening. My code is below. Would anyone be able to tell me what I am doing wrong. Thanks, Aaron html body ?php if ($submit) { //VALID USERNAME/EMAIL ADDRESS if (!ereg('^[-!#$%\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[!#$%\'*+\\/0-9=?A-Z^_` a -z{|}`]+\.'.'[-!#$%\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $username)) { $error = You must enter a valid email address for your username.br; echo $errorbr; } else { $db = mysql_connect(localhost, username, password); mysql_select_db(database,$db); $query = SELECT * FROM users WHERE email LIKE '.$username.'; echo $querybr; $result = mysql_query($query,$db); $num_rows = mysql_num_rows($result); echo There are $num_rows records matching $usernamebr; //VALID PASSWORD echo Entered User Name: $usernamebr; echo Entered Password: $passwbr; if (strlen($passw) 6 || !preg_match('/[a-z]/i', $passw) || !preg_match('/[0-9]/', $passw)) { $error = Invalid Password. Must be greater than six characters containing at least one number.br; echo $errorbr; } else { //USERNAME/EMAIL ADDRESS IN DATABASE if (!$num_rows){ $error = Username was not found. Please Register.; echo $errorbr; die(mysql_error()); } else { //ENTERED PASSWORD IN DATABASE if (!$passw = mysql_result($result,0,pass)){ $error = Invalid Password.br; echo $errorbr; } else { printf(Password is %sbr\n, mysql_result($result,0,pass)); } } } } } else { ? form method=post action=?php echo $PHP_SELF? User Name:input type=Text name=usernamebr Password:input type=Text name=passwbr input type=Submit name=submit value=Enter information /form ?php } // end if ? /body /html -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php !DSPAM:40fc074a164631045595694! -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http
Re: [PHP-DB] Fwd: IMPORTANT: Please Verify Your Message
PLEASE look at the previous messages about this. Yes, it's legit. No, it's not the PHP lists sending it to you. On Mon, 19 Jul 2004 10:24:27 -0700, Marcjon [EMAIL PROTECTED] wrote: I got this email today. Is php doing this? Is this email ligitimate? On Mon, 19 Jul 2004 09:55:58 -0400, [EMAIL PROTECTED], [EMAIL PROTECTED] p.net said: Hello [EMAIL PROTECTED] , [EMAIL PROTECTED], [EMAIL PROTECTED] is currently protecting themselves from receiving junk mail using [1]Spamcease Just this once, click the link below so I can receive your emails. You won't have to do this again. [2]http://www.tgpwizards.com/spamcease2/verify.php?id=69153 References 1. http://www.spamcease.com/cart/affiliate.php?id=3 2. http://www.tgpwizards.com/spamcease2/verify.php?id=69153 -- Marcjon -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php !DSPAM:40fc0683162762080714991! -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] php, javascript and db - your help is needed
On Sun, 18 Jul 2004 13:24:01 -0700, Marcjon [EMAIL PROTECTED] wrote: You could use a if/while construct. Something like: select name=\courses\ ?php if ($_POST['studentselect']){ $result = mysql_query(SELECT courses FROM students WHERE student_name = ' . $_POST['studentselect'] . '); while ($row = mysql_fetch_assoc($result)) { echo option value=.$row['course']..$row['course']./option; } } ? /select Basically you would submit the form, and if a student was selected, it would populate the list with their courses from the database. -- Marcjon - Original message - From: G. Cohen [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: Sun, 18 Jul 2004 19:30:49 +0300 Subject: [PHP-DB] php, javascript and db - your help is needed Hello, I have a HTML form with 2 select boxes, lets say students and courses. When the from loads for the first time, I fill the students select box with data from database. The courses selectbox remains empty. When the user selects a value from the students selectbox (onchange event), I should go to the db to reterive the courses for the selected student and fill the courses selectbaox. I found it very complicated to do the interaction between javascript and php: apparently, I have to submit the from for the selected student id to be passed as a parameter to php (so that php can access the db with the student id and retrieve his courses), and at the same time I want the form to stay with the list of students, and the selected student. This should not be that hard, should it?! this is something trivial, I hope? I also tried using cookies, with no success. If someone knows how to do that, please let me know. Best Regards, G. Cohen PHP is a server-side language, so any further processing can only be done when the browser sends a new request. You have to refresh *some* page to get new data. It is possible to use a hidden iframe to send a request, then parse it with JS and display it in the main page, but this isn't trivial. -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Rewrite value from form data
Somnething like this? //remove all non-digits $home = preg_replace('/[^\d]/', '', $_POST['home_phone']); //if it's 10 digits if(preg_match('/\d{10}/')) { $home = preg_replace('/(\d{3})(\d{3})(\d{4})/', '\1-\2-\3', $home); } On Sat, 17 Jul 2004 12:44:46 -0400, Vincent Jordan [EMAIL PROTECTED] wrote: I have a form with a field for a telephone number. I would like to either apply some kind of formatting to force format of XXX-XXX- or rewrite after submit to insert - in 3 and 5 (or 6). Here is what I have for code: --Form- tdHome Phone:/td tdinput type=text name=home_phone id=home_phone size=15 tabindex=8 //td handler.php $home = $_POST['home_phone' I have tried str_replace() however im not using it correctly or it is not the correct string to use for this -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php !DSPAM:40f9556c159931176717192! -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] LAST_INSERT_ID?????
Try the PHP funciton mysql_insert_id(). http://us3.php.net/manual/en/function.mysql-insert-id.php On Thu, 15 Jul 2004 15:16:44 -0500, NIPP, SCOTT V (SBCSI) [EMAIL PROTECTED] wrote: OK. I know that a BUNCH of people have had this question, and I have read numerous Google threads on this, but nothing really seems to point out the resolution... I have a table with the Primary Key as an auto_increment field. Once I insert a new row of data into the table I want to direct the user to a Submitted page. I am trying to pull the entry number to display for the user as a ticket number. I would assume that I should use the LAST_INSERT_ID function for this. Unfortunately, I am getting either failures or all zeroes for this output. I can't even get this function to work in a SQL query window. Please help!!! I would attach code to this, but I am not sure what to attach. -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] LAST_INSERT_ID?????
On Thu, 15 Jul 2004 16:25:26 -0400, Hutchins, Richard [EMAIL PROTECTED] wrote: Scott, I typically use PHP's mysql_insert_id() function on a result. For example, the following snippet from a function I use: snip $result = mysql_query($sql) or die(mysql_error()); With the or die() above, $result will never be false. if(!$result){ $evNew = -1;//set evID to an impossible value in case the query fails }else{ $evNew = mysql_insert_id();//if the query succeeds, return the id of the new event } return $evNew; /snip Works like a charm. Rich -Original Message- From: NIPP, SCOTT V (SBCSI) [mailto:[EMAIL PROTECTED] Sent: Thursday, July 15, 2004 4:17 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] LAST_INSERT_ID? OK. I know that a BUNCH of people have had this question, and I have read numerous Google threads on this, but nothing really seems to point out the resolution... I have a table with the Primary Key as an auto_increment field. Once I insert a new row of data into the table I want to direct the user to a Submitted page. I am trying to pull the entry number to display for the user as a ticket number. I would assume that I should use the LAST_INSERT_ID function for this. Unfortunately, I am getting either failures or all zeroes for this output. I can't even get this function to work in a SQL query window. Please help!!! I would attach code to this, but I am not sure what to attach. -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] More problems with searching
On Thu, 1 Jul 2004 12:28:46 -0500, Shiloh Madsen [EMAIL PROTECTED] wrote: After the very kind help i was given last night I have the query being built right, however the query does not work. Just to refresh, the gentlemen who had helped me suggested creation of a query that looks like: SELECT * FROM table1 where 1 or cat or dog...and so forth. Now, this query is building fine, but the where 1 is causing it to return rows even if it has none of the search terms. When i run it in sql without the where 1 it works as it should, but with that, i get all rows returned. Is there a way i can reword this query or am I doing something wrong? this was Mr Holmes's solution (in part): $query = SELECT * FROM keyword WHERE 1 $words = explode(' ',$_GET['search_text']); foreach($words as $word) { $query .= AND keyword = '$word' ; } Shouldn't that be OR? Ideas? Shiloh -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php !DSPAM:40e4480b265025655517531! -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Conditional explode?
On Thu, 1 Jul 2004 15:09:38 -0500, Matt M. [EMAIL PROTECTED] wrote: On Thu, 1 Jul 2004 14:05:49 -0500, Shiloh Madsen [EMAIL PROTECTED] wrote: Can I use explode in a conditional manner? I.E., can i have it explode on a space, but only if the space is not encased in double quotes? I would use http://www.php.net/preg_split I'm not sure how you could do that as there could be multiple sets of quotes. If you have: 1 2 3 4 5 6 7 8 9 How would you write a preg to split only on those *not* encased in quotes? Here was my solution (posted before for another question): /** * does a regular explode, but also accounts for the deliminator to be within quoted fields * for example, if called as such: * splitQuoteFriendly(',', '0,1,2,3,I am still 3,4'); * it will return: * array(0 = '0', * 1 = '1', * 2 = '2', * 3 = '3,I am still 3', * 4 = '4'); * @param string deliminator to explode by * @param string text to explode * @param string text which surrounds quoted fields (defaults to ) * @return array array of fields after explode */ function explodeQuoteFriendly($delim, $text, $quote = '') { $strictFields = explode($delim, $text); for($sl = 0, $l = 0; $sl sizeof($strictFields); ++$sl) { $fields[$l] = $strictFields[$sl]; $numQuotes = 0; while(fmod($numQuotes += substr_count($strictFields[$sl], $quote), 2) == 1) { ++$sl; $fields[$l] .= $delim.$strictFields[$sl]; } ++$l; } return $fields; } -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] [slightly OT] OOP syntax
On Wed, 30 Jun 2004 14:20:52 -0400, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I have some procedural code that i'm wanting to convert into classes(and i'm a bit greeen to OOP), hopefully to offer them to the PHP community. I keep all my config data in arrays of arrays, which i'd like to keep when i move to a class model, but can't seem to find out the correct defintion syntax. for example, here is a portion of the array storing connection info to a mssql db(keeping it in db land) $srvr['etime'] = array(); $srvr['etime']['server']= '27.22.1.5:1433'; $srvr['etime']['db'] = 'dbmaster'; $srvr['etime']['user'] = 'uname'; $srvr['etime']['pass'] = 'pword'; $srvr['etime']['title'] = 'eTime'; $srvr['etime']['dfltch']= 'N'; $srvr['etime']['optional'] = false; var $srvr = array('etime' = array('server' = '27.22.1.5:1433', 'db' = 'dbmaster', etc.), 'atime' = 'a value'); BTW, this looks like DB abstraction data. Have you looked into PEAR DB, MDB, DB_DataObject, etc? How would this need to be defined at the top of a class to taken on as a class variable/array. Am i thinking of this wrong? I can add them all as scalar variables, but i'd rather work with arrays, as i use the arrays to loop for other functions. I've tried a variety of syntaxes, but keep getting parse errors. thanks for any info you can provide. Jeff -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php !DSPAM:40e3028f186817955031138! -- paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] How to define array variable while accessing it ???
Well, IMHO you shouldn't do in-string variables as you never know if it will work. In this case, it won't YOu should do something like this: $query='delete from feedback where id='.$delete[$i]; Single quotes tell PHP not to look for variables in the string. A period concatenates. There's actually a better solution, too: $query='delete from feedback where id='.mysql_real_escape_string($delete[$i]).''; On Tue, 29 Jun 2004 00:06:24 -0700 (PDT), Rinku [EMAIL PROTECTED] wrote: Actually I want to know how to access the variable after defining it. Like : $query=delete from feedback where id=$delete[$i]; $deleteresult=mysql_query($query) or die(Unable to delete); But here I am not getting any value in $delete[$i]-(here $i is 0,1,2,3) So what to do to access it ? I cant access the value even by $_POST['$delete[$i]'] Can any of you suggest me the sollution ? Rinku --- Torsten Roehr [EMAIL PROTECTED] wrote: Matt M. [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] TDDIV ALIGN=CENTER input type=checkbox name=? printf(chk_arr[%d],$i); ? value=?=$row[0]? /DIV/TD setup your checkbox something like this: input type=checkbox name=delete[] value=?=$row[0]? / php will treat this as an array The closing php tag and quote of the value attribute was missing: input type=checkbox name=delete[] value=?= $row[0] ? / Regards, Torsten Roehr -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php __ Do you Yahoo!? Yahoo! Mail is new and improved - Check it out! http://promotions.yahoo.com/new_mail -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php !DSPAM:40e112fd156793833020386! -- paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Date help needed
You could loop through the weeks and put those 3 specifically in: $days = array(); for($i = 0; $i 365; $i +=7) { $days[] = strtotime('next Monday', strtotime('+ '.$i.' days')); $days[] = strtotime('next Friday', strtotime('+ '.$i.' days')); $days[] = strtotime('next Sunday', strtotime('+ '.$i.' days')); } sort($days); foreach($days as $day) { echo date('Y-m-d', $day).'br/'; } (This is not tested, but it *should* work,) On Thu, 24 Jun 2004 17:07:12 -0400, Chris Payne [EMAIL PROTECTED] wrote: Hi there everyone, I have a problem, I currently have some code which populates a dropdown box - this code gives me every day for the next x amount of days (EG: a years worth of days), however what I really need to be able to do, is to find a way to display this data in the dropdown box but ONLY show 3 days a week, IE: Mondays, Fridays and Sundays, so it would show the dates for each Monday, Friday and Sunday for X amount of days (IE: 365 days in the dropdown). Does anyone have any idea how to do this? I would really appreciate any help, I'd send my sample code only I'm not at my home/work computer ATM. Chris !DSPAM:40db40cb34094233914063! -- paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: content managment systems
Pete M wrote: I use www.tikiwiki.org love it I just started using it and it's very nice. Here's a quick hint to those who are new, though. You can click the :: to expand the menu. If I'd only known this when I started pete Lisi wrote: I am looking for open source CMSs that: 1) use PHP/Mysql 2) are relatively easy to install, for someone familiar with both PHP and MySQL 3) also easily allow you to change the layout/template from the default For instance, if I want to hire a graphic designer to create a static page for me with a unique design for my site, I want to be able to create a template file from that (possibly one template for the home page and a second one for inside pages) and then plug in a CMS into that layout (or plug the template into a CMS) so the client can then make any changes to any pages without having to go through me. I've heard PHP-Nuke is a very good portal system - would it work for this? Any other recommendations? The CMS must be open source, the budget is very limited right now. Thanks! -Lisi -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: MySQL executes several times the same request
Loïc moisy wrote: Hi Everyone ! I've coded a php site for a musical store. At the end of every page, before closing the connection, I send an UPDATE request to increment a statistical tool. Recently I saw weird results, so I tried to understand. Looking in my logs, I saw that this request could be sent several times, arbitrary - can be 5 times or 8 or whatever... So my counter is incremented from 4 to 8 times. The server seems to resend the whole requestes several times. I have read all of my scripts, even coded some trace code, and sure there is no loop. The code seems like that: $counter++; $SQL = UPDATE statistics SET VALUE (`counter` = $counter) $res = mysql_query($SQL); mysql_closedb($DB); So, I do not see anything strange. Can u help me ? My own thought about it is something like a buffer not empty or something like that. Thanks ! We had a problem like this on our site for a while. It turned out that soneone had put an empty image tag on the site which was causing the browser to go to the same page *again*. Check to make sure that all of your images have the src attribute filled out. -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: PHP/MySQL learning project
Alexey Kupershtokh wrote: Hi. In trying to learn PHP and MySQL, I'm trying to create a web-based database application that will keep track of my movies. I have five tables (shown in the graphic). I'm trying to be able to display the results of the tables with one movie title, all of the actors associated with it, and all of the genre's associated with it. You are thinking not in the terms of relational db. It's impossible on the mysql db level. WBR, Wicked I don't know what you're trying to say here. You can do relational databases with mysql without any trouble whatsoever. Just because it doesn't support foreign keys (constraints) doesn't mean you can't have foreign keys. In fact, foreign keys mostly just slow down the run-time of your system, but I don't want to start a holy war here. -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Extremely Urgent: Problem with PHP and Oracle
Charles Morris wrote: Hello all, I have recently been working with OCI and when I use OCILogon [wethere with example scripts or my own code] I get a PAge cannot be displayed (like DNS error) when I naviagte to the page. When I comment out the OCILogon part it works great exept for the oracle part. I am able to accesss the database from Perl, the built in SQL*PLUS and other languages.- The only problem is this. I have to have this working by friday morning and I cannot risk not mailing this alias; so please any help is greatly appreciated!! Here are my code snippets: dbconnection.php ?php class OracleConnection { var $CONN = ; var $IPADD = *.*.*.*; var $USER = ; var $PASS = ; var $SID = ; function fatal_error($text) { $maillink = 'a href=mailto:[EMAIL PROTECTED]network administrator/a'; echo bFatal Error. /bbr; echo [$text] ( 0 : 0 ) br; echo $_SERVER['HTTP_USER_AGENT']; echo br; echo ORACLE_SID: .getenv(ORACLE_SID).BRORACLE_HOME: .getenv(ORACLE_HOME.BR; $error = OCIError(); if ($error[offset]) { $sqltext = substr ($error[sqltext], 0, $error[offset]) . '*' . substr ($err ($error[sqltext], $error[offset]); } else {$sqltext = No OCI error.;} echo $sqltext; echo BRContact the $maillink with this message.\n; exit; function init() { putenv(ORACLE_SID=PROJ); putenv(ORACLE_HOME=/home/oracle9); $ipadd = $this-IPADD; $user = $this-USER; $pass = $this-PASS; //$dbase = $this-DBASE; //$dbase = $DBAC_BEGIN . $DBAC_PROTO . $DBAC_HOST . $DBAC_PORT . )) . $DBAC_COTD . ); $dbase = (DESCRIPTION=(ADDRESS_LIST =(ADDRESS =(PROTOCOL = TCP)(HOST = 128.*.*.*)(PORT = 1521)))(CONNECT_DATA=(SID=PROJ))); // use for PHP 5.0 and greater //$conn = oci_connect($user, $pass, $dbase) || $this-fatal_error(Connection could not be established with server [$ipadd]); // use for PHP 4.91 and lower $conn = ociplogon($user, $pass, $dbase) || $this-fatal_error(Connection could not be established with server [$ipadd]); $this-CONN = $conn || $this-fatal_error(Connection could not be stabalized, unable to continue.); return true; } //end class: 'OracleConnection' } --eof-- Also, could someone please send me a working example of using variables appended to text with array()? I am a long time experienced perl programmer and I have tried using the . operatore a + but no luck. Thanks everyone!!! Please excuse types, typing on a 14.4 connection. --- Charles Morris [EMAIL PROTECTED] CS Systems GroupOld Dominion University http://www.cs.odu.edu/~cmorris http://www.cs.odu.edu/cspage/systemstaff.html -- They that give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety. -- Benjamin Franklin, 1759 The only secure computer is one that's unplugged, locked in a safe, and buried 20 feet under the ground in a secret location... and i'm not even too sure about that one--Dennis Huges, FBI. On first glance, your fatal_error function doesn't seem to have an ending }. I have tried putenv myself and it doesn't seem to work for Oracle connections. Putting those in your shell environment, then restarting apache. Check to see if the env vars are set from a PHP script (without using putenv to set them of course). -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: automatic call reference creation
Gawie Marais wrote: thanx for the replys guys... basically i need a PHP formula to generate a 'call refenrence code' that is unique to give out to clients whenever they log a call. this unique 'call reference code should be inserted into a mysql field within a table. all i need is a formula to get the last entered code and increment it by one - the intended code should be forumated by php by using the current date i.e. 20040101 + a numerical value i.e. 001 for the first 'call reference code' for the day. when the next call is logged, the next unique available numerical should be assigned and combined with the date to form the call reference number. hope this makes it a bit clearer. Pete M [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] not sure what u want here but have you looked at the identiry field ?? its called auto_increment in mysql and this gives it record in a database a unique number eg Insert into table (date_call)values(now() ) then after the insert do select last_insert_id() pedro Gawie Marais wrote: hi all, i need to create an automatic call reference. i though it would work using the date as ccyymmdd and by adding a '001', '002', etc to the end. now, i know how to format the date but how would i increment the 001, 002 at the end... ? i understand that i would have to check back to the database to check the last one used. but how... ? alternatively is to just generate a random number, check it against the database to see if it's not already used. if not use it. if its used already, just create another one... ? OR do you guys have any laternative suggestions ? Regards, Gawie. You should really just use an auto_increment field in mysql or a sequence in any other DB. This will let the DB give you a unique ID. If you try to make one yourself, it's possible that you'll have concurrency problems. -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: HELP: best way to TEXT dump a MySQL table to a local file...
Leo G. Divinagracia III wrote: project i'm working with, his host died or something. but, the phpMyadmin (on that host) can NOT do a backup of 200mb table without running out of memory or something weird. so what is the best way to text dump the table? i thought i would (pseudo-code): open DB do while not EOF grab 1000 rows from DB write to a file on host www path filename = filename000 + 1 until EOF user would then FTP down the files to his machine. but i figured i could use the HEADER to send it to the user. i grabbed this from the HEADER help section: ?php $output_file = 'something.txt'; $content_len = 666; @ob_end_clean(); @ini_set('zlib.output_compression', 'Off'); header('Pragma: public'); header('Content-Transfer-Encoding: none'); header('Content-Type: application/octetstream; name=' . $output_file . ''); header('Content-Disposition: inline; filename=' . $output_file . ''); header(Content-length: $content_len); ? is that the best way to send the txt file to the user? thanks... Try using mysqldump from the command line. If you need a PHP script to do this, use system() or `` or one of the other system call functions. -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: PHP/MySQL learning project
News.Php.Net wrote: Hi everyone! In trying to learn PHP and MySQL, I'm trying to create a web-based database application that will keep track of my movies. I have five tables (shown in the graphic). I'm trying to be able to display the results of the tables with one movie title, all of the actors associated with it, and all of the genre's associated with it. Of course I can do the query: Select * From MovieMain, MovieActor, MovieGenre, Genre, Actors Where MovieMain.MovieID=MovieGenre.MovieID And MovieMain.MovieID=MovieActor.MovieID And MovieActor.ActorID=Actors.ActorID And MovieGenre.GenreID=Genre.GenreID But that displays the movie title for every genre and actor there is. Is there another way to perform the query that will display the title once, and all of the associated genres and all of the associated actors for that movie? Or should I try to code it using PHP to find the movie title first? Thanks in advance, everyone! There's no way to do that in SQL alone. You should do it in PHP. :-) -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Anyone using MSQL Server with PHP?
Miguel Guirao wrote: Hi!! Anybody here using PHP with SQL Server? I would like to use a similar function to password () from MySQL under SQL Server. Anybody knows of a similar function under SQL Server? Kind Regards, Miguel Guirao Servicios Datacard www.SIASA.com.mx If it's for your app only, you could use md5() in PHP. -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Dynamic Data
Christopher J. Crane wrote: What is the best way to produce a report listing the fieldname and then the data in that field. It is a report containing only one row from a table, but I don't want to hard code the fields since they change often. I can get the field names dynamically like this: $fields = mysql_list_fields(Network, Subnets); $num_columns = mysql_num_fields($fields); for($ i = 0; $i $num_columns; $i++) { echo mysql_field_name($fields, $i); } now is where I get confusedwhat I would like to happen is do a query on a single row and put the results into mysql_fetch_assoc and during the prior loop put the column name into the loop of the data. Something like: $fields = mysql_list_fields(Network, Subnets); $num_columns = mysql_num_fields($fields); $result = mysql_query(SELECT * FROM table1 WHERE ID = '$ID'; $field = mysql_fetch_assoc($result) for($ i = 0; $i $num_columns; $i++) { echo b . mysql_field_name($fields, $i) . : /b . $field[mysql_field_name($fields, $i)] . br\n; All you really need here is: $sth = mysql_query(SELECT * FROM table1 WHERE ID = '$ID'); $rec = mysql_fetch_assoc($sth); foreach($rec as $field = $value) { echo 'b'.$field.': /b'.$value.'br/'; } -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: About retrieving auto increment value
Marc Soler wrote: Hi I have the typical problem with retrieving auto increment value in php-mysql environment. I have search info in mysql page and I have found LAST_INSERT_ID() funtion but I don't know how to use correctly. I have one script that insert a row. And another script that must retrieve last auto_increment value for primary key on a table. I want something like this: SELECT LAST_INSERT_ID() FROM foo_table; (like curval(foo_sequence) in postgres) This doesn't work. It's possible? Where I am wrong? Thanks in advance I *think* you have to do this in the same script. I would suggest using mysql_insert_id() (in PHP) on the same page where you inserted and pass it into the page that needs it. -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: $_Session vs $_Cookie
Ng Hwee Hwee wrote: Hi all, I have a problem: my $_SESSION variables and $_COOKIE variables get destroyed very often, even though my clients are actively browsing the site (that means, the variables should not be garbage collected). Our guess is that the network connections are weak. My server is in Singapore but my clients are connecting to it from Japan, Thailand, Australia (some on dial-up) etc... Apparently, their connections get dropped pretty frequently. Thus, their $_SESSION variables and $_COOKIE variables get destroyed everytime their connections are dropped. Has anyone experienced such phenomenon before? is our guess accurate? if it is, does it mean that the best solution would be to change all our $_SESSION variables to $_COOKIE and set an expiry date to the cookies to 12 hours later or something.. fyi, i'm using PHP4.2.2 and my session.gc_maxlifetime = 1440 and session.gc_probability = 1. I will be upgrading to 4.3.6 in the near future. thanks in advance! hwee Are you using a server cluster? If so, do you have some kind of session sharing set up? (Basically you have to either set up the same directory to be pointing to one machine or use a shared DB for session storage). -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: How to select records if any of it's fields match the requirement?
Amanda wrote: I would like to select the records where any of the fields LIKE '%abc%' Can I do that without knowing the table's column names? If table column names are required, how can I retrieve the column names from the table? Regards Amanda Many database engines will give them to you if you do this: DESCRIBE table; -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Am I missing something? Why doesn't php have a 'date' variable
Ross Honniball wrote: Hello. I've been using php for about 5 months now. One of the first things I noticed it was missing was a standard in-built manner of handling dates. I assumed that, being inexperienced, I was probably missing something and in time all would become clear. It's a while later now and I still think it sucks that it doesn't have a standard date variable type. Why doesn't it have a standard class or variable type to help process dates in a standard manner? Php should offer a DATE variable type (in addition to string, int, array, object etc.). Dates could be stored by utilising standard date functions. eg. $birthday = SetDate('23-07-1985', 'dmy'); Use of this function would effectively declare $birthday as a field of type date. (note that I wish this was my birthday). Standard maths could be performed on date fields for comparison. eg. $newdate = $start_date + $birthdate - 5; // as in days if ($date1 $date2) ..whatever..; And of course standard routines for formating dates, standard routines for showing time between dates / times etc. This frustrated me so much that I recently wrote a class to emulate, as best as possible, this level of functionality, which would actually be quite adequate if Windows didn't suck. But due to some lunatic Windows limitation, it will only work on dates between 1970 and 2038. Hmmm. Nice one, Bill (are we in for another 'new millenium' problem on windows machines in 2038?). Anyway, am I missing something, or do other people find this a glaring omission in an otherwise spiffing product? Ross PS note that in refering to dates above, I really mean date + time. PSS Technical note: As you all know, internally the only rational way to store dates is as a sequential number from an chosen starting date - eg. 1-1-1960, 1-1-1970, whatever. Prior dates are simply stored as negative numbers. . . Ross Honniball. JCU Bookshop Cairns, Qld, Australia. . You are missing a bit. Integers are generally used for Dates in PHP, using the UNIX Timestamp format. You can use strtotime() and date() to convert between timestamp and string formats. Of course, this only works for dates back to 1970. You should have come to the list before now. ;-) There's a class in PEAR that deals with pretty much any date you'll need and has lots of funcitons for adding, subtracting, formatting, etc. http://pear.php.net/package/Date -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Forum Software
Room 11 Designs wrote: Hi there everyone, I was wondering how hard it is to write your own forum, maybe even as complicated as PhpBB... Any help out there? To completely write something that complicated and featureful takes a long time. Why not just use PHPBB? -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: mail() function and AOL users
Matt Perry wrote: I use the following php mail function in an online applicaiton program: mail($email, application submitted, $message, From: [EMAIL PROTECTED]); This function does not always work when I modify $message. I have checked for null values for $message already but this does not seem to be the problem. I am trying to develop some sort of pattern of when this function works and when it does not. The only essential difference between the values I pass in for message is the one that does not always work includes a link. Apparently anyone useing AOL email is particularly vulnerable to this problem. Is it likely that AOL and other mail servers sometimes block any email from a web site if it has a link in the main body? Or should I not be useing mail() in this manner to begin with? -Matt Are you doing this on your own server? If so, your problem is likely due to AOL blocking dynamic IPs from sending e-mail to them. Even if this is a real server, you could still have these problems. Are you getting bounces back? The solution is to route all of your e-mails through a trusted mail server, such as that of your ISP. You can use a mailing package which sends the mail to a mail server (instead of sending it locally). One such is PEAR's Mail package. Use the smtp backend. You can also do this on your server. If you need more help with this, mail me off-list. -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Load balancing and SQLite
Andy Ladouceur wrote: Hey everyone, Currently planning out the databases for a large project, and have decided to use separate SQLite database files for each users hit statistics. The problem is, there are two webservers, with a load balancer. I'm wondering what suggestions people might have on accessing the sqlite databases from either webserver? (As I can't write them to the same disk the webserver is on, without needing to copy it to the other webserver as well.) I _might_ have access to a third system, which I could use for a dedicated database server, but is NFS a viable solution? Would there be a noticeable performance impact when opening the database files remotely? Thanks in advance for any responses, Andy Short answer: if you have more than a simple project and / or one webserver, you don't want to use SQLite. If you're worried baout load balancing I doubt you really want to be using SQLite. It's meant as a simple system. If you're making a large project, you probably want to go with a better system, at least mysql. That way, you can run the DB server on one machine and have both access it. You could even run the DB on one of the webservers and have both webservers use it. As for NFS, I haven't had major problems with it myself, but it's always called the Network Failure System by many people I trust. It can (will) also cause quite a bit of extra network traffic, especially since your database engine will reside on a different machine than the database file, likely causing reading of large quantities of data over the network that just get thrown out by sqlite engine. -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] no temp var for mysql_fetch_array results
You'd have to ask someone with more internals knowledge for that one... I'm sure it does get GC'd, but I don't know if it happens in-script or at the end. Also, I would assume it is freed when GC'd, but who knows, I might be wrong. It's much safer to free it yourself. paperCrane Justin Patrin David T-G wrote: Justin, et al -- ...and then Justin Patrin said... % % David T-G wrote: % % ...and then Justin Patrin said... % % ... % % Of course, this leaves the result handle open. It's best to store the % % result handle and free it with mysql_free_result(). % % Makes sense. I actually hadn't thought of that; do I need to do that % after a typical while(mysql_fetch_array()) or does the exhaustion caused % by the while loop then close and free for me? % % Nope, it's kept open so that you can use a seek to go back to the % beginning i fyou want to (at least, I'm pretty sure that's what it's % doing). You should always use mysql_free_result on your statement/result % handle. Ah... Very interesting. One learns something every day :-) % % Of course, you don't *really* need to do this if your script is small as % PHP will free everything when it's done, but it's good coding style and % can keep you from (possibly) running out of memory in larger scripts. Right. And surely someone who so fastidiously fclose()s every fopen()ed file, even if it was opened read-only, would want to tie up any loose db ends in the same way! One last question... If I make a query and run through the results and then make another query, reusing the same result handle, should I have freed the first result before assigning the second? That is, does that handle get closed automatically or orphaned for garbage collection at the end of the script? % % -- % paperCrane Justin Patrin Thanks again HAND :-D -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] no temp var for mysql_fetch_array results
David T-G wrote: Jeff (and John) -- ...and then [EMAIL PROTECTED] said... % ... % $r = mysql_query($q,$dbro) ; % $row = mysql_fetch_array($r) ; % $i = $row[0] ; ... % this one row (not looping), could I just % % $i = mysql_fetch_array($r)[0] ; % % Hi David Hi! % How about: % $i = mysql_result(mysql_query($q,$dbro),0); Oooh! Cool! Just right. % HTH % Jeff Thanks HAND :-D Of course, this leaves the result handle open. It's best to store the result handle and free it with mysql_free_result(). If you want to get one column's data (or one row even) you may want to look into a DB abstraction layer (such as PEAR DB or MDB). Or, of course, you could write your own function. function getOne($sql, $link) { $sth = mysql_query($sql, $link); $val = mysql_result($sth, 0); mysql_free_result($sth); return $val; } -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] no temp var for mysql_fetch_array results
David T-G wrote: Justin, et al -- ...and then Justin Patrin said... % % David T-G wrote: % % ...and then [EMAIL PROTECTED] said... % % ... % % How about: % % $i = mysql_result(mysql_query($q,$dbro),0); % % Oooh! Cool! Just right. ... % % Of course, this leaves the result handle open. It's best to store the % result handle and free it with mysql_free_result(). Makes sense. I actually hadn't thought of that; do I need to do that after a typical while(mysql_fetch_array()) or does the exhaustion caused by the while loop then close and free for me? Thanks TIA HAND :-D Nope, it's kept open so that you can use a seek to go back to the beginning i fyou want to (at least, I'm pretty sure that's what it's doing). You should always use mysql_free_result on your statement/result handle. Of course, you don't *really* need to do this if your script is small as PHP will free everything when it's done, but it's good coding style and can keep you from (possibly) running out of memory in larger scripts. -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Procedure for submitting an order via email
Ruprecht Helms wrote: Hi, I'm looking for an simple example how to send an order (content of the basket) via email. Does someone have such a good ans simple example. Regards, Ruprecht You're not giving nearly enough information. If you want to send an e-mail you can use the mail() function or use a package, such as PEAR::Mail. http://www.php.net/mail http://pear.php.net/package/Mail -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Cursor in text box.
John W. Holmes wrote: matthew perry wrote: My users complain about everything. The most common is Why do I have to move the mouse over to this box every time? Wh! How do I get the cursor to que into the first input area of my form? JavaScript, not PHP. document.yourform.yourtextbox.focus(), I think. Here's a more cross-browser way: document.forms[formName].elements[elementName].focus(); -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Scrolling drop down menu
John W. Holmes wrote: matthew perry wrote: When my users choose an option in the drop down menu, they sometimes accidentally change what they have chosen when the move the center scrolling button of their mouse. I was giving a presentation in front of my company's owner and did this myself. 5 or so index fingers instantly pointed at me saying See you do that to! Wh! Is there a way to stop a menu from scrolling with the center scrolling mouse button? Your questions have nothing to do with PHP. And absolutely nothing to do with DB... -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: URL Problem
Chris Payne wrote: Hi there everyone, I have a problem. Basically this is what I need to do: Request behind the scenes (PHP) an ASP Url on a different website with the value pid=1 (Where 1 is an identifying number). Then I need PHP to listen to the response from that request as ASP will then return a value which PHP has to pickup, and I have ZERO idea how to do this :-( I tried something which I though, but that gets the webpage and NOT the url that it passes back with its values. Any help would be greatly appreciated. So basically I need to request an URL from within PHP, PHP listens to and gets the reply URL that is sent back to it with the new value (Which is determined by the pid= value). Thank you everyone. Chris --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.662 / Virus Database: 425 - Release Date: 4/20/2004 You could use PEAR's HTTP_Request and just grab the resulting URL from it. require_once('HTTP/Request.php'); $req = new HTTP_Request('http://example.com/somescript.asp?pid=1', array('allowRedirects' = true)); $req-sendRequest(); $url = $req-_url; That *should* do it. -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: lamer noob question
Dan Bowkley wrote: So I'm building this website; the first I've tried to build using a mostly dynamic structure. What I've done is create a mysql table, with two fields: id and page_val. The idea is you call the page like http://www.someplace.com/page.php?id=404 and it'll spit back (in this case) the infamous 404 not found page. I've got it so it'll spit back stuff from the DB, but only if I hard-code it...which defies the whole point of this exercise. Here's what I've got thus far: !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN html head titleWelcome to boardlady.com!/title link rel=stylesheet type=text/css href=styles.css SCRIPT language=JavaScript1.2 src=main.jstype=text/javascript/SCRIPT /head body DIV id=TipLayer style=visibility:hidden;position:absolute;z-index:1000;top:-100/DIV SCRIPT language=JavaScript1.2 src=style.js type=text/javascript/SCRIPT table width=750 trtd table trtdimg src=banner-1.gif alt=The Board Lady - Eva-M. Hollmann/tdtdOver b3,281/b Served!/td/tr /table tabletrtd class=sideboxa href=index.html onMouseOver=stm(Text[00],Style[12]) onMouseOut=htm()HOME/abrbrbra href=intro.html onMouseOver=stm(Text[01],Style[12]) onMouseOut=htm()INTRO/abrbrbra href=repairs.html onMouseOver=stm(Text[02],Style[12]) onMouseOut=htm()REPAIRS/abrbrbra href=prices.html onMouseOver=stm(Text[03],Style[12]) onMouseOut=htm()PRICES/abrbrbra href=faq.html onMouseOver=stm(Text[04],Style[12]) onMouseOut=htm()FAQ/abrbrbra href=trailer.html onMouseOver=stm(Text[05],Style[12]) onMouseOut=htm()TRAILER/abrbrbra href=contact.html onMouseOver=stm(Text[06],Style[12]) onMouseOut=htm()CONTACT ME/abrbrbra href=directions.html onMouseOver=stm(Text[07],Style[12]) onMouseOut=htm()DIRECTIONS/a/td td valign=top !--Begin main body text-- ?php define ('DB_USER', 'user'); define ('DB_PASSWORD', ''); define ('DB_HOST', 'localhost'); define ('DB_NAME', 'database'); $dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to database: ' . mysql_error()); @mysql_select_db (DB_NAME) OR die ('Could not connect to database: ' . mysql_error()); if ($page_req == ) {$id=index;} elseif ($page_req == index) {$id=index;} else { $id=404;} $query = SELECT page_val FROM boardlady_site WHERE id =404; $result = @mysql_query ($query); while ($row = mysql_fetch_array($result)) {echo $row[0];} mysql_close(); ? !--End main body text-- /td /tr trtd colspan=2centerdiv class=footer onMouseOver=stm(Text[08],Style[12]) onMouseOut=htm()This site a href=copyright.html style=color:#2f2f2f; font-size:xx-small;text-decoration:none;font-weight:bold; target=newcopyright (C)/a 2004 by Eva-M. Hollmann. All rights reserved./divdiv class=footerbrWebsite design by Dan at a href=http://www.dibcomputers.com; style=color:#2f2f2f; font-size:xx-small;text-decoration:none;font-weight:bold; target=newDIB Computers./a/div/center/td/tr/table /td/tr/table /body /html First off, I need to know how to fetch variables out of the URL. I know this is /supposed/ to be easy...but dammit I just can't get it to work. The other part that's pissing me off is trying to stuff a variable inside my query variable...no matter what I try I get a syntax error.. Yeah, I'm that noob. So were we all. Thanks in advance, Dan The query vars are in the $_GET, $_POST, and $_REQUEST superglobals. Look up superglobals on php.net to see what they are. Here's a modified DB query string for you: $query = 'SELECT page_val FROM boardlady_site WHERE id ='.$_REQUEST['id']; You will probably also want to change your $page_req vars up above. This is all likely happening to you because register_globals is turned off for you in your php.ini. Believe me, this is a good thing. Use the superglobal arrays instead. -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: PHP OO Problem
Andre Matos wrote: Hi List, Two months ago I developed a project using PHP and MySQL without problem. Now, I am developing using PHP and MySQL, but using PHP Object Oriented. My problem is that the access is become slowly after few accesses or if I perform a reload some times. The unique way to revert is to restart the Apache. Is anyone had this problem? Is this problem related to PHP OO or may something that I used in my programs? Thanks. Andre [EMAIL PROTECTED] Pretty much all of the larger PHP systems around are OO. PEAR is OO. If OO was the problem, it would have been fixed far before now. Likely you're using more resources inadvertently or not closing resources. Try checking specific functions to see if they're slowing you down. If you need more help, post some code and it will get looked at. -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Dynamic Form?
Aaron Wolski wrote: Hi All, I've been given the task of developing a dynamic form for a client. When I say dynamic, I mean dynamic in that the client can use an administrative interface (back-end) to create the various form fields (and types) that get displayed on the front-end. Before I start brainstorming the DB and programming requirements, I'd take a stab to see if anyone knows of open source software that might do what I am looking for? Wheel reinvention is not high on my task list. Thanks so much! Aaron Well, this isn't completely what you want, but it will probably help you quite a bit for form displayingg: http://pear.php.net/package/HTML_QuickForm -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Mail() - Preposterous Accusation
Jochem Maas wrote: Justin Patrin wrote: accurate. If it is, why hasn't the mail function been modified in the more recent builds? I've been using PHP since it was invented never had a problem with mail. Also note that your form page is currently using the PHP mail() function, which doesn't work very well anymore. You would be best advised to use another solution (one example is PHPMailer - http://phpmailer.sf.net/) for doing PHP script-based email delivery. Sounds alot more like advertising than sanity ... there's not much trickery in using the mail() function ... only if you want to attach files can it get a bit tricky (encoding the file and inserting the result), but in reality, there's not much in using that function properly ... you'll find that phpmailer is a quite nice wrapper for the mail function - it presents 1 clear object interface and handles all the mundane tasks of CC, BCC, Attachments, Encoding, MIME etc. I have been using it for quite sometime now. just drop 2 files into your project include/class directory and your pretty much off using a simple Mailer object. I think advertising is a bit harsh considering it free software. I usually interested in what people think are good tools/classes, even if its the writer (is that even the case here?). let the code speak for itself. I didn't mean to say that phpmailer isn't useful, just that using mail() should work fine for simple mailing. I definately agree with using a library, be it phpmailer or PEAR::Mail for anything more than a simple message. incitement_to_riot code re-use is good right? which is why ideas like PEAR a good for everyone. and in the interest of starting a flame war (which there seems to be a bit of going around lately) I'll say that IMO most of PEAR (incl. the core is bloatware) and that PHP5 will make alot of it redundant, they should tear down all but the package manager and a few the gems and start again. /incitement_to_riot Yes, code re-use is good. I won't get into the PEAR vs. other stuff argument again, I've done it too much lately. Just look for me and Manuel Lemos in the archives. ;-) I will say one thing: I like PEAR because it's all built around the same framework and everything has a similar interface to similar functionality. It has never felt like bloatware to me and never will, all of the given functionality is very useful. ... -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Mail() - Preposterous Accusation
Ryan Jameson wrote: He says later in his email that: The reason I mention this is because any email delivery failures will not be sent back to you, but to our servers (due to the way that PHP writes the email headers when using the mail() command). ... Is there a way to get the bounces to go to the reply to address? I've never really cared to, but now that he mentions it ... It would be nice. Ryan -Original Message- From: -{ Rene Brehmer }- [mailto:[EMAIL PROTECTED] Sent: Thursday, April 08, 2004 6:08 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Mail() - Preposterous Accusation At 00:01 08-04-2004, Ryan Jameson (USA) wrote: I know this isn't technically DB related but this is the list that I use. I'd just like to know if anyone else thinks the below statement is accurate. If it is, why hasn't the mail function been modified in the more recent builds? I've been using PHP since it was invented never had a problem with mail. Also note that your form page is currently using the PHP mail() function, which doesn't work very well anymore. You would be best advised to use another solution (one example is PHPMailer - http://phpmailer.sf.net/) for doing PHP script-based email delivery. Sounds alot more like advertising than sanity ... there's not much trickery in using the mail() function ... only if you want to attach files can it get a bit tricky (encoding the file and inserting the result), but in reality, there's not much in using that function properly ... Rene -- Rene Brehmer aka Metalbunny ~ If you don't like what I have to say ... don't read it ~ http://metalbunny.net/ References, tools, and other useful stuff... Check out the new Metalbunny forums @ http://forums.metalbunny.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Maybe add the appropriate header to the headers parameter? I'm using the mail() function and getting bounces just fine. Perhaps set up a mail alias/forwarding for the user that the script runs as? -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Mail() - Preposterous Accusation
Ryan Jameson wrote: I know this isn't technically DB related but this is the list that I use. I'd just like to know if anyone else thinks the below statement is accurate. If it is, why hasn't the mail function been modified in the more recent builds? I've been using PHP since it was invented never had a problem with mail. Also note that your form page is currently using the PHP mail() function, which doesn't work very well anymore. You would be best advised to use another solution (one example is PHPMailer - http://phpmailer.sf.net/) for doing PHP script-based email delivery. Ryan I have never had any major problems with mail() myself. People just use it incorrectly or don't configure correctly or don't create their e-mails correctly. However, it *can* be hard to use, especially for multi-part e-mails and on Windows platforms. If you're doing anything but sending a simple text message, I would highly recommend using a mailer package. The one I happen to like is a combination of PEAR's Mail and Mail_Mime. http://pear.php.net/package/Mail http://pear.php.net/package/Mail_Mime -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: ocilogon error
Adam Williams wrote: Hi, I have oracle and PHP working together on a remote server called zed that runs redhat linux. I have another computer called accessserver that runs win2k pro with PHP that I am trying to connect to oracle on zed. Both computers have the oracle client libraries installed. On accessserver I have the code: ?php $conn = ocilogon(user,pw,zed.aleph0) or die .ora_error(); if ($conn) { echo connection to oracle successful; } ? When I run this I get the error: Warning: ocilogon(): OCISessionBegin: ORA-12705: invalid or unknown NLS parameter value specified in C:\htdocs\oracleconnect.php on line 2 I've tried looking on google for the NLS parameter but I'm not having much luck. Anyone able to help? Thanks! You probably need to set up some environment vars. Here's the ones I have set: export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1 export ORA_NLS33=/usr/lib/ora/ocommon/nls/admin/data export ORA_NLS=/usr/lib/ora/ocommon/nls/admin/data export ORACLE_HOME=/usr/lib/ora export ORACLE_BASE=/usr/lib Fix the paths, put those in your env, then restart apache and see if you still have the problems. -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Looking for simpler way to do this...
-{ Rene Brehmer }- wrote: I'm working with PHP 4.3.0 w. MySQL 4.0.14b on Windows XP I've written my own (pretty advanced actually - or it will be once I get the code completed) forum system (why? because I wanted to learn how to handle relational databases with PHP/MySQL, and then I just decided to complete the thing) ... it uses a multitude of 1-to-many relations across several tables, to keep track of categories, forums, threads, posts, perms, users and so on ... This particular chunk of code is part of the show forum code. What the first query does is pull out all the threads in the current forum ($forumID ... this valuable is set further up the code), and all the posts in each thread to find the last post in that thread. The second query is simply to figure out how many posts are in each thread. If at all possible, I'd like to combine these two query pulls (to keep the number of DB pulls per page down - there's currently 1 more, but going to be 2-3 more queries on this page than just this), but since I'm still rather n00bish at the SQL statements, I can't figure out how... Code in question: // get all the threads in current forum, and for each thread find the last post $threadquery = SELECT * FROM hf_threads,hf_posts WHERE hf_threads.forumID='$forumID' AND hf_posts.threadID=hf_threads.threadID GROUP BY hf_threads.threadID ORDER BY hf_posts.time DESC; $threads = mysql_query($threadquery) or die('Error in thread querybr'.mysql_error()); while($thread = mysql_fetch_array($threads)) { // info from hf_threads $threadID = $thread['threadID']; $threadtitle = $thread['threadtitle']; $threadmaker = $thread['createnick']; $threadstart = $thread['createtime']; // info from hf_posts $lasttime = $thread['time']; $lastposter = $thread['name']; // number of posts in thread $threadposts = mysql_fetch_array(mysql_query(SELECT COUNT(`postID`) AS numposts FROM hf_posts WHERE `threadID`='$threadID')) or die('Threadposts'); $numposts = $threadposts['numposts']; // output thread data echo(tda href=\showthread.php?forumID=$forumIDthreadID=$threadID\$threadtitle/a/td); echo(tdbBy:/b $threadmakerbrbAt:/b $threadstart/td); echo(td align=\center\a href=\editthread.php?forumID=$forumIDthreadID=$threadID\Edit/a/td); echo(td align=\center\$numposts/td); echo(tdbAt:/b $lasttimebrbBy:/b $lastposter/td\n); echo(td align=\center\input type=\Checkbox\ name=\del$threadID\/td); echo(/trtr\n); } Structure of tables in question: #TABLE hf_threads: threadID // ID of current thread forumID // ID of forum where the thread belongs userID // ID of thread creator (for perms reasons) createtime // time of thread creation createnick // name of thread creator threadtitle // title of thread sticky // not implemented yet closed // not implemented yet #TABLE hf_posts: postID // ID of post threadID // ID of thread where the post belongs userID // ID of poster (for perms reasons) name // name of poster time // time of post post // actual post content edit // tracking data of editings not that it's really relevant in this case, but these 2 tables are through the relations tied together with 8 other tables handling the forums and perms and users and statistics and such ... that's the reason why I want to keep the number of queries down, as it has to do join searches on a couple of these to handle the perms and other things on each page... TIA Rene SELECT threadID, COUNT(*) AS numPosts FROM hf_threads,hf_posts WHERE hf_threads.forumID='$forumID' AND hf_posts.threadID=hf_threads.threadID GROUP BY hf_threads.threadID ORDER BY hf_posts.time DESC You can also add more columns to the select. -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: how to work with www.ups.com.mx???
Desi wrote: I need a module in PHP to get the rates from this service, the tools are in XML but I need the module in PHP, to give the size and the weight and get the rate from this module. If you have work with this, please help me, or tell me if you can made it, how much will cost, and the time you can send it to me. Cheers. Desi. XML is just a data format, you can use it in PHP with no problem. You probably want to look into the XML processing features of PHP (http://php.net/xml) and possibly a SOAP or XML RPC implementation. I would suggest PEAR's. http://pear.php.net/package/SOAP http://pear.php.net/package/XML_RPC -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: cant insert into specific column in specific row...help?
Aj Seelund wrote: im trying to insert, or more or less, add to the number in a column called (comNum) in one a specific row in one table(dm_blog), and add other values to another table(comments). i have the comments table working fine, everything insert correctly, but im trying to add to the count (comNum) in dm_blog. im not quite sure how to go about doing this... im trying to select the cell and then add a value to it, but my targeting is off i think. heres a sample of the code im using: //if posting a comment do this: if ($comms==true) { //create a row in comments table $id is post number from dm_blog $id = $entryNum; if ($newTab==true) { //set comNum to 1 if no comment yet $comNum = 1; //insert the values into the table for the comment $commPost = INSERT INTO comments VALUES ('$id','$daUser', '$entryNumb', '$priv', '$comm'); $add_to_comNum = 'SELECT `comNum` ' . ' FROM `dm_blog` ' . ' WHERE 1 AND `entryNum` = ' . $id .' LIMIT 0, 30'; //this is where im confused... $commAdd = INSERT INTO dm_blog VALUES ('$id','$daUser', '$entryNumb', '$priv', '$comm'); $addComm = mysql_query($add_to_comNum) or die(error selecting and inserting $comNum into comNum on $id); //output the comment or errors $CommResult = mysql_query($commPost) or die((Error on line 70 of inputBlog.php) br /br / tableName:$theTable br / entryNum:$entryNum br / entryNumb:$entryNumbbr / priv:$priv br /usr:$daUserbr / comm:$comm); }else{ //insert the values into the table for the comment $commPost = INSERT INTO comments VALUES ('$id','$daUser', '$entryNumb', '$priv', '$comm'); $post = INSERT INTO dm_blog VALUES ('$comNum'); //output the comment or errors $CommResult = mysql_query($commPost) or die((Error on line 78 of inputBlog.php) br /br / tableName:$theTable br / entryNum:$entryNum br / priv:$priv br /usr:$daUserbr / comm:$comm); $result2 = mysql_query($post) or die((Error on line 85 of inputBlog.php) br / $post /td \n\r /tr \n\r /table /body/html); } while($myrow = mysql_fetch_array($CommResult)){ $p_entryNumb = $myrow[entryNumb]; $p_daUser = $myrow[daUser]; echo entryNumber: $p_entryNumb by [user: $p_daUser] has been addedbr /; } //if posting a new post in dm_blog do this: }else{ $post = INSERT INTO dm_blog VALUES ('$date', '$chapter', '$mood', '$theuser', '$message', '$entryNum' ,'$song','$t_level','$r_thought','$comNum'); $result = mysql_query($post) or die(Uh oh! You fucked up dumbass! (Error on line 85 of inputBlog.php) br / $post /td \n\r /tr \n\r /table /body/html); } thanks in advance -aj seelund [EMAIL PROTECTED] If you're trying to add to a column or change a field, you should be using an UPDATE SQL statement. -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: How to simplify DB creation?
Michal Masa wrote: Hi, We plan to write a simple DB with app. 10 tables. Are there any tools that simplify and automatize the creation of PHP scripts for the database? Like automatic generation of PHP scripts that produce HTML input forms, generation of value lists, validation, sorting and searching? Well documented PHP library could be also useful. Regards, Mike And the one that will do it all for you: DB_DataObject_FormBuilder Of course, you have to set up DB and DB_DataObject before it will work, but it is very featureful and customizable. Just ask on the pear general list if you need help. http://pear.php.net/package/DB_DataObject_FormBuilder -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: ?DHTML Layers with PHP?
Mark A Galbreath wrote: I've been sitting here all morning wracking my brains for a way to code a hierarchical menu tree with JavaScript from database data retrieved by PHP, so that the child menus appear on a mouse click. Can PHP do this without JS? The only JS examples I can find use static menu trees, not dynamic data. tia, Mark The short answer is No. PHP is a server-side scripting language, meaning that things can't change on the client side (browser) unless the user makes a new request. All of the text (HTML, JS, CSS, etc.) sent by PHP to the browser is static until the user sends another request. If you want DHTML, you have to use JS. (It's part of the definition of DHTML ;-). If you still don't understand, you might want to check out some PHP tutorials or read some of the basics in the PHP manual. (http://php.net/manual) -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL - separating web and database servers
Operator wrote: On 18 Mar 2004 at 14:24, Ricardo Lopes wrote: in your php.ini you have mysql.default_host, mysql.default_user and mysql.default_password which are used if: a) you are not in safe mode b) you supply no string for those parameters. But i guess this is not your case, i think this doesnt help, Exactly... but i had an ideia, you could set your server (http) to work as a router and make something like a port-forwarding to the other server, like routers do, one ip could be used be several machines, depending on the port is accessed the data is forwarded to that port. This is just an idea i had right now, i dont know if it can be used or if it works but and least appears to logical and implementable. Good luck. And this is how I want it to be done, but in the localhost case unix socket is used, not 127.0.0.1:3306 which I could forward wherever I want. Probably I need to change this behaviour in ext/mysql/libmysql/libmysql.c for my installation, but this is my last hope (mostly because I'm not a C programist...) If some of you could tell me if it's possible without breaking something else, or point me to the lines that do the job... I suppose the change needed would be quite simple. PB I agree with all of the others, you should not be hacking your way around this as it will make lots of problems. You just need to tell your users to switch their scripts to using the new host. Here's the solutions I use. Put all of your connection info in one include and include it any time you need to connect. This way, you have only one file to change, ever. -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Processing a fetched external page
Donovan Hutchinson wrote: Hi, I'm working on a project that takes the content of a URL and does stuff with the content. I've managed to extract the target url's html, and am using str_replace to fix links, stylesheets etc. However, i'm stumped when it comes to processing the text content. Would anyone know how to isolate displayed text (anything in the body, paragraph text, headings etc) and then manipulate this text on a word by word basis? Any suggestions appreciated, Don Well, this kind of regluar expressions should be able to find what's in a p tag. /p[^]*(.*?)\/p/ -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Processing a fetched external page
Donovan Hutchinson wrote: Thanks for the fast replies. I understand about stripping tags and identifying areas using regular expressions, however my intention is to display the page intact, with only the content changed. An example being http://www.pootpoot.com/poot/pootify/ Thanks, Don If you're changing the content it's not really intact... ;-) A regexp can do replacement as well with preg_replace. If we haven't answered your question, maybe you need to rephrase it? -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Inserting Data in Multiple Tables - MySQL
Craig Hoffman wrote: Is it possible to write one INSERT statement to populate multiple tables? __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimb.net _ Nope. One record, one insert. Well, actually, some DBs support multiple inserts with one query (such as mysql 4) but not into multiple tables. -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Inserting Data in Multiple Tables.. again
Craig Hoffman wrote: Here is the problem I am experiencing: I have a form that collects data and I would like it to send it to three tables in a MySQL DB. One table is called TRAININGLOG , other is called CORE and the third is USERS. The USER table is the main table that contains the primary key. My question is, what is the correct way for handling something like this? Do I need to write three separate queries (INSERT) statements? I am using MySQL 4.0.17 if that helps? Thanks in advance, Craig __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimb.net _ You need three seperate queries. -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: need to select one cell from one row in one table...?
Aj Seelund wrote: ok, this might be difficult to explain, but this is what im trying to do... i have a table in my db call db_blog. in it i have an auto_increment column called entryNum. i use that strictly for order when i view the blog. i also have a column called comNum. each row in the table is an entry in the blog, and has comments (comNum) i have a variable called $comNum that is used to count how many comments are per entry in the blog. example, entry number 1 has 3 comments, and entry number 5 has 0 comments. if there are no comments on the entry, and the user wants to make one, and if statement decides whether to display or input into the db. that works fine. now, when i input lies the problem. i want to input data in a newly created table called $entryNum_comms (xx_comms) AND add to the number in the comNum column for THAT entry in dm_blog. example: i am making the first comment on entry number 74 in db_blog. comNum in dm_blog should change form 0 to 1 and the data fromt he form should be inserted into 74_comms, a newly created table for that entry. example 2: i am making the 3rd comment on entyr number 94 in db_blog. comNum in db_blog should change form 3 to 4 and the data from the form should be entered into the already created table 94_comms. the only thing i am stuck on is entering the data into the two different tables. here is the code im using: if ($comms==true) { //define a table name based on main Post number $theTable = $entryNum . '_comms'; if ($newTab==true) { //create a table $sql = 'CREATE TABLE ' . $theTable . ' ( `daUser` VARCHAR( 255 ) NOT NULL ,' . ' `entryNumb` INT NOT NULL ,' . ' `priv` VARCHAR( 1 ) NOT NULL ,' . ' `comm` BLOB NOT NULL ,' . ' PRIMARY KEY ( `entryNumb` ) )'; $resulter = mysql_query($sql) or die(There has been an error creating table: $theTable br / newTab = $newTab); //insert the values into the table for the comment $commPost = INSERT INTO $theTable VALUES ('$daUser', '$entryNumb', '$priv', '$comm'); //output the comment or errors $CommResult = mysql_query($commPost) or die((Error on line 70 of inputBlog.php) br /br / tableName:$theTable br / entryNum:$entryNum br / entryNumb:$entryNumbbr / priv:$priv br /usr:$daUserbr / comm:$comm); }else{ $select_comNum = 'SELECT `comNum` FROM dm_blog' //insert the values into the table for the comment $commPost = INSERT INTO `' . $theTable . '` VALUES ('$daUser', '$entryNumb', '$priv', '$comm'); $post = INSERT INTO dm_blog VALUES ('$comNum'); //output the comment or errors $CommResult = mysql_query($commPost) or die((Error on line 78 of inputBlog.php) br /br / tableName:$theTable br / entryNum:$entryNum br / priv:$priv br /usr:$daUserbr / comm:$comm); $result = mysql_query($post) or die((Error on line 85 of inputBlog.php) br / $post /td \n\r /tr \n\r /table /body/html); } while($myrow = mysql_fetch_array($result2)){ $p_entryNumb = $myrow[entryNumb]; $p_daUser = $myrow[daUser]; echo entryNumber: $p_entryNumb [user: $p_daUser] br /; } //echo posting a comment; //if posting a new post do this: }else{ $post = INSERT INTO dm_blog VALUES ('$date', '$chapter', '$mood', '$theuser', '$message', '$entryNum' ,'$song','$t_level','$r_thought','comms'); $result = mysql_query($post) or die((Error on line 85 of inputBlog.php) br / $post /td \n\r /tr \n\r /table /body/html); } thanks in advance -AJ Seelund [EMAIL PROTECTED] You say you want to make a new table and then put a record in it? I don't see how that has anything to do with your subject. You just need to run a create table query first, then insert a record, then update the comNum in the other table. Three seperate queries. -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: MySQL Backups
Jai Jones wrote: Hi Everyone. I have MySQL databases on various servers, I'd like to know how people automate backups. I imagine there would be lots of scripts and products that do this, I've tried a few, but I guess I'll have to write something myself to do it. I'd be very interested in learning from others who can share experiences/methods. Something simple is all I need :) I would ideally like to backup to a separate Linux server. All the servers are in different remote locations and bandwidth isn't an issue. Please feel free to send me your ideas or scripts off list :) Thankyou! Jai _ MSN Messenger: instale grátis e converse com seus amigos. http://messenger.msn.com.br Try the shell command mysqldump. -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Creating query with multi-dimensional array
Lisi wrote: I have a form that allows users to edit an entry in a database. It displays the current values in a textbox/select box/textarea depending on the type of data (text, enum, etc). The same form is used for different tables, so no values are hard coded. Field names are retrieved with a show columns query and then content is retrieved with a select query. This works fine for almost all fields, I am having trouble with the field that is of type set. I build the REPLACE query by listing the values entered into the form. The first thing I do is loop through the $_POST variable and create two arrays - one with the keys, and one with the values. So the variable $vals is an array that holds the data the user has entered, and in theory the REPLACE statement could be REPLACE INTO table ($key) VALUES ($vals), if I could list the values of $keys and $vals as follows: (field1, field2, field3) VALUES ('data1', 'data2', 'data3'). I wrote the following function to loop through the array values and list them as needed for the query (separated by a comma, surrounded by single quotes - yes, I know the quotes haven't been added yet): function print_array($arr) { //This function takes an array and lists all values in a comma-separated list //for easy printing in a query or web page $count = count($arr); $last = $count - 1 ; for ($i = 0; $i $count; $i++) { if (is_array($arr[$i])) { /PROBLEM***/ $count2 = count($arr[$i]); $last2 = $count2 - 1 ; for ($j = 0; $j $count2; $j++) { $list .= $arr[$i][$j]; } /PROBLEM***/ } else { $list .= $arr[$i]; } if ($i != $last) { $list .= , ; } } return $list; } The problem is that if a value in the array is itself an array, for instance a field of type set that has more than one value chosen, it's not listing the values of that array, just the word array. I tried making it a recursive function if (is_array($arr[$i])) { print_array($arr[$i]); } but that also just gave me Array, so I tried duplicating the code, as you can see in the function above, but this didn't work either. I feel like there must be something obvious I'm missing, but I just can't see it. The code for the form itself is select name=Category[] SIZE=5 MULTIPLE so it is being passed as an array, and I can do print_r of the specific variable and see the array values. I just can't get them to print properly in my query. The other odd thing is that when I do print_r($vals) it also shows me Array for the field that is an array, instead of showing me the values. But when I do print_r($Category) it does show me that it is an array. Can anyone help? TIA, -Lisi What code are you using to set $vals. In other words, I'd like to see what you're doing with the $_POST data before you send it to print_array(). -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: help w/ multidementional array in mysql
Scott Phelps wrote: Thanks in advance for reading this: I am trying to take a query based on user input and selectively output fields to a table. Heres the query code: snip - snip $query_result = mysql_query($query); while ($field = mysql_fetch_array($query_result)) { $returned_rows = array( array( id=$field['id'], lastname=$field['lastname'], firstname=$field['firstname'], yearhired=$field['yearhired'], yeardepart=$field['yeardepart'] ) ); } snip - snip Now what I want to do is put only the lastname and firstname in a small table with alternating colors: Like this: - | $lastname, $firstname | --- color=blue - | $lastname, $firstname | --- color=white - | $lastname, $firstname | --- color=blue - Heres the code: snip - snip table class=results_inner ?php foreach ($returned_rows as $value) { printf (trtd class='results_blue'%s, %s/td/trbr, $value['lastname'], $value['firstname']); next($returned_rows); printf (trtd class='results_white'%s, %s/td/trbr, $value['lastname'], $value['firstname']); } } ? /table snip - snip The problem is that it only prints one name. Also next() doesn't seem to be advancing the table so I am getting duplicates of the one name it does print to the table Thanks. First of all, $returned_rows = array(array(...)); Will just give you an array with one thing in it, however may rows are returned. Second, you don't have to recreate the returned row. This should work much better: $query_result = mysql_query($query); $returned_rows = array(); while ($field = mysql_fetch_array($query_result)) { $returned_rows[] = $field; } Third, foreach() is already looping through your array, so you don't have to use next(). In addition, foreach() loops through a *copy* of the array, so using next() doesn't actually do anything to the values you're using. Basically what you're doing in that loop is looping through the original array *and* a copy of it. You need to just loop once and output one record in the loop. Fourth, printf() is pretty slow compared ot print and echo. It is really only useful if you need extended formatting. If all you're doing is putting strings in another string, it's much cleaner and easier to read using print or echo. table class=results_inner ?php foreach ($returned_rows as $value) { echo 'trtd class=results_blue'.$value['lastname']. ', '.$value['firstname'].'/td/trbr'; } ? /table -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Storing a php variable in MySQL
Daniel Crespo wrote: Hi there. I want to save a variable (its structure and data) in MySQL. I know the function serialize(mixed value), wich generates a storable representation of a value. This storable representation has characters like { and : (when talking about arrays). So, how can I store this in MySQL? Wich type of field do I have to create in de DB? I tried the longtext type, but it doesn't work. Any help? Thanks. How did it not work? If there was an SQL error, you may want to run addslashes() on the serialized data befre storing it. -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Fw: [PHP-DB] Re: help w/ multidementional array in mysql
;-) table class=results_inner ?php foreach ($returned_rows as $key = $value) { echo trtd class='. ($key 1 ? 'results_blue' : 'results_white').'. $value['lastname']., .$value[firstname]./td/trbr; } ? /table -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: mail() and sendmail configuration
[EMAIL PROTECTED] wrote: Good Morning, This post is somewhat OT -- please forgive me. I've spent over 3 days trying to get sendmail configured and I've lost some patience and reasoning ability in the process. I have a Linux (RH9), Apache 2.0.48, PHP 4.3.4, MySQL GUI that creates a PDF document on the server for web access. We would also like to have the document emailed to several folks within the company. So I essentially have to get the PDF attached to an email and routed to our SMTP server. I have webmin installed and have tried to use it to configure sendmail. When I execute /etc/rc.d/init.d/sendmail status --- Linux says that sendmail is running. I'm using this method for creating emails with attachments (which was posted on the PHP-WIN list several months ago ), but it is failing: ?php $fileatt = ; // Path to the file $fileatt_type = application/octet-stream; // File Type $fileatt_name = ; // Filename that will be used for the file as the attachment $email_from = ; // Who the email is from $email_subject = ; // The Subject of the email $email_txt = ; // Message that the email has in it $email_to = ; // Who the email is too $headers = From: .$email_from; $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); $semi_rand = md5(time()); $mime_boundary = ==Multipart_Boundary_x{$semi_rand}x; $headers .= \nMIME-Version: 1.0\n . Content-Type: multipart/mixed;\n . boundary=\{$mime_boundary}\; $email_message .= This is a multi-part message in MIME format.\n\n . --{$mime_boundary}\n . Content-Type:text/html; charset=\iso-8859-1\\n . Content-Transfer-Encoding: 7bit\n\n . $email_txt . \n\n; $data = chunk_split(base64_encode($data)); $email_message .= --{$mime_boundary}\n . Content-Type: {$fileatt_type};\n . name=\{$fileatt_name}\\n . //Content-Disposition: attachment;\n . // filename=\{$fileatt_name}\\n . Content-Transfer-Encoding: base64\n\n . $data . \n\n . --{$mime_boundary}--\n; $ok = @mail($email_to, $email_subject, $email_message, $headers); if($ok) { echo font face=verdana size=2The file was successfully sent!/font; } else { die(Sorry but the email could not be sent. Please go back and try again!); } ? I've examined the content of the variables in this expression (from above) [[$ok = @mail($email_to, $email_subject, $email_message, $headers) ]] and it looks ok, though I'm no expert, so I'm guessing that the problem lies within the sendmail configuration. Webmin has loads of config pages for sendmail, and I admit that they're overwhelming right now. It seemed to me at first a relatively simple task to have an email created on the server, and forwarded to our SMTP server for delivery, but I was obviously naiive in this assumption. If anyone has suggestions or knows of helpful links or tutorials, I'd be deeply obliged. Thanks for reading this long post. David Sounds like a doozy of a problem. Fixing the local machine is a good thing, but to get around it you could use PEAR::Mail's smtp backend. require_once('Mail.php'); $mail = Mail::factory('smtp', array('host' = 'your.relay.com', 'port' = 25, 'auth' = true, 'username' = 'user', 'password' = 'pass')); $mail-send('[EMAIL PROTECTED]', array('From' = '[EMAIL PROTECTED]', 'Subject' = 'Test e-mail'), 'This is a test e-mail.'); Note that you can remove the port, auth, username, and password entries if you don't need them. You can also use this with PEAR's Mail_Mime package to easily create and send multipart messages. http://pear.php.net/package/Mail http://pear.php.net/package/Mail_Mime -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Storing data in a file
Todd Cary wrote: I have a client that does not want to use a DBMS for storing the email addresses the surfers input. Is there a class available that has a search function as well as an append? I would like to have several fields separated by a tab or : . Todd I have heard that SQLite is pretty nice in this regard. It implements a basic database system but without having to run a seperate database process. (Honestly, running mysql isn't that hard, but...) -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP] Re: [PEAR] Re: PEAR DB 1.6.0 has been released
Richard Davey wrote: Hello Justin, Monday, February 23, 2004, 5:30:16 PM, you wrote: JP The real hairy part is dealing with joins as the syntax is very JP different across the DBs. This can be solved by simply not doing them or I wish :) JP using a syntax that most use. Or you can try to use DB_DataObject, but JP I'm not sure it works for all DBs yet. Yeah, I thought as much. I think if I was creating an application to be distributed open-source on the Internet it'd make life easier for other developers if it used something like the PEAR-DB class, but when you're building your own/companies site and know the environment it lessens the value somewhat. It's still nice for all of the other reasons I mentioned. -- -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PEAR] Re: PEAR DB 1.6.0 has been released
Lukas Smith wrote: Justin Patrin wrote: I think you're confusing the issue. PEAR DB does support many databases, but it only loads the code for the ones that you are currently using. So if you're using one database it is effectively a one database API. Jakes wrote: What is performance like using this class? I've gone through the class and it just seams to be over kill, for a DB API (13 databases). Are there any time stats showing the different time in using a single DB API class to the PEAR class. Yes things are really not that bad. However expect to give up somewhere a fairly significant amount of performance. If you are using an abstraction layer you have to do it with a good reason (you need to support multiple databases mainly :-) ). Here is a benchmark John Lim came up with: http://phplens.com/lens/adodb/ It only tests MySQL though and it implements a very unrealistic scenario. The reason that ADODB scores so high can be read here: http://marc.theaimsgroup.com/?l=pear-devm=100793507904834w=2 Well, yes, you're going to lose some processing time using an abstraction layer, but IMHO the pros far outweight the cons, even if you don't need ot support multiple DBs. 1) Many very useful utility functions which will give you the data you want and automatically free resources for you, such as getRow(), getAll(), and getOne(). 2) Good and easy to use error handling (this is very important, believe me). 3) A unified architecture for mysql and Oracle. You don't have to remember different functions for use with different databases. 4) You never know when you might want to switch to another DB. 5) You never know someone else using your code might want to switch to another DB. The company I'm at now had an abstraction layer of their own (for all of these reasons) and it wasn't nearly as good as PEAR DB even after all of the work I put into it. I just didn't have the time to deal with it all on my own. I'd much rather use PEAR DB which has lots of developers working on it and using it, finding bugs and making patches. :-) -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP] Re: [PEAR] Re: PEAR DB 1.6.0 has been released
Richard Davey wrote: Hello Justin, Monday, February 23, 2004, 4:11:40 PM, you wrote: JP3) A unified architecture for mysql and Oracle. You don't have to JP remember different functions for use with different databases. That abstraction only abstracts the functions to connect to, select and query the database, surely? Oracle/SQL Server/MySQL all use slightly different SQL syntax - so if the query you pass in has to be unique depending on the database in hand - you're already having to remember a stack of system specific SQL and will have to code your application to take into consideration all of those different syntax. What I'm trying to say is that abstracting the connection to the database is the easy part, writing an application that will support them all is another matter. Very true. In that case, you can use a package such as DB_DataObject or DB_QueryTool to abstract the SQL as well. Or you can use fairly simple SQL with just a few rules and you should be fine. For instance, always select columns as upper case (for Oracle compatibility) or always convert them to lower case (DB_PORTABILITY_LOWERCASE), always use DB::quoteSmart() for values and DB::quoteIdentifier() for table / column names, etc. The real hairy part is dealing with joins as the syntax is very different across the DBs. This can be solved by simply not doing them or using a syntax that most use. Or you can try to use DB_DataObject, but I'm not sure it works for all DBs yet. -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: PEAR DB 1.6.0 has been released
I think you're confusing the issue. PEAR DB does support many databases, but it only loads the code for the ones that you are currently using. So if you're using one database it is effectively a one database API. Jakes wrote: What is performance like using this class? I've gone through the class and it just seams to be over kill, for a DB API (13 databases). Are there any time stats showing the different time in using a single DB API class to the PEAR class. Thanks Daniel Convissor [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [This has be cross-posted. Be careful when following up, please.] Greetings: Crack open the beer, PEAR DB 1.6.0 is here! (Hey, I'm a bit giddy with excitement that my intense work during the past seven weeks has come to fruition.) For those unfamiliar with PEAR DB, it's a package of PHP classes that provide an object oriented API with common methods of accessing thirteen of PHP's database driver extensions: dBase, FrontBase, InterBase, Informix, mSQL, MS SQL Server, MySQL, Oracle, ODBC (tested with DB2 and Access), PostgreSQL, SQLite and Sybase. Key links for PEAR DB: Download:http://pear.php.net/get/DB Change Log: http://pear.php.net/package-changelog.php?package=DB Manual: http://pear.php.net/manual/en/package.database.php Home Page: http://pear.php.net/package/DB Notable changes since 1.5.0RC2 include: * New portability features, making it possible to write applications which can be easily ported between DBMS's. * Tons of bug fixes, making the package actually work for more than just MySQL systems. * Improved error reporting. * Getting prepare/execute to work the same way for all DBMS's and allow escaping of placeholder characters. * Deploying tableInfo() in more drivers and officially moving it from DB_result to DB_common. See the documentation for proper usage. * Making the test suite simpler to use and work on both windows and *nix platforms. * Various optimizations, several of which were uncovered using Zend Studio's Code Analyzer. * Countless documentation corrections. * Full PHP 5 compatibility. * Requiring PHP to be at version 4.2.0 or higher. * Deprecating quote() and quoteString(). If you're one of the lucky few people using PHP's mysqli extension, do note that the DB file/class has been renamed from mysql4 to mysqli, but the online documentation won't reflect this modification until they're rebuilt on Sunday. Similarly, there are a few other features and documentation bugs that won't show up there until then either. Is Dutch, German or Russian your native language? The manual needs translating into these languages. Join in by signing up for the pear-doc mailing list at http://pear.php.net/support.php. For those of you in and around New York City this coming Tuesday, February 24th, I'll be giving a presentation about this at the NYPHP meeting. See http://nyphp.org/ for more info. If you like the changes I've made to DB since version 1.5.0RC2, make a donation: http://www.analysisandsolutions.com/donate/donate.htm Enjoy, --Dan PS: I'm not on this list/newsgroup. Just posting this as an announcement. So, if you wish to contact me, please do so directly or via cc. -- T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y data intensive web and database programming http://www.AnalysisAndSolutions.com/ 4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409 -- -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: SUM and JOIN together
Rogue wrote: Hi all, Not sure how to handle this situation and was hoping someone with a bigger brain then me could help. 2 tables tbl_hoursbought id | client | hours 1 | test | 5 2 | test | 10 tbl_hoursused id | client | hours 1 | test | 3 What I am trying to do is sum the hours bought and the hours used, then subtract the values to get the available hours. The problem I am having is that I get a multiple (based on how many rows are in the first table) of the value in the second table. Here is my query: select sum(tbl_hoursbought.hours) as bought, sum(tbl_hoursused.hours) as used from tbl_hoursbought left join tbl_hoursused on tbl_hoursbought.client = tbl_hoursused.client and tbl_hoursbought.client = $id So my results return 15 for bought (which is correct) but I get 6 for used since there are 2 rows in bought (I think). I figure I could just divide that by the number of results, but is there a 'correct' way of doing it in the SQL statement? Thanks for any help. Please copy me with any replies as I am on the digest. thanks, rogue You're trying to do completely unrelated sums. The join really has no relevance to this (you're not *really* trying to join records). The only way to do this in one query (I think) is to use subqueries, which isn't in mysql yet. I'd suggest doing multiple queries. -- -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Need some help please!
BUTTON STYLE=position:absolute;top:150;left:250;width:auto;height:50 onclick=location.reload()? echo $txt_playagain; ?/BUTTON /DIV ? } else { echo $error; } ? /center /BODY /HTML It's a scartchy game, 3 boxes, run your mouse over them to scratch, if you win it pops up a java box saying you won and your Username. What I want to do is do a query to a db and update an accounting table to credit users account if they win, and if they lose do nothing. But I am not sure what to add with this code... Does the page need to refresh to do a insert query or can it do it some other way? When they win they get a popup, page does not refresh, to play again it restarts. Is there a way to credit the account without refreshing? If worst comes to worst I guess I could redirect the user to another page to credit accounts, but this would take them away from game and is not ideal. Ideas/code welcome here. Jerry Find local movie times and trailers on Yahoo! Movies. http://au.movies.yahoo.com -- -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Is it safe to do this?
Jerry wrote: That depends on what you're doing. Here's why I can't provide feedback: 1) Your code isn't at all complete, the foreach isn't even finished. Not what matters here, I just snipped a bit of code in here. I'm not even concerned about it because the code works fine. I just need some work on a query. 2) Where does the $addresses variable come from and what are you trying todo with it? Again it's a snipped code. $addresses collects information from an emails. It searches for special characters only, if no matches it does nothing, if a match it runs a query. So looks for matches such as @, +, _ for email addresses in the original email sent, minus the headers. 3) What is the mysql table and its columns supposed to represent? What is the mysql table? I'm not sure what your asking here. What's it for? For my site. Why do you need me to explain that? I think my query explains what's going on here. Another person responded to me about this and new exactly what I was trying to do. But for the record it's for a bouncing email script. To handle bounced emails, again it's only a bit of snipped code, the rest is fine. 4) What is this code supposed to accomplish? Bounced emails, if an email is bounced it will do a search and do something if and flag account if it's bad. If it finds an email that is not in the DB it also does nothing. (spam emails mainly go into that account) As for the query. I want to change a value of a field when it reaches a certian value. So was wondering if it was safe to change a value in one field once it reaches a set value. Okay with my program site emails that have a email_setting of: 0 - All emails go to external inboxes and internal inboxes 1 - All emails go to external inboxes and not internal 2 - All emails go to internal inboxes and not external Each user can toggle what they want, ext. is real email addresses... int. is the internal one with the account which is not an email just an inbox. So when it reaches a value of -5 means it's bounced 5 times therefore needs to be set to a lower value so emails are not sent. So I have: field1 field2 field1 - is used for 0 , 1 , 2 value to send emails to inboxes internal and external. Anything set in negative figures no internal or external email will be sent to that user. field2 - is used to track the number of times the email has bounced. So when it reaches 5 I need to handle it and reset filed1 to a negative value. So regarding my first example, it's no longer used by me and won't go back to it. But is example 2 going to work? ... UPDATE users SET email_setting='-1' WHERE emailerror 5 ... will that set email_setting to -1 if emailerror has a value of 5 or more? Yes, it will. -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Interbase: How to get table structure via SQL ?
Dizem Pgc wrote: Hi, ...table structure without PEAR ? Is it possible to accomplish this by a sql-statement or do I really HAVE TO install this xtension (PEAR) ? Cuz I've already written a few scripts containing many function calls (self written classes, too). I read the PEAR extension organizes everything with packages. So, if I install PEAR, do I have to change all my function calls? I'd like to find a more 'simple' solution for my problem. (P.S.: Thx to R.Hutchins 4 answering quickly!) Bye, DiZEM No you don't have to install PEAR. It just uses SQL to do it all anyway. This SQL works in other DBs (not sure about Interbase): DESCRIBE table And no, you don't have to convert all of your old code if you do install PEAR packagesthat is, as long as your names don't clash. I highly recommend at least looking at PEAR's DB. Or even DB_DataObject. It gives a lot of (highly tested) high level abstraction and easy to use functions. It's quick to use and shouldn't slow down your scripts any (especially if you did convert everything to use PEAR). Plus you get free updates without having to do all of the debugging and such on your own. Add to that standardization and all of the other packages you can use. :-) -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: oracle: fetch a query result into an array
To make your life much easier, I recommend using PEAR DB. The function calls are very easy and work for any DBMS (no remembering DB specific calls :-)). It also gives you lots of added functionality, such as fetching of an entire result set at once, fetching only one row, or even fetching one column quickly and without the need to worry about freeing your resources. Used right, you don't have to worry about memory leaks or even the DB backend you're using. http://pear.php.net/package/DB http://pear.php.net/manual/en/package.database.php Torsten Lange wrote: Hello, I'm a php beginner and not succeed in fetching an oracle query result into an array. I want to load the colum names of a table (from an Oracle9i) into a select-field. There is something working, but only the last column name appears in the select field and is wraped by each letter. For instense acw_fid_lab: ___ |non| |all| |A | |C | . . and so on. What are my mistakes? If anyone could suggest me how to solve it or using a better approach... Thank you, Torsten --- My last version (I also tried OCIFetchInto before): --- function fill_select($table_name) { $connect = @OCILogon(, , ); if(!$connect) { $err_oci = OCIError(); echo (2) No connection - OCIError(): nbsp;nbsp;nbsp;.$err_oci[message]; echo p; } else { $sql_table_names = SELECT column_name FROM user_tab_columns WHERE table_name = '.$table_name.'; $stmt = OCIParse($connect, $sql_table_names); OCIExecute($stmt); $column_name = array(); $counter = 0; while(OCIFetch($stmt)) { $column_name = OCIResult($stmt,'COLUMN_NAME'); $counter++; } if($counter == 0) { $column_name[0] = nothing found; } OCIFreeStatement($stmt); OCILogOff($connect); return($column_name); } } # This is a cut-out from that file I call the function from echotd\n; echoselect name=\chemistry\ size=\12\ multiple\n; echooptionnone/option\n; echooptionall/option\n; $table_name = AN_CHEMISTRY_WATER; $count = (int) count_table_columns($table_name); $column_names = fill_select($table_name); for($i=1; $i=$count; $i++) { echo option,$column_names[$i],/option\n; } echo/select\n; echo/td\n; -- -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Is it safe to do this?
That depends on what you're doing. Here's why I can't provide feedback: 1) Your code isn't at all complete, the foreach isn't even finished. 2) Where does the $addresses variable come from and what are you trying todo with it? 3) What is the mysql table and its columns supposed to represent? 4) What is this code supposed to accomplish? Jerry wrote: Hi, Is it safe to do this: snip foreach ($addresses as $email) { $body = str_replace($email, $comp_uri, $body); mysql_query (update users SET email_setting='-1' WHERE email='$email') or die (Can't set email_setting); mysql_query (UPDATE users SET email_setting='-1' WHERE email_setting -5) or die (Unable ); /snip Or would I be better to do this?: snip foreach ($addresses as $email) { $body = str_replace($email, $comp_uri, $body); mysql_query (update users SET emailerror='+1' WHERE email='$email') or die (Can't update email_setting); mysql_query (UPDATE users SET email_setting='-1' WHERE emailerror 5) or die (Unable ); /snip Suggestions welcome. Jerry Find local movie times and trailers on Yahoo! Movies. http://au.movies.yahoo.com -- -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Database Abstraction Layer?
I like PEAR::DB myself, especially since so many other PEAR packages build upon it. To make your code even more DB independant, you can use a package which builds the SQL for you, such as DB_DataObject. It can also quote table / column names and values correctly per DB. (Although DB hasn't been uypdated yet with my patch to support table and column quoting.) Muhammed Mamedov wrote: Thanks Ricardo for your comments. What do you think guys: ADODB or PEAR::DB ? - Original Message - From: Ricardo Lopes [EMAIL PROTECTED] To: Muhammed Mamedov [EMAIL PROTECTED] Sent: Wednesday, January 21, 2004 11:21 AM Subject: Re: [PHP-DB] Database Abstraction Layer? You have ADODB and PEAR DB that both work as abstraction layer. I have used ADODB and seems to me that is very good, yet i have not tested PEAR DB... To make php code 100% database independent is not very easy, depends of what are you going to do with your code. Use the ADODB or PEAR functions every time possible, and avoid the using of sql statements in your code because you have to carefull design then to be database independent but that can be a very difficult task. - Original Message - From: Muhammed Mamedov [EMAIL PROTECTED] To: phpdb [EMAIL PROTECTED] Sent: Wednesday, January 21, 2004 8:31 AM Subject: [PHP-DB] Database Abstraction Layer? Hello everybody, What do you think is the best method to abstract php code from a specific database?. Make PHP code 100% database independent?.. Waitin' for your comments. Muhammed Mamedov -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Database Abstraction Layer?
There's also PEAR's DB_DataObject which does build SQL for you. The join syntax isn't set up to be totally DB independant yet, but it can and will be. Paul Miller wrote: PEAR is great from what I hear. The issue you are going to run into with DB independence is not the function calls which could be handled with something as simple as sqlalphp. It is the SQL calls themselves. The two options I have found is a SQL library with unembeded SQL or the Propel solution. Either way adds a significant time to coding and product release initially. - Paul -Original Message- From: Muhammed Mamedov [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 21, 2004 10:07 AM To: [EMAIL PROTECTED]; phpdb Subject: Re: [PHP-DB] Database Abstraction Layer? Hmm.. Thank you for you sql picks:) But what do you guys think aabout Pear :: DB? Is it as effective as these Paul's picks? Thank you. Muhammed Mamedov - Original Message - From: Paul Miller [EMAIL PROTECTED] To: phpdb [EMAIL PROTECTED] Sent: Wednesday, January 21, 2004 5:44 PM Subject: RE: [PHP-DB] Database Abstraction Layer? There are a couple of products out there that I am about to start testing, starting first with: - SQL Relay http://sqlrelay.sourceforge.net/ This product uses its on C interfaces to interact with DBs and different programming languages. It addresses a bunch of items in the PHP DB calls. Connection pooling and load balancing. - Propel http://propel.phpdb.org/ Extensive templates create the SQL definition files you need to setup your database and the classes you need to work with your data model in your PHP scripts. The classes for your object model are generated from a simple XML schema and any customizations are written in plain PHP. This will effectively that add SQL and DB dependence out of your mix. This is PHP5 also. HTH - Paul -Original Message- From: Muhammed Mamedov [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 21, 2004 2:31 AM To: phpdb Subject: [PHP-DB] Database Abstraction Layer? Hello everybody, What do you think is the best method to abstract php code from a specific database?. Make PHP code 100% database independent?.. Waitin' for your comments. Muhammed Mamedov -- 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 -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Subselect ?
Christine Clerc wrote: Hi, I have a Mysql table of texts in different languages : id_readme id_script (the object that the text describes) id_language (the language the text is written in) etc. So two texts may have the same id_script but with different id_language. I need to retrieve the list (without duplicate) of id-script that are described in one language and NOT in another. Is there hope ? Any help would be welcome. Chris Maybe give us a sample of the SQL you wish to use? You can probably get it done without a sub-select. That being said, the newest versions of MySQL support sub-selects, but you'd have to use an unstable version. -- paperCrane Justin Patrin -- Question Everything, Reject Nothing -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: passing a $_POST variable
[EMAIL PROTECTED] wrote: Good day all, This may be easier than I'm imagining... The question: When using the header(location: ...) method for inserting or updating some $_POST['variable']'s into a MySQL db (preventing repeat insertions or updates when 'refreshing', etc...), is it possible to return a $_POST['variable'] from the page that does the insert? I'm imagining that I'd have to have a form on the insert page with a hidden field to hold the values(s). But using this line of reasoning, I'm stuck at how the form would be submitted. Maybe I'm missing something, but if you want to show the updated info for that computer, why not just pull the updated data fromt he DB, just as you must be when you initially create the page? If that's not what you meant, why not do the insert and such, then display the page without using header()? Or, if there is an error, display the error, use the current $_POST entries to fill out the form again, then on a sucessful post, insert, then refresh. -- paperCrane Justin Patrin -- Question Everything, Reject Nothing -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Unsubscribe User Fabio Farinelli - Headers Needed
Richard Hutchins wrote: PHP-List-Admin, Every time a user posts to the php-db list, the message below is automatically sent to the sender. This has been a problem for many months now and frequently sparks multiple requests from frustrated users to have [EMAIL PROTECTED] removed from the list. Can you please remove the user from the list? I do not have the headers for this particular e-mail, but am copying the list in hopes that someone WILL have the original headers and can attach them to this mail and forward it along. (message appears below) Subject: L'utente Fabio Farinelli ha cambiato indirizzo di posta elettronica. Il nuovo indirizzo è: [EMAIL PROTECTED] La mail è stata comunque inoltrata entro 60 minuti al nuovo indirizzo di posta. Si consiglia sin da subito l'utilizzo del nuovo indirizzo; a breve il vecchio indirizzo verrà inattivato. Questa è una mail di servizio. NON rispondere. Here's the headers I got from the return e-mail: From [EMAIL PROTECTED] Fri Jan 16 08:37:08 2004 Return-Path: [EMAIL PROTECTED] Delivered-To: [EMAIL PROTECTED] Received: (qmail 18100 invoked from network); 16 Jan 2004 08:37:08 -0800 Received: from smtp.easydns.com (HELO carnage.easydns.com) (216.220.40.247) by c-24-5-55-230.client.comcast.net with SMTP; 16 Jan 2004 08:37:08 -0800 Received: from www.asl.pavia.it (www.asl.pavia.it [212.210.13.254]) by carnage.easydns.com (Postfix) with ESMTP id EF2B14CA96 for [EMAIL PROTECTED]; Fri, 16 Jan 2004 11:55:13 -0500 (EST) Subject: L'utente Fabio Farinelli ha cambiato indirizzo di posta elettronica. Sender: [EMAIL PROTECTED] To: Justin Patrin [EMAIL PROTECTED] Message-ID: [EMAIL PROTECTED] Date: Fri, 16 Jan 2004 17:45:18 +0100 X-MIMETrack: Serialize by Router on SRVINT/ASLPavia(Release 5.0.12 |February 13, 2003) at 01/16/2004 05:42:54 PM MIME-Version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: quoted-printable From: [EMAIL PROTECTED] X-Spambayes-Classification: spam; 1.00 -- paperCrane Justin Patrin -- Question Everything, Reject Nothing -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: sql query, editing?
Louie Miranda wrote: I have this code below, it fetches data on a mysql database. I was hoping you could give me a code hint on where could, my goal is to display this data on a browser which i did already and be able to edit it via a form. edit? - table1=value - table2=value I dont know where to start. please help me, i hope i can display all the data and have a button for editing and catch which one to edit. Well, my first suggestion is to use a database abstraction class such as PEAR's DB. It offers much more powerful features than the regular mysql extension in PHP, has better error handling, and allows you to have the same interface for all of the databases it supports. My second suggestion is to use DB_DataObject and DB_DataObject_FormBuilder to create the forms for a table and handle editing the data. It really simplifies things. My third suggestion would be to use a new package that I'm writing. It not only automates editing of table data, but it also shows you all of the records and lets you view multiple tables. Unfortunately, it's not out yet, but I could give you a copy if you wanted. To see the precursor to what I'm working on, check out RDBEdit (http://rdbedit.sf.net). PEAR::DB http://pear.php.net/package/DB PEAR::DB_DataObject http://pear.php.net/package/DB_DataObject PEAR::DB_DataObject_FormBuilder http://pear.php.net/package/DB_DataObject_FormBuilder -- paperCrane Justin Patrin -- Question Everything, Reject Nothing -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Multiple SQL queries
Arthur Pelkey wrote: I am new this. I have a page that has multiple queries on it, I want to do doing the following: Query a mysql db multiple times in the same page, but i must be missing something, I keep getting these AFTER the first queryis successful: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /path/php_file.php on line line_number Can someone point in the right direction on how to do multiple queries, some are not querying the same db btw. -Art You need to make sure that you use your statement handles and connection handles so that the functions use the correct connection and such. Of course, that's a pain, so You could try using a Database Abstraction class, such as PEAR's DB to help a bit with this. Even easier, though, is to use something like DB_DataObject which encapsulates all of this for you AND gives you a handy place to store all of the data. PEAR::DB http://pear.php.net/package/DB PEAR::DB_DataObject http://pear.php.net/package/DB_DataObject -- paperCrane Justin Patrin -- Question Everything, Reject Nothing -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: multi-language site
Please don't send a new message as a reply to a previous posting. It breaks threading (which associates replies to the message it replied to) and makes it seem that your new post is a reply to an completely unrelated message. Instead, please create a new message and enter the newsgroup or list address in the To: box. -- paperCrane Justin Patrin -- Question Everything, Reject Nothing -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: PHP4.2.3 and Oracle 9.2
Error display on browser: Warning: SQL error: Specified driver could not be loaded due to system error 5 (Oracle in OraHome92)., SQL state IM003 in SQL Connect in c:\inetpub\wwwroot\PHP\testora.php on line 2. Warning: odbc_exec(): Supplied argument is not a valid ODBC-Link resource in c:\inetpub\wwwroot\PHP\testora.php on line 5 Warning: odbc_fetch_into(): Supplied argument is not a valid ODBC result resource in c:\inetpub\wwwroot\PHP\testora.php on line 6 Warning: odbc_close(): Supplied argument is not a valid ODBC-Link resource in c:\inetpub\wwwroot\PHP\testora.php on line 14 If you're using seperate PHP compilations for command-line and Apache (ie. a php binary for CLI and mod_php for apache) then it is likely that the same things were not compiled into both. Of course, since this is ODBC, it seems unlikely that this is the problem. It's probably some kind of ODBC configuration issue. Check the documentation for ODBC on Linux and make sure that the web version of PHP has the correct settings (use phpinfo()). -- paperCrane Justin Patrin -- Question Everything, Reject Nothing -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: L'utente Fabio Farinelli ha cambiato indirizzo di posta elettronica.
Ignatius Reilly wrote: Somebody with admin rights to this list please castrate this Farinelli user. +1 on that! -- paperCrane Justin Patrin -- Question Everything, Reject Nothing -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] date problem in MySQL DB
Brett King wrote: Hi Angelo Yes you will have to reformat and he is something that may help you. Hope it does function dateCheckMysql ($date) { list($dateDay, $dateMonth, $dateYear) = explode(/, $date); if ((is_numeric($dateDay)) (is_numeric($dateMonth)) (is_numeric($dateYear))) { if (!checkdate($dateMonth, $dateDay, $dateYear)) { return false; } else { return($dateYear./.$dateMonth./.$dateDay); } } else { return false; } } function dateCheckForm($date) { list($dateYear, $dateMonth, $dateDay) = explode(-, $date); if ((is_numeric($dateDay)) (is_numeric($dateMonth)) (is_numeric($dateYear))) { return($dateDay./.$dateMonth./.$dateYear); } else { return false; } } Many Thanks Brett Wow, that's lots of code. I'd recommend something simpler. Like: $mysqlDate = date('Y-m-d', strtotime($myDate)); $myDate = date('m/d/Y', strtotime($mysqlDate)); No checking involved, just one line of code. -- paperCrane Justin Patrin -- Question Everything, Reject Nothing -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: php includes
Mayo wrote: I'm new to php (I've been in the CF world the last few years) and have a basic question regarding includes: On my dev box (a fancy term for laptop) I have the following include: ?php include (navTop.php); ? This doesn't work on the client's site. There I have to use: ?php include (/home/sites/www.abc.com/web/navTop.php); ? I can't use relative links. So is there any trick that people have so that I don't have to touch each of my files before sending them up? gil Please do not write a new post by replying to an old post and changing its subject and content. It screws up threading in the better e-mail clients (mutt, Thunderird, etc.) as it keeps the thread's headers. It looks like your client doesn't have . in their include_path in the php.ini. They could change their php.ino to have . in it and fix things quick and simple. Or, you can use ini_set() to set the value yourself. You'd probably want to do something like this in your files: ini_set('include_path', '.:'.ini_get('include_path')); -- paperCrane Justin Patrin -- Question Everything, Reject Nothing -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php