Re: [PHP-DB] select
Yes, option value=? echo $row-id; ? ? echo $selected; ? selected You've hardcoded selected there and also expect it to be set dynamically. -- Maxim Maletsky [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] select from multi tables
Hi All, I have a situation where I need to get data from more than one table, but where the fields in the table are identical, the two tables are holding data for different years. The queries I would like to execute would be something along the lines of this: - SELECT SUM(T1.F1) AS C1, SUM(T2.F1) AS C2 FROM T1, T2 Which I would like to give the total of T1.F1 in C1 and the total of T2.F1 in C2. What I get however is the sum of T1.F1 * sum of T2.F1 in both result fields and the number of records found as being the sum of the number of records in T1 * those in T2. What I would like to do eventually with this is get the sum of F1 from any number of tables each representing a year as I don't want to lump all my data into one big table that will get out of hand. Can anyone tell me the right way to go about this? Cheers Dan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: select from multi tables
SELECT SUM(T1.F1) AS C1, SUM(T2.F1) AS C2 FROM T1, T2 Hi, T1,T2 is a join of the two tables which means that you combine each value of T1 with each value of T2. This is why you don't get the result you want. In your case I simply would do two querys as it won't make any problems: SELECT SUM T1.F1 FROM T1; SELECT SUM T2.F2 FROM T2; Regards, Bastian -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] form field rejection
You could also look at a site like javascript.internet.com and look up a pre-written phone number validation script and do the validation on the client side in addition to or instead of doing it on the server side. One reason you may want to consider doing client-side validation for something like this is consideration for your users. Not everyone has a DSL or Cable connection, let alone T1 or T3. If one of your users fills out your form, hits SUBMIT, then has to wait maybe 60 seconds round trip for the server to report that the phone number was invalid, they're probably going to get frustrated. Any time you can get away with client side form validation, you should use it. Especially if you're backing it up with server-side validation. It's much more user-friendly. Server-side validation is good to double-check to make sure the form data has not been tampered with and is still acceptable by the server and in the event that the user has disabled JavaScript in the browser. It's also necessary anytime you have to validate a form entry against a database (e.g. checking to see if a username already exists on a user account creation form). -Original Message- From: Leif K-Brooks [mailto:[EMAIL PROTECTED]] Sent: Sunday, February 02, 2003 11:53 PM To: Addison Ellis Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] form field rejection Try something like this (untested): $phonenumber = '(123)-123-1234'; $phonenumber = preg_replace('/[^0-9]/','',$phonenumber); if(!preg_match('/^([0-9]{3})([0-9]{3})([0-9]{4})$/',$phonenumb er,$matches){ die('Invalid phone number.'); } $full_number = $matches[0]; $areacode = $matches[1]; $exchange = $matches[2]; $number = $matches[3] $banned_exchanges = array('321','654'); if(in_array($exchange,$banned_exchanges)){ die('Bad exchange.'); } Addison Ellis wrote: hello, thank you for your time... what is the best way for me to have a form field, phone reject certain phone prefixes? for example: someone enters 321-1791 and 321 prefix can not be allowed as an entry... thank you again, addison -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Re: select from multi tables
thanks, i think your probably right. Another problem I have is trying to sum the totals of F1 over muliple tables, what I would like is to be able to use the UNION statement but my site is hosted and they are not using version 4x of MySQL. Is there any work around for this using a single SQL statement or again will I need to use multiple statments and add up the results with php? thanks again -Original Message- From: Bastian Vogt [mailto:[EMAIL PROTECTED]] Sent: 03 February 2003 13:12 To: [EMAIL PROTECTED] Subject: [PHP-DB] Re: select from multi tables SELECT SUM(T1.F1) AS C1, SUM(T2.F1) AS C2 FROM T1, T2 Hi, T1,T2 is a join of the two tables which means that you combine each value of T1 with each value of T2. This is why you don't get the result you want. In your case I simply would do two querys as it won't make any problems: SELECT SUM T1.F1 FROM T1; SELECT SUM T2.F2 FROM T2; Regards, Bastian -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Date format in MySQL
Hi All, I have a date format of -MM-DD in MySQL and am showing it on a PHP page. However I want to show it as 2 February, 2003 or 2 February Can someone please help me. The date will not necessarily be todays date (I looked at the datetime() function and the getdate() function but couldn't work it out for these) Thanks for your support All the best Lisa Lisa Rubanowicz CNH Ireland Tel: +353 46 77663 Email: mailto:[EMAIL PROTECTED] [EMAIL PROTECTED]
Re: [PHP-DB] Date format in MySQL
strftime() offers a lot of formatting options for dates. Hope it helps. RUBANOWICZ Lisa wrote: Hi All, I have a date format of -MM-DD in MySQL and am showing it on a PHP page. However I want to show it as 2 February, 2003 or 2 February Can someone please help me. The date will not necessarily be todays date (I looked at the datetime() function and the getdate() function but couldn't work it out for these) Thanks for your support All the best Lisa Lisa Rubanowicz CNH Ireland Tel: +353 46 77663 Email: mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] -- John Krewson Programmer - SWORPS -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Date format in MySQL
Or if you want to change it when you're pulling out of mysql you can use the DATE_FORMAT( ) function... hth jeff John Krewson krewsonj@sworp To: RUBANOWICZ Lisa [EMAIL PROTECTED] s.utk.educc: '[EMAIL PROTECTED]' [EMAIL PROTECTED] Subject: Re: [PHP-DB] Date format in MySQL 02/03/2003 09:32 AM strftime() offers a lot of formatting options for dates. Hope it helps. RUBANOWICZ Lisa wrote: Hi All, I have a date format of -MM-DD in MySQL and am showing it on a PHP page. However I want to show it as 2 February, 2003 or 2 February Can someone please help me. The date will not necessarily be todays date (I looked at the datetime() function and the getdate() function but couldn't work it out for these) Thanks for your support All the best Lisa Lisa Rubanowicz CNH Ireland Tel: +353 46 77663 Email: mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] -- John Krewson Programmer - SWORPS -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] VFP 6 via ODBC and data integrity questions
Good day all, I have just began work on a project to let users subscribe to a service and place orders into a database that is VFP 6 based. Using PHP4, I am able to interface with their program (that also uses ODBC locally) in all aspects (INSERT, UPDATE, DELETE, and SELECT). My worries come when inserting a new user/order from the web. The morons who designed the database made the Primary Key as character and NULLable (once only of course), but I have to deal with that. My question is this... How can I know the new user I INSERT will be unique? (the field is character, but counts like a number field) This especially holds true since I have to deal with local users possibly adding at the exact same moment as PHP (ie. a racing issue). Can anyone tell me how to avoid problems? Would odbc_prepare() reserve a new key for me? Thanks. Brian PJC Services P.S. Kudos to all of the developers. This is a great job you guys are doing. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] VFP 6 via ODBC and data integrity questions
I have just began work on a project to let users subscribe to a service and place orders into a database that is VFP 6 based. Using PHP4, I am able to interface with their program (that also uses ODBC locally) in all aspects (INSERT, UPDATE, DELETE, and SELECT). My worries come when inserting a new user/order from the web. The morons who designed the database made the Primary Key as character and NULLable (once only of course), but I have to deal with that. My question is this... How can I know the new user I INSERT will be unique? (the field is character, but counts like a number field) This especially holds true since I have to deal with local users possibly adding at the exact same moment as PHP (ie. a racing issue). Can anyone tell me how to avoid problems? Would odbc_prepare() reserve a new key for me? Just insert the name and look for an error coming back to you. There's some way to get the error reported by the database with ODBC, isn't there? Parse the error returned for something like duplicate key and then you'll know the username wasn't unique and they need to find another. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Date format in MySQL
$query = mysql_query(SELECT UNIX_TIMESTAMP(fieldname) AS date WHERE id = '1';); $array = mysql_fetch_array($query); $mydate = date(j F, Y,$array[date]); Change fieldname and the where clause, and that should work. If you want to further munipulate how it looks, just look at the date manual page: http://www.php.net/date And change the first parameter to the date function. On Mon, 2003-02-03 at 09:09, RUBANOWICZ Lisa wrote: Hi All, I have a date format of -MM-DD in MySQL and am showing it on a PHP page. However I want to show it as 2 February, 2003 or 2 February Can someone please help me. The date will not necessarily be todays date (I looked at the datetime() function and the getdate() function but couldn't work it out for these) Thanks for your support All the best Lisa Lisa Rubanowicz CNH Ireland Tel: +353 46 77663 Email: mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] -- Adam Voigt ([EMAIL PROTECTED]) The Cryptocomm Group My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc signature.asc Description: This is a digitally signed message part
[PHP-DB] login script
Hi, need some help. i will try to explain my self. I have a sendmail in GNU/linux, and a radiator GNU/Linux with Mysql. I have to give a diferente user for de dialup login and the sendmail, cause i can't or i dont know a way to change the user and pass for the user in the two servers. Like this, the user to make a dialup conection has a user and a pass and for the sendmail has another, and, if there is any changes, when the user changes de user or pass from one can't at the same time change the user/pass from the other. can someone help me Cumprimentos Bruno Pereira [EMAIL PROTECTED] -Original Message- From: SELPH,JASON (HP-Richardson,ex1) [mailto:[EMAIL PROTECTED]] Sent: sexta-feira, 31 de Janeiro de 2003 17:52 To: Matt; [EMAIL PROTECTED] Subject: RE: [PHP-DB] login script try: http://www.hotscripts.com/PHP/Scripts_and_Programs/User_Authentication/ there are loads of pre done scripts you can reference. Cheers Jason -Original Message- From: Matt [mailto:[EMAIL PROTECTED]] Sent: Friday, January 31, 2003 11:48 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] login script Anyone have any suggestions on how to go about creating a solid login script? I have a MySQL database with a field called LoggedIn that is by default NO but I want it to turn to YES when the user logs in, and I want it to turn back to NO when the user either logs out, or a certain amount of time goes by and they timeout. I was just wondering if anyone had any suggestions for me on how to go about this process. Thanks a lot. Matt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] print
It IS following your \n, but HTML doesn't know what a newline is. Do a vbiew source and you'll see that it's got line breaks. You need to use BR or P tags so that *HTML* knows what you want from it. As for property_type, print_r($row) in the while statement to see what's coming out of the db. --- Addison Ellis [EMAIL PROTECTED] wrote: hi, i still am having a problem. can you see what is wrong with what i've got. and... thank you. best regards, addison ellis this is what is printing: 2Bedroom/2Bath great From Campus Available imm 500.00 Contact: 321-1791 it is not printing the property_type and it is not following my \n commands. here's the code: ? // Begin Ad Block $count = 0; $id = 50; $obj = mysql_db_query($dbname,select a.*,s.name as subcategory_name,c.name as category_name from ads a,subcategory s,category c where a.subcategory=s.id and s.category=c.id and a.subcategory=$id and a.que='checked'); if ($obj mysql_num_rows($obj)0) { while($row = mysql_fetch_object($obj)) { $count++; ? ? echo {$row-bedrooms}Bedroom/{$row-baths}Bath{$row-property_type}\n {$row-description}\n {$row-distance} From Campus Available {$row-date_available}\n {$row-price}\n Contact: {$row-contact}; ? /fontfont color=#00 size=2 face=Arial, Helvetica, sans-serifbr / br img src=../images/thin_line.gif width=185 height=1br br ? } } // End Ad Block ? thanks again... -- Addison Ellis small independent publishing co. 114 B 29th Avenue North Nashville, TN 37203 (615) 321-1791 [EMAIL PROTECTED] [EMAIL PROTECTED] subsidiaries of small independent publishing co. [EMAIL PROTECTED] [EMAIL PROTECTED] = Mark Weinstock [EMAIL PROTECTED] *** You can't demand something as a right unless you are willing to fight to death to defend everyone else's right to the same thing. -Stolen from the now-defunct Randy's Random mailing list. *** __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] heredoc and coding standards
I try to write very clean code. However, there is one thing that always bugs me - using heredoc syntax in a function. Code in the function really should be indented (or 4 spaces for PEAR types), but, to quote the documentation, the closing identifier must begin in the first column of the line. That means no tabs, right? So is that just the way it is? Do I just need to not worry about my tabs for heredoc? Is there some way to maintain consistency without breaking my code? -Rob -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Uploading an image then storing it in a MySQL blob field
I'm looking for a sample code that process an image upload AND insert it in a MySQL blob file. Thanks. --- Stéphane Pinel - Exenevex SA --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Uploading an image then storing it in a MySQL blob field
I think you might find it a better option to upload the image to a folder on the server and save the image path in the db...not the actual image. Eddie -Original Message- From: Stéphane Pinel [mailto:[EMAIL PROTECTED]] Sent: Monday, February 03, 2003 1:03 PM To: 'PHP DB' Subject: [PHP-DB] Uploading an image then storing it in a MySQL blob field I'm looking for a sample code that process an image upload AND insert it in a MySQL blob file. Thanks. --- Stéphane Pinel - Exenevex SA --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Uploading an image then storing it in a MySQL blob field
Regardless of the final decision (directory vs BLOB) this topic is covered just about every week on this list. If you check the archives you'll find a wealth of information out there regarding uploading, storing and retrieving images and the benefits and disadvantages of each possibility. If you've already made your decision and you're just looking for raw code, check http://www.phpclasses.org/ or http://freshmeat.net/ and you should find a wealth of resources there. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Monday, February 03, 2003 1:45 PM To: 'PHP DB' Subject: RE: [PHP-DB] Uploading an image then storing it in a MySQL blob field I think you might find it a better option to upload the image to a folder on the server and save the image path in the db...not the actual image. Eddie -Original Message- From: Stéphane Pinel [mailto:[EMAIL PROTECTED]] Sent: Monday, February 03, 2003 1:03 PM To: 'PHP DB' Subject: [PHP-DB] Uploading an image then storing it in a MySQL blob field I'm looking for a sample code that process an image upload AND insert it in a MySQL blob file. Thanks. -- -- --- Stéphane Pinel - Exenevex SA -- -- --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Uploading an image then storing it in a MySQL blob field
De: Stéphane Pinel [EMAIL PROTECTED] Date: Lun 3 fév 2003 19:57:25 Europe/Paris À: [EMAIL PROTECTED] (Edward Peloke) Objet: Rép : [PHP-DB] Uploading an image then storing it in a MySQL blob field Le lundi, 3 fév 2003, à 19:44 Europe/Paris, Edward Peloke a écrit : I think you might find it a better option to upload the image to a folder on the server and save the image path in the db...not the actual image. Yes I know but in this particular case, I need to store the images in the MySQL DB since this DB will be connected to a system that can't deal with files. Thanks. --- Stéphane Pinel - Exenevex SA 4D Plugins [MySQLConnect for 4D] [DBGateway for 4D] iChat/AIM: s.pinel --- --- Stéphane Pinel - Exenevex SA --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] VFP 6 via ODBC and data integrity questions
There's an alternate route, but I've used it only over a network, not across the internet. Create a keys table which has two fields - tablename and keyvalue. Create a Get_VFP_Key function with one parameter, the tablename, which returns the keyvalue for that table name. Get_VFP_Key gets a lock on the row containing the tablename, grabs the value, increments it according to whatever scheme you are using, writes the new value and releases the lock. A friend of mine used the ascii table and generated base 256 keys, rather an exceptional fellow. The problem I see here is latency and a locking problem. Alternately, if the machine you are hitting is running VFP, why not use its native sys(2015) (or 2017 - can't remember just now) to generate a random key. HTH - Miles Thompson BTW Character-based primary keys are quite common in the VFP world because FoxPro did not cleanly handle a mix of numeric and character fields in the WHERE portion of a SELECT. It wanted all character values, so don't be too hard on the morons. How are they handling the generation of primary keys? At 09:43 AM 2/3/2003 -0500, Brian Evans wrote: Good day all, I have just began work on a project to let users subscribe to a service and place orders into a database that is VFP 6 based. Using PHP4, I am able to interface with their program (that also uses ODBC locally) in all aspects (INSERT, UPDATE, DELETE, and SELECT). My worries come when inserting a new user/order from the web. The morons who designed the database made the Primary Key as character and NULLable (once only of course), but I have to deal with that. My question is this... How can I know the new user I INSERT will be unique? (the field is character, but counts like a number field) This especially holds true since I have to deal with local users possibly adding at the exact same moment as PHP (ie. a racing issue). Can anyone tell me how to avoid problems? Would odbc_prepare() reserve a new key for me? Thanks. Brian PJC Services P.S. Kudos to all of the developers. This is a great job you guys are doing. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MySQL : InnoDB tables
Helloo people, I have a question about MySQL, i use MySQL 3.23.55 together with PHP 4.3.0 on my windows XP system. Does the version of MySQL supports InnoDB tables? And how do i do it i have noticed that in PhpMyAdmin i cannot choose this table format..., but i gues that has more to do with the PhpMyAdmin then with my database i gues. Best regards, Davy Obdam -- Davy Obdam - Obdam webdesign© mailto:[EMAIL PROTECTED] web: www.davyobdam.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] heredoc and coding standards
I usually do something like this: function somefunction(){ //Do whatever print END Whatever text here END ; } Rob Day wrote: I try to write very clean code. However, there is one thing that always bugs me - using heredoc syntax in a function. Code in the function really should be indented (or 4 spaces for PEAR types), but, to quote the documentation, the closing identifier must begin in the first column of the line. That means no tabs, right? So is that just the way it is? Do I just need to not worry about my tabs for heredoc? Is there some way to maintain consistency without breaking my code? -Rob -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Date format in MySQL
the function you need is DATE_FORMAT() select event, DATE_FORMAT(my_time,'%d-%m-%Y) as mytime From mytable; mytime will be in the form dd-mm-, the %d specifier will give you the prefferred output -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] VFP 6 via ODBC and data integrity questions
Currently they are using a VFP client app, the actual program is not installed. I just discovered that the suggestion you offered (about a key table) is being used by this client. Would the sys() function work through ODBC w/o the full VFP install? How do I lock the database through PHP and ODBC for a moment?? I cannot find any information on this. Thanks for your help. Brian PJC Services At 03:13 PM 2/3/2003, you wrote: There's an alternate route, but I've used it only over a network, not across the internet. Create a keys table which has two fields - tablename and keyvalue. Create a Get_VFP_Key function with one parameter, the tablename, which returns the keyvalue for that table name. Get_VFP_Key gets a lock on the row containing the tablename, grabs the value, increments it according to whatever scheme you are using, writes the new value and releases the lock. A friend of mine used the ascii table and generated base 256 keys, rather an exceptional fellow. The problem I see here is latency and a locking problem. Alternately, if the machine you are hitting is running VFP, why not use its native sys(2015) (or 2017 - can't remember just now) to generate a random key. HTH - Miles Thompson BTW Character-based primary keys are quite common in the VFP world because FoxPro did not cleanly handle a mix of numeric and character fields in the WHERE portion of a SELECT. It wanted all character values, so don't be too hard on the morons. How are they handling the generation of primary keys? At 09:43 AM 2/3/2003 -0500, Brian Evans wrote: Good day all, I have just began work on a project to let users subscribe to a service and place orders into a database that is VFP 6 based. Using PHP4, I am able to interface with their program (that also uses ODBC locally) in all aspects (INSERT, UPDATE, DELETE, and SELECT). My worries come when inserting a new user/order from the web. The morons who designed the database made the Primary Key as character and NULLable (once only of course), but I have to deal with that. My question is this... How can I know the new user I INSERT will be unique? (the field is character, but counts like a number field) This especially holds true since I have to deal with local users possibly adding at the exact same moment as PHP (ie. a racing issue). Can anyone tell me how to avoid problems? Would odbc_prepare() reserve a new key for me? Thanks. Brian PJC Services P.S. Kudos to all of the developers. This is a great job you guys are doing. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.449 / Virus Database: 251 - Release Date: 1/27/2003 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] VFP 6 via ODBC and data integrity questions
At 06:25 PM 2/3/2003 -0500, Brian Evans wrote: Currently they are using a VFP client app, the actual program is not installed. I just discovered that the suggestion you offered (about a key table) is being used by this client. Would the sys() function work through ODBC w/o the full VFP install? No, I wouldn't think so, it's a native VFP function. I'm wondering if you could clone something, by using rand(), seeded with the unix time and client's IP number. Don't take me too seriously, I'm just musing here. How do I lock the database through PHP and ODBC for a moment?? I cannot find any information on this. Probably you can't. but I'm wondering if you could SELECT the keyvalue you need, then immediately execute an update, setting keyvalue to keyvalue + 1, assuming it's numeric. What would that be like, something along the lines of update keys ( keyvalue), ( str( val(keyvalue) + ) ) where tablename = 'var_tablename' The val expression converts the existing keyvalue to a numeric which allows a numeric one to be added, returning that expression as a string. (Unless I have their functionality reversed, but I hope you get the idea.) With his you don't have to worry about the lock and the value will be appropriately updated. Again the question is what kind of functions can you use through ODBC; I've not ever had to work with it. HTH - Miles Thompson Thanks for your help. Brian PJC Services At 03:13 PM 2/3/2003, you wrote: There's an alternate route, but I've used it only over a network, not across the internet. Create a keys table which has two fields - tablename and keyvalue. Create a Get_VFP_Key function with one parameter, the tablename, which returns the keyvalue for that table name. Get_VFP_Key gets a lock on the row containing the tablename, grabs the value, increments it according to whatever scheme you are using, writes the new value and releases the lock. A friend of mine used the ascii table and generated base 256 keys, rather an exceptional fellow. The problem I see here is latency and a locking problem. Alternately, if the machine you are hitting is running VFP, why not use its native sys(2015) (or 2017 - can't remember just now) to generate a random key. HTH - Miles Thompson BTW Character-based primary keys are quite common in the VFP world because FoxPro did not cleanly handle a mix of numeric and character fields in the WHERE portion of a SELECT. It wanted all character values, so don't be too hard on the morons. How are they handling the generation of primary keys? At 09:43 AM 2/3/2003 -0500, Brian Evans wrote: Good day all, I have just began work on a project to let users subscribe to a service and place orders into a database that is VFP 6 based. Using PHP4, I am able to interface with their program (that also uses ODBC locally) in all aspects (INSERT, UPDATE, DELETE, and SELECT). My worries come when inserting a new user/order from the web. The morons who designed the database made the Primary Key as character and NULLable (once only of course), but I have to deal with that. My question is this... How can I know the new user I INSERT will be unique? (the field is character, but counts like a number field) This especially holds true since I have to deal with local users possibly adding at the exact same moment as PHP (ie. a racing issue). Can anyone tell me how to avoid problems? Would odbc_prepare() reserve a new key for me? Thanks. Brian PJC Services P.S. Kudos to all of the developers. This is a great job you guys are doing. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.449 / Virus Database: 251 - Release Date: 1/27/2003 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] VFP 6 via ODBC and data integrity questions
OK, I know what I have to do. I thank you for all of your help and I will use your idea of a select, then update and then capture all errors to try again. Hopefully, this will minimize problems in the future. Thanks, Brian PJC Services At 06:45 PM 2/3/2003, you wrote: At 06:25 PM 2/3/2003 -0500, Brian Evans wrote: Currently they are using a VFP client app, the actual program is not installed. I just discovered that the suggestion you offered (about a key table) is being used by this client. Would the sys() function work through ODBC w/o the full VFP install? No, I wouldn't think so, it's a native VFP function. I'm wondering if you could clone something, by using rand(), seeded with the unix time and client's IP number. Don't take me too seriously, I'm just musing here. How do I lock the database through PHP and ODBC for a moment?? I cannot find any information on this. Probably you can't. but I'm wondering if you could SELECT the keyvalue you need, then immediately execute an update, setting keyvalue to keyvalue + 1, assuming it's numeric. What would that be like, something along the lines of update keys ( keyvalue), ( str( val(keyvalue) + ) ) where tablename = 'var_tablename' The val expression converts the existing keyvalue to a numeric which allows a numeric one to be added, returning that expression as a string. (Unless I have their functionality reversed, but I hope you get the idea.) With his you don't have to worry about the lock and the value will be appropriately updated. Again the question is what kind of functions can you use through ODBC; I've not ever had to work with it. HTH - Miles Thompson Thanks for your help. Brian PJC Services At 03:13 PM 2/3/2003, you wrote: There's an alternate route, but I've used it only over a network, not across the internet. Create a keys table which has two fields - tablename and keyvalue. Create a Get_VFP_Key function with one parameter, the tablename, which returns the keyvalue for that table name. Get_VFP_Key gets a lock on the row containing the tablename, grabs the value, increments it according to whatever scheme you are using, writes the new value and releases the lock. A friend of mine used the ascii table and generated base 256 keys, rather an exceptional fellow. The problem I see here is latency and a locking problem. Alternately, if the machine you are hitting is running VFP, why not use its native sys(2015) (or 2017 - can't remember just now) to generate a random key. HTH - Miles Thompson BTW Character-based primary keys are quite common in the VFP world because FoxPro did not cleanly handle a mix of numeric and character fields in the WHERE portion of a SELECT. It wanted all character values, so don't be too hard on the morons. How are they handling the generation of primary keys? At 09:43 AM 2/3/2003 -0500, Brian Evans wrote: Good day all, I have just began work on a project to let users subscribe to a service and place orders into a database that is VFP 6 based. Using PHP4, I am able to interface with their program (that also uses ODBC locally) in all aspects (INSERT, UPDATE, DELETE, and SELECT). My worries come when inserting a new user/order from the web. The morons who designed the database made the Primary Key as character and NULLable (once only of course), but I have to deal with that. My question is this... How can I know the new user I INSERT will be unique? (the field is character, but counts like a number field) This especially holds true since I have to deal with local users possibly adding at the exact same moment as PHP (ie. a racing issue). Can anyone tell me how to avoid problems? Would odbc_prepare() reserve a new key for me? Thanks. Brian PJC Services P.S. Kudos to all of the developers. This is a great job you guys are doing. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.449 / Virus Database: 251 - Release Date: 1/27/2003 --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.449 / Virus Database: 251 - Release Date: 1/27/2003 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] problems with variables
I want to pass some variables named a1, a2...aX in a form. So I wrote a couple of lines to do the trick: for($i=1;$i=$X;$i++) { echo input type=\hidden\ name=\q$i\ value=\$q$i\\n; } But there is just one problem. How do I pass the correct value? This is what I want the loop to do: echo input type=\hidden\ name=\q1\ value=\$q1\\n; echo input type=\hidden\ name=\q2\ value=\$q2\\n; ... ... So I want to make the variables $q1 .. $qX from q$i Is this possible and if so, how? Thanks for your support, Marcel -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] heredoc and coding standards
heredoc is the fastest way to get lazy. use inline php then, easier and can use tabs, no? Tabs of 4 spaces are, normally, the most prefered. -- Maxim Maletsky [EMAIL PROTECTED] On Mon, 3 Feb 2003 11:47:12 -0600 Rob Day [EMAIL PROTECTED] wrote: I try to write very clean code. However, there is one thing that always bugs me - using heredoc syntax in a function. Code in the function really should be indented (or 4 spaces for PEAR types), but, to quote the documentation, the closing identifier must begin in the first column of the line. That means no tabs, right? So is that just the way it is? Do I just need to not worry about my tabs for heredoc? Is there some way to maintain consistency without breaking my code? -Rob -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Anyone used dgssearch script before? Newbie needs some help
I'm trying to use dgssearch, from digitalgenesis.com, and am unable to find any help. I'm hoping to find someone with some experience working with this script. I'm using it on Win2k with an MSSQL 7 server (please don't chastise me, I'm setting up a linux server at home so I can get away from MS). It's working, except I'm still getting some errors at the top and bottom of the page. if anyone can help me or know of a site that gives some advice using this script, please let me know. Thanks. -Brian [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: problems with variables
Marcel [EMAIL PROTECTED] wrote: Can you clarify? Possibly show how the result should look in the page after parsing. I'm sure I can help but your question is a bit unclear. I want to pass some variables named a1, a2...aX in a form. So I wrote a couple of lines to do the trick: for($i=1;$i=$X;$i++) { echo input type=\hidden\ name=\q$i\ value=\$q$i\\n; } But there is just one problem. How do I pass the correct value? This is what I want the loop to do: echo input type=\hidden\ name=\q1\ value=\$q1\\n; echo input type=\hidden\ name=\q2\ value=\$q2\\n; ... ... So I want to make the variables $q1 .. $qX from q$i Is this possible and if so, how? Thanks for your support, Marcel -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: heredoc and coding standards
Rob, I've come across the same dilema. To keep things clean while using the convenience of heredoc you can write the heredoc in a seperate file and include_once() the file. Larry Rob Day [EMAIL PROTECTED] wrote: I try to write very clean code. However, there is one thing that always bugs me - using heredoc syntax in a function. Code in the function really should be indented (or 4 spaces for PEAR types), but, to quote the documentation, the closing identifier must begin in the first column of the line. That means no tabs, right? So is that just the way it is? Do I just need to not worry about my tabs for heredoc? Is there some way to maintain consistency without breaking my code? -Rob -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: problems with variables
Sorry, I see that I've got the a's and q's mixed up. I'll try to clarify it some more by giving an example with 2 variables. $q1 = first_var; $q2 = second_var; for($i=1;$i=2;$i++) { echo input type=\hidden\ name=\q$i\ value=\$q$i\\n; } The output should now be: input type=hidden name=q1 value=first_var input type=hidden name=q2 value=\second_var Hope you can help me, Marcel - Original Message - From: [EMAIL PROTECTED] Newsgroups: php.db To: [EMAIL PROTECTED] Sent: Tuesday, February 04, 2003 3:24 AM Subject: Re: problems with variables Marcel [EMAIL PROTECTED] wrote: Can you clarify? Possibly show how the result should look in the page after parsing. I'm sure I can help but your question is a bit unclear. I want to pass some variables named a1, a2...aX in a form. So I wrote a couple of lines to do the trick: for($i=1;$i=$X;$i++) { echo input type=\hidden\ name=\q$i\ value=\$q$i\\n; } But there is just one problem. How do I pass the correct value? This is what I want the loop to do: echo input type=\hidden\ name=\q1\ value=\$q1\\n; echo input type=\hidden\ name=\q2\ value=\$q2\\n; ... ... So I want to make the variables $q1 .. $qX from q$i Is this possible and if so, how? Thanks for your support, Marcel -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: To quote or not to quote?
Unknown Sender [EMAIL PROTECTED] wrote: As mentioned in another reply, in MySQL all fields can have quotes regardelss of type. If you really need to tell, use this: if(!is_numeric($value)) { $value = ' . $value . '; } I guess this is mostly a MySQL question, but perhaps PHP has a solution... I would like a foolproof way to determine whether a data value needs to be quoted. Numeric data doesn't need quotes, but string data does. I could use mysql_field_type and check if it's integer, float, double, real, etc., but this seems fragile. I could easily miss one, or a new version of MySQL could add a new one. So how can I get the equivalent of a mysql_needs_quotes function? -- Patrick Doyle [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Oracle 9.2 + IIS 5.0 + Win2k server + PHP 4.3 + ADODB 3.10
Hello folks, I need help with the following. I'm recording machine production and 'health' status information into a Oracle 9.2 DB. That's working great, rock solid, great admin tools, etc. I've been trying to use the Rockwell Software tools to get the data out onto the web in a pretty format, but Rockwell's tools are brittle, buggy, and overpriced. Also, ASP + VBScript for my hacks is turning out to be crufty and slow. I have Oracle 9.2 sitting on a Win2k server that is the primary domain controller. I've set up IIS with PHP, and everything is working great... It can see all the extensions, and with a change to the permissions of the oci.dll, PHP can see that too. I'm wanting to use ADODB 3.1 as a cleaner interface to the Oracle database via oci8. But no matter what I try, I get errors. These errors are not the access is denied error I saw when oci.dll had the wrong perms. It seems I get a warning in the ado... Here is the code snippet from the testpage, tnsname has been changed to protect the guilty... ;) -- This is the dbtest.php file, based on samples given on the adodb page -- ?php include('.\adodb\adodb.inc.php'); # load code common to ADOdb include('.\adodb\tohtml.inc.php'); $conn = ADONewConnection('oci8'); # create a connection # connect to Oracle OCI8 DB... $conn-debug=true; $conn-NConnect('', 'usr', 'usr_pwd', 'TNSName'); # select machines from machinetable $recordSet = $conn-Execute(select * from machinetable); if (!$recordSet) print $conn-ErrorMsg(); else while (!$recordSet-EOF) { print $recordSet-fields[0].' '.$recordSet-fields[1].'BR'; $recordSet-MoveNext(); } #$recordSet-Close(); # optional #$conn-Close(); # optional ? -- This is the error I get in my HTML page, when I browse to dbtest.php -- Warning: _oci_open_server: in D:\PHP\includes\adodb\drivers\adodb-oci8.inc.php on line 132 : (oci8): select * from machinetable : --- adodb-oci8.inc.php is part of the adodb package, and I am getting a warning at that line in the ADODB code. Is this a bug? Should I try ADODB 2.5 instead since it's listed as being more stable on the site? Any and all help will be greatly appreciated. I'm trying to get a demo app up and running in a few days so they don't think I'm nuts for trying this... :) -Daniel Joyce -- The Meek shall inherit the Earth... For the Brave are among the Stars! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: problems with variables
OK, now I get it: $input = 'input type=hidden name=q' . $i . ' value=' . ${$q . $i} . ' . \n; print($input); This one isn't well known so don't forget it!! ;) Larry Marcel [EMAIL PROTECTED] wrote: Sorry, I see that I've got the a's and q's mixed up. I'll try to clarify it some more by giving an example with 2 variables. $q1 = first_var; $q2 = second_var; for($i=1;$i=2;$i++) { echo input type=\hidden\ name=\q$i\ value=\$q$i\\n; } The output should now be: input type=hidden name=q1 value=first_var input type=hidden name=q2 value=\second_var Hope you can help me, Marcel -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Help!
Hello I'm a beginner, I'm reading the PHP's manual but I can't test the examples because always receipt the following error message: Call to undefined funciont:name of any function that I want to use I can't understand why! Please help... :-( Thank you very much, Tom. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL : InnoDB tables
I have a question about MySQL, i use MySQL 3.23.55 together with PHP 4.3.0 on my windows XP system. Does the version of MySQL supports InnoDB tables? And how do i do it i have noticed that in PhpMyAdmin i cannot choose this table format..., but i gues that has more to do with the PhpMyAdmin then with my database i gues. MySQL 3.23 supports InnoDb, but not by default. Read through the manual on how to set up InnoDb support with 3.23. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Help!
On Tuesday 04 February 2003 11:29, Tomás Liendo wrote: Hello I'm a beginner, I'm reading the PHP's manual but I can't test the examples because always receipt the following error message: Call to undefined funciont:name of any function that I want to use I can't understand why! Please help... :-( 1) Please use a descriptive subject. Help! does NOT describe your problem. 2) As your problem has nothing to do with PHP databases you should use the php-general list. 3) Call to undefined function means the module which contains the function has not been compiled into PHP. RTFM for the function in question to see which configure option/switch you need to compile that function into PHP. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* Sysadmin and editors. The holy wars of UNIX. - Linus Torvalds on linux-kernel */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php