Re: [PHP-DB] DBF + PHP
What errors are you getting? Check file permissions, maybe you can't read/write the file. I get warning: Warning: dbase_open() [function.dbase-open]: unable to open database c:\temp\test.dbf in /usr/local/lappstack-1.1/apache2/htdocs/dbase.php on line 8 In php.ini I have safe_mode=off. Even if I wont simple change a directory by: echo getcwd() . \n; chdir('c:\\temp'); echo getcwd() . \n; I get this warning: /usr/local/lappstack-1.1/apache2/htdocs Warning: chdir() [function.chdir]: No such file or directory (errno 2) in /usr/local/lappstack-1.1/apache2/htdocs/dbase.php on line 5 /usr/local/lappstack-1.1/apache2/htdocs And how you see the directory does't change :( Some propositin? THANKS ALL :) echo getcwd() . \n; chdir('c:\\Przewozy\\BAZY'); echo getcwd() . \n; $db = dbase_open(c:\\Przewozy\\BAZY\\Ceny.dbf, 0); -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] DBF + PHP
Instruct ICC [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] From: Luke [EMAIL PROTECTED] echo getcwd() . \n; chdir('c:\\temp'); echo getcwd() . \n; chdir('c:\\Przewozy\\BAZY'); echo getcwd() . \n; $db = dbase_open(c:\\Przewozy\\BAZY\\Ceny.dbf, 0); Just a quick guess/suggestion: Single tick quotes ' are taken literally and double tick quotes allow expansion. $aVariable = 0; echo '$aVariable';//$aVariable echo $aVariable;//0 Maybe change the chdir to use double quotes or remove the double backslash? Especially if your dbase_open works with double quotes and the double backslash. Thanks, but it did't help :(. I still get the some error. I thing it is something with php configuration ? Some other suggestion? _ http://im.live.com/messenger/im/home/?source=hmtextlinkjuly07 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] DBF + PHP
[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Thu, Jul 19, 2007 at 19:34:34 +0200, Luke wrote: I get this warning: /usr/local/lappstack-1.1/apache2/htdocs Warning: chdir() [function.chdir]: No such file or directory (errno 2) in echo getcwd() . \n; chdir('c:\\Przewozy\\BAZY'); echo getcwd() . \n; You seem horribly confused. Why are you using Windows-style paths (c:\\..) on something that looks to be a un*x server (/usr/local...) Becouse I wont read files, exactly *.dbf, from local machine, not from server. I have no problem with read or changing directory, if database is located on server. Thanks for any suggestion. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] DBF + PHP
Hi. I need open some dbase files. Function dbase_open work correctly only when I open data base from server eg. dbase_open('/tmp/test.dbf', 0). How Can I open this database from local host ? dbase_open('c:\tmp\test.dbf', 0) - not working dbase_open('c:\\tmp\test.dbf', 0) - not working dbase_open('c:/tmp/test.dbf', 0) - not working Any idea? Thanks. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Access db
Thanks Michael. I'll check it out ;) - Luke Michael Mauch [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Luke Van Blerk wrote: I'll probably just extract the data with an access to mysql script and run it on mysql. This is probably the best approach if you have access to Windows machine. If not, http://freshmeat.net/projects/mdbtools/ might help. Regards... Michael -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Access db
Hi everyone Can PHP access an access database residing on a unix / linux box? I know theres and ODBC extension but is that only for windows? Regards Luke -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Access db
Thanks Robert I'll probably just extract the data with an access to mysql script and run it on mysql. - Luke Robert Twitty wrote: To the best of my knowledge you cannot access an Access database directly from UNIX or Linux. The reason is because the Jet Engine has not been ported to those platforms. Your only options may be something like EasySoft's ODBC-ODBC bridge or ODBTP. -- bob On Wed, 19 Nov 2003, Luke van Blerk wrote: Hi everyone Can PHP access an access database residing on a unix / linux box? I know theres and ODBC extension but is that only for windows? Regards Luke -- 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.542 / Virus Database: 336 - Release Date: 11/18/2003 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.542 / Virus Database: 336 - Release Date: 11/18/2003 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Saving state
Sounds fairly complicated, but wat about storing the information in session variables? and using multi dimensional arrays to store the information eg Array ( [call_1] = Array ( [name] = john smith [number] = 555-555-555 [time] = 2003-10-17 10:41:00 ) [call_2] = Array ( [name] = bill johns [number] = 555-555-555 [time] = 2003-10-16 07:41:00 ) ) but it really depends on how you want to do it, it might be beneficial to re query the database every time, especially if its going to be multi-user, because what happens if 1 person logs a call, how will the other person using the system know that a new call has been logged, re-querying it shouldnt take too long, and would provide advantages when there is more than one user, and you would have no synchronisation problems Luke - Original Message - From: Shiloh Madsen [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, September 17, 2003 10:24 AM Subject: [PHP-DB] Saving state Sorry about the cross posting, as im not exactly sure what would be the best method to handle this, but im trying to set up a web application with a tabbed interface. Each tab will have a form to enter data, and the requisite save and continue button. Heres where things get hard though. I want to be able to allow users to click on a previous tab to refrence, change, update, etc the information on those tabs. How do i save the state of these tabs so that they can be reaccessed? Just so you have a little more information, im trying to make a kinda simple call logging system with a customer tab which would hold customer info and a calls tab which would store call info and allow you to switch between call records. all of this data would be stored in a database, but i dont want to actually have to send a new query to the database just because the user clicked on a previous tab...if this would be possible. Also, if anyone has an idea as to how i can implement this a bit more intelligently, im open to suggestions, but the tabbed interface seemed to be the most user friendly. And yes, the web interface is important, which is why im not trying to do it in c++ or something like that. Shiloh -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Saving state
Yeah, that is a good way to do it, i would do something similar too but Shiloh seemed to not want to requery the database, althought querys in this case would be the quickest and simplest way to get the historical information, which would be stored in the database already, and as you said, update querys if you want to change the information loaded into the form. If you need to avoid the database, the only other way i can see of keeping the information is adding it to variables at the same time as you add it into the database, and when you need to re-access the info, pull it from the variable instead of the database, but that could get messy Luke - Original Message - From: Duane Lakoduk [EMAIL PROTECTED] To: 'Luke Skywalker' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, September 17, 2003 12:39 PM Subject: RE: [PHP-DB] Saving state Luke, Good point, this list is set up different in that Reply ONLY replies to the individual poster, not the list. Have to use reply to all. I have added the list address to this post. To all concerned, this thread contains some off list conversation that may be of interest, particularly to the original poster. Luke, I agree, both methods will probably work well, as you said, 'depending on the situation'. To expand on the issue of retrieving previously posted data into a multi-tabbed form. In this case, I would normally show the user a list of previous posts or perform a search. Selecting a previous post would load the form with the historical data to allow reviewing one tab at a time. Just like loading any normal edit/view form, but with the tabs breaking up the form into individual parts of the same record. Edits and updates are performed and posted using a similar process to the original post but using an UPDATE WHERE instead of an INSERT INTO statement. List, Sorry if this post is ugly. Delete as necessary. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Can't do anything with variables
Dude - sweet book. I bought it myself when i was starting out. Your problem is due to the PHP error message setting in the php.ini file. Whack this at the beginning of your scripts: // Report simple running errors error_reporting (E_ERROR | E_WARNING | E_PARSE); When you know more - check out the php.ini file and read about the error level.. And this page in the PHP manual: http://www.php.net/manual/en/function.error-reporting.php Cheers, Luke Woollard -Original Message- From: Gilles [mailto:[EMAIL PROTECTED] Sent: Monday, 7 April 2003 11:18 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Can't do anything with variables Hi all, Sorry for this really beginner question (PHP-Newbie here). I bought the book PHP and MySQL web developpement (Welling Thompson) and I'm trying to recreate the exemples and it won't work. I installed PHP 4.3.1 and MySQL 4.0.12. The easy part. Here's a simple form page (from the book): SEARCH.HTML html head titleBook-O-Rama Catalog Search/title /head body h1Book-O-Rama Catalog Search/h1 form action=results.php method=post Choose Search Type:br select name=searchtype option value=authorAuthor option value=titleTitle option value=isbnISBN /select br Enter Search Term:br input name=searchterm type=text br input type=submit value=Search /form /body /html And now the processing page: RESULTS.PHP html head titleBook-O-Rama Search Results/title /head body h1Book-O-Rama Search Results/h1 ? if (!$searchtype || !$searchterm) { echo You have not entered search details. Please go back and try again.; exit; } $searchtype = addslashes($searchtype); $searchterm = addslashes($searchterm); @ $db = mysql_pconnect(localhost, bookorama, bookorama); if (!$db) { echo Error: Could not connect to database. Please try again later.; exit; } mysql_select_db(books); $query = select * from books where .$searchtype. like '%.$searchterm.%'; $result = mysql_query($query); $num_results = mysql_num_rows($result); echo pNumber of books found: .$num_results./p; for ($i=0; $i $num_results; $i++) { $row = mysql_fetch_array($result); echo pstrong.($i+1).. Title: ; echo stripslashes($row[title]); echo /strongbrAuthor: ; echo stripslashes($row[author]); echo brISBN: ; echo stripslashes($row[isbn]); echo brPrice: ; echo stripslashes($row[price]); echo /p; } ? /body /html The problem. Even if I fill both fields, I always get Notice: Undefined variable: searchtype The only way it would work is if I remove all the if part and leave the select * from books (without the where clause). I don't get it. Any help would be much appreciated. Regards Gilles -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] PHP and MySQL 4
Sure does - sure is. -Original Message- From: Benjamin Higgins [mailto:[EMAIL PROTECTED] Sent: Monday, 31 March 2003 6:47 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] PHP and MySQL 4 Does PHP have support for MySQL 4? If I install MySQL 4, and rebuild PHP with --with-mysql, is that sufficient to get MySQL 4 support? Ben -- 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] Creating mySQL database
sure - just pass the mysql query through the mysql_query function. Make sure you connect using mysql_pconnect() first, then you can start creating databases.. Luke Woollard -Original Message- From: Thomas Tremain [mailto:[EMAIL PROTECTED] Sent: Wednesday, 19 March 2003 4:36 PM To: '[EMAIL PROTECTED]' Subject: [PHP-DB] Creating mySQL database Can I create a mySQL user and PW from PHP Thomas Tremain www.LiveHost.net http://www.livehost.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Re: Really easy question
$str = 'hi'; $newstr = eregi_replace(\, , $str); -Original Message- From: Peter Beckman [mailto:[EMAIL PROTECTED] Sent: Wednesday, 19 March 2003 4:33 PM To: Foong Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Re: Really easy question $str = 'hi'; $newstr = preg_replace(/\/, , $str); On Wed, 19 Mar 2003, Foong wrote: try $with_quote = '0'; $without_quote = str_replace('', '', $with_quote); Foong Jeremy [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hey folks, Im apologize that this is just a really easy general php question but any help would be appreciated. if i have a variable that is = to something like 0 or 1 but I just need it to be 0 or 1. how do i strip the off. thanks, Jeremy -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Peter Beckman Internet Guy [EMAIL PROTECTED] http://www.purplecow.com/ --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Server Error
Your MySQL Database is down. 'cd' to your mysql directory (probably /usr/local/mysql ) and type ./bin/safe_mysqld --user=mysql -Original Message- From: Marie Osypian [mailto:[EMAIL PROTECTED] Sent: Tuesday, 18 March 2003 8:42 AM To: php-db Subject: [PHP-DB] Server Error I was able to access my database for weeks and now I am getting this error. Can anyone help? Warning: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/blah/public_html/includes/configi.inc.php on line 3 Warning: MySQL Connection Failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/blah/public_html/includes/configi.inc.php on line 3 Thanks, Marie -- 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] Server Error
This should read 'Your MySQL Database SERVER is down' Thanks, LW -Original Message- From: Luke Woollard [mailto:[EMAIL PROTECTED] Sent: Tuesday, 18 March 2003 8:48 AM To: Marie Osypian; php-db Subject: RE: [PHP-DB] Server Error Your MySQL Database is down. 'cd' to your mysql directory (probably /usr/local/mysql ) and type ./bin/safe_mysqld --user=mysql -Original Message- From: Marie Osypian [mailto:[EMAIL PROTECTED] Sent: Tuesday, 18 March 2003 8:42 AM To: php-db Subject: [PHP-DB] Server Error I was able to access my database for weeks and now I am getting this error. Can anyone help? Warning: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/blah/public_html/includes/configi.inc.php on line 3 Warning: MySQL Connection Failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/blah/public_html/includes/configi.inc.php on line 3 Thanks, Marie -- 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] Picture Upload
Me either Luke Woollard -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Fredrik de Vibe Sent: Wednesday, 12 March 2003 12:51 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Picture Upload [EMAIL PROTECTED] (Dallas Freeman) writes: I have asked my host to update the php software, as for now, I need to know what the lines for changing the size of a picture is. I couldn't see any command lines for it, unless it is something different, I don't know, so could you please show me. Afaicr, there is an excellent recipe for doing just that in The Manual, under image functions. I also need to know, if there is a possibility that php can change the size of an image before it uploads it to the server (so it changes size on the end-user's computer not on the server - that way there would be a shorter upload time). PHP is server side, and can't do anything on the client side (apart from reading and writing cookies, if the user allows it). I can't see any other solution to this than to tell the users to resize the images themselves. -- --Fredrik Reality is that which, when you stop believing in it, doesn't go away. -- Philip K. Dick -- 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] Picture Upload
use the GD Library functions - look up on php.net The GD library is available from http://www.boutell.com/ It is included by default with PHP 4.3.x NOTE: This is a question for [EMAIL PROTECTED] -Original Message- From: Dallas Freeman [mailto:[EMAIL PROTECTED] Sent: Tuesday, 11 March 2003 5:07 PM To: Subject: [PHP-DB] Picture Upload Is there a possibility that you can resize an image before uploading to the server? If so, how? Thanks, Dallas Freeman -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Auto Generation of HTML Forms + SQL Code to update My/Postgre SQL Database
Does anyone know of a program that can autp-generate HTML interfaces and PHP Code to add to/update/delete from different tables in a mysql/postgresql database? Something similar to some of the RAD tools on the market for Microsoft products etc... I'm trying to quicken my development cycle. :) Luke Woollard -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Auto Generation of HTML Forms + SQL Code to update My/Postgre SQL Database
thanks dude. -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED]] Sent: Thursday, 20 February 2003 5:04 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Auto Generation of HTML Forms + SQL Code to update My/Postgre SQL Database On Thursday 20 February 2003 23:49, Luke Woollard wrote: Does anyone know of a program that can autp-generate HTML interfaces and PHP Code to add to/update/delete from different tables in a mysql/postgresql database? Something similar to some of the RAD tools on the market for Microsoft products etc... I'm trying to quicken my development cycle. freshmeat.net and search for mysql forms -- 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 -- /* Nobody can be as agreeable as an uninvited guest. */ -- 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] how do I use same page for submit and results?
or you can use check for the name of the submit button using a specific SUPERGLOBAL array. e.g. if ( ! empty($_POST[submit]) ) { /* form was submitted */ } else { /* form hasn't been submitted, show it */ echo 'form name=something method=post' .' form fields/button goes here ' .'input type=submit name=submit value=send form' .'/form'; } Best to check if a variable exists Using the other method will throw an error: Notice: Undefined index: action in c:\program files\apache group\apache\htdocs\testerr.php on line x... Thanks, Luke Woollard -Original Message- From: Joshua Stein [mailto:[EMAIL PROTECTED]] Sent: Friday, 7 February 2003 5:29 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] how do I use same page for submit and results? But now I'm not using anything that I can check except for the button click. Any ideas how to do this? assign a name to the button and check for that. input type=submit name=action value=Show List ... if ($_REQUEST[action] == Show List) { /* form was submitted */ ... } else { /* form hasn't been submitted, show it */ ... } -j. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] PHP Database Abstraction Layer
I once read a great article in the first or second issue of http://www.phparch.com/ on database abstraction layers. At which point I used the tutorial as a starting point for creating a very similar structure I named dbWave. There are only minor differences and a postgresql driver is now included for the most common pg_* functions. I was just wondering if anyone has developed a database abstraction layer that allows you to separate your SQL queries from your application logic like dbWave does? I'm looking for a more advanced way of doing this? Attached is dbWave for anyone to look at/use. To run it you need to use the following tags in your file: // DBWave include files include( [attached_filename].php ); To instantiate the dbWave object you use the following code in a file name connect.php ?php /* This file instantiates dbWave using our chosen API */ /* It is automatically generated by the database setup program */ // Instantiate dbWave using the MySQL API $dbWave = new Mysql(); // Connect to the database $dbWave-connect( 'yourhost', 'yourport', 'yourdbname', 'yourdbuser', 'yourdbpass' ); ? Thanks, Luke Woollard Programmer / Analyst TABORVISION.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Using Objects with Databases
Initialise the database connection and perform actions on the database using a seperate class. You can pass your functions (methods) values returned from your database calls to manipulate. This is commonly called a 'database abstaction layer' Theres a good database abstraction class in this magazine by a guy called marco talbini http://www.phparch.com/ Else lookup PEAR:MB or adodb library on teoma.com or similar. -Original Message- From: Philip Zee [mailto:[EMAIL PROTECTED]] Sent: Wednesday, 22 January 2003 4:27 PM To: Subject: [PHP-DB] Using Objects with Databases Hello all, I am trying to create a class, say User. Each user has an entry in the database table called user. Each function, including the constructor, will be calling the database to do something. Is it better to initialize the database connection inside each function or is it better to initialize the connection at the beginning of the class? What's the best practice on this? Any help or example is appreciated. Thanks, Philip -- 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] Using Objects with Databases
I store all my sql queries in an include file. These queries could store the actions you want to perform for each user.. I then use scripts to execute queries (with an alias name for each) based on decisions (such as whether certain $_POST variables are present etc..) If I were building a 'user' class - I would store the actions that would 'call' the appropriate query by it's alias. This allows other objects to perform the same queries without re-writing them inside a different class. Also - I'm using a database abstraction layer so I don't have database specific calls inside my classes. This helps maintain portability of my applications. Hope that helps. LW -Original Message- From: Philip Zee [mailto:[EMAIL PROTECTED]] Sent: Wednesday, 22 January 2003 5:16 PM To: Luke Woollard; PHP-db Subject: RE: [PHP-DB] Using Objects with Databases Luke, Thanks for the help. This only answers half of my question. I understand that you need to build a class to handle your database needs. However, once the database returns a row in the table user, there will be functions performed for that user. I was thinking about creating a class User to handle the initialization and other functions for the user. What's the best way of doing that? Thanks, Philip -Original Message- From: Luke Woollard [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 21, 2003 9:38 PM To: PHP-db Subject: RE: [PHP-DB] Using Objects with Databases Initialise the database connection and perform actions on the database using a seperate class. You can pass your functions (methods) values returned from your database calls to manipulate. This is commonly called a 'database abstaction layer' Theres a good database abstraction class in this magazine by a guy called marco talbini http://www.phparch.com/ Else lookup PEAR:MB or adodb library on teoma.com or similar. -Original Message- From: Philip Zee [mailto:[EMAIL PROTECTED]] Sent: Wednesday, 22 January 2003 4:27 PM To: Subject: [PHP-DB] Using Objects with Databases Hello all, I am trying to create a class, say User. Each user has an entry in the database table called user. Each function, including the constructor, will be calling the database to do something. Is it better to initialize the database connection inside each function or is it better to initialize the connection at the beginning of the class? What's the best practice on this? Any help or example is appreciated. Thanks, Philip -- 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] Unlimited Categories
EG: CREATE TABLE category ( id int not null auto_increment, parent int default 0, name varchar 100, ); The parent field contains the ID of the record of which category it belongs. Then use a recursive function to display the 'levels' of data. (If parent is 0 then it is top level category) Luke Woollard -Original Message- From: Gerard Samuel [mailto:[EMAIL PROTECTED]] Sent: Tuesday, 14 January 2003 4:32 PM To: php-db Subject: [PHP-DB] Unlimited Categories Im figuring this is more of an sql question than anything else. I'm trying to figure out a table structure to create unlimited depths of categorical data. I've done something for category/subcategories before, but haven't an idea how to create categories at an unlimited depth. Any pointers would be greatly appreciated. Thanks -- Gerard Samuel http://www.trini0.org:81/ http://dev.trini0.org:81/ -- 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] denying access to folders/files
I wrote a similar script a long time ago to achieve this. [Anti-Leech solution] You store the software in a folder that is outside of the web directory tree and use PHP to 'fopen' the file being downloaded by the 'authenticated' user and send it back to the broser using location() with the correct headers... Here's a sample: header(Content-Disposition: attachment; filename='thefilenamehere'); header(Content-type: application/octet-stream); header(Content-Transfer-Encoding: binary); header(Content-Length: .filesize('thefilename')); header(Pragma: no-cache); header(Expires: 0); $fp=fopen(thefilename,r); print fread($fp,filesize(thefilename)); fclose($fp); -Original Message- From: Darren Bentley [mailto:[EMAIL PROTECTED]] Sent: Thursday, 9 January 2003 11:20 AM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: [PHP-DB] denying access to folders/files I'm hoping someone can give a little advise. We have a customer that provides his software via a www address. We've setup .htaccess on this folder with a single username/password. So he supplies this user/pass to people that pay to get his software. He now wants to have control over the username/passwords. He also wants to have groups so that he can set which programs his customers can download. He also wants it all logged. I don't see this happening via .htaccess so I'm thinking of developing a simple PHP/MYSQL interface. So the customer comes to a login page, authenticates to a MYSQL database, is assigned a cookie and is allowed access to which ever programs his group allows. This is fine and dandy, but how do I prevent that person from taking the direct link to the file and giving it to someone else? I'm sure there is a much better and simpler way. Idea's? Thanks in advance. -- Darren Bentley [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Re: blob
I agree with Dave. I wrote an application to allow a client to upload/manage images and categorise them into diff. parts of their website. Images were stored as normal image files after upload and a pointer made to them from the appropriate database record (which had additional image info e.g. description) Since I now have to move this website to a new server - transferring all these files was a bit annoying. Storing them as binary data in mysql would have been easier to manage... -Original Message- From: David Smith [mailto:[EMAIL PROTECTED]] Sent: Wednesday, 8 January 2003 10:19 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Re: blob On Tue, 2003-01-07 at 15:52, [EMAIL PROTECTED] wrote: I agree with this method. i have not yet seen an advantage of storing blobs in a database. Is there one? i'm sure those on this list would have an opinion if there was one. personally, i like storing all this stuff on the file system. There is one advantage. You must either chown the upload directory to the user that your web-server runs as, or chmod it to be world-writable. When creating a web-application that you plan to distribute (like Slashcode), you can't assume that your users will have that privilege. So, storing it in MySQL is a great option. --Dave -- 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_num_rows
Hello All, I am struggling to understand why my query throws an error the code as below $link = mysql_connect ( db.localhost.org, $user , $pass ); if ( ! $link ) die ( Couldn't Connect to Mysql Server ); print Sucessfully connect to server p; $query = select * from users .where screen_name='$screen_name' . and passwd=password('$passwd'); $result = mysql_query($query, $link); if (mysql_num_rows($result) 0 ) When executed you get a little message back like this one Warning: Supplied argument is not a valid MySQL result resource in /usr/local/share/doc/apache/trial/authmain.php on line 20 What does this generally mean as I have noted that others use this syntax so what is my issue ? Any help or pointers to references would be most appreciated. Thanks Luke K -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Simple Question, hopefully simple answer
In one of my mySql tables I have a colum that contains many fields of numbers. for example | id | Name | Age | Sex | |1 | Jim | 17 | m| |2 | Dave | 31 | f | |3 | Fred | 25 | m| Ok and I want to get the total value of all the ages out of the table. how can I get this? Hope someone can help. Luke -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Deleting characters from a string...
Hi, I have a string that says width=123 Height =456 and I need to for mat the output as 123 x 456 is there a way to do this? Thanks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: newbie question: request response
The real reason I'm asking is because I want to design a PHP app that uses a similar framework to a current Java/JSP app I'm developing, and I will need to use a controller php file that forwards the request and response objects it receives to another php. Java Servlets do this nicely because instead of parsing through all of the arguments in the request object, and then going to the next servlet, it just punches the whole request object to the next servlet. Like I said, the only reason I would need them is to align with my current framework. But I will probably just design a different framework for my PHP apps. Thanks, though... -L -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] request and response objects?
Yes, that's the environment I'm coming from and am used to... -L Paul Dubois [EMAIL PROTECTED] wrote in message news:p05101403b87e54724472@[192.168.1.31]... At 12:30 -0600 1/30/02, Matthew Crouch wrote: basically a yes or no question my brother wants me to ask: Does PHP support these objects? If not, Can they be faked? What, like in Java servlets/JSP pages? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Re: MySQL Update command syntax
Off of MySQL.com: UPDATE [LOW_PRIORITY] [IGNORE] tbl_name SET col_name1=expr1, [col_name2=expr2, ...] [WHERE where_definition] [LIMIT #] So a typical UPDATE command could be UPDATE email_table SET email = '[EMAIL PROTECTED]' WHERE id = '1'; For explanations of all args and options, http://www.mysql.com/doc/U/P/UPDATE.html Hope that helps... -L Jas [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Could anyone help me out with the update command in php? I am trying to update a unique field on a table, or overwrite the current contents of said field. My sql statement is as follows... $db_name = localhost; $table_name = table01; $connection = @mysql_connect(localhost, user, password) or die (Could not connect to database. Please try again later.); $db = @mysql_select_db($db_name,$connection) or die (Could not select database table. Please try again later.); $sql = UPDATE $table_name (new_area) VALUES (\$new_area\) ; $result = @mysql_query($sql, $connection) or die (Could not execute query. Please try again later.); My question is if someone could give me an example of the UPDATE command I would appriciate it. Jas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] newbie question: request response
Does PHP have built-in support for using request and response objects? Thanks, -L -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] RE: Getting apache to recognizeindex.php....
Vincent: Find the DIRECTORYINDEX attribute in httpd.conf and add 'index.php' to the list: DIRECTORYINDEX index.html index.php index.wml homepage.html index.shtml homepage.shtml index.cgi homepage.cgi index.htm \ Index.html Homepage.html Index.shtml Homepage.shtml Index.cgi Homepage.cgi Index.htm Let me know if you need further clarification. -luke Luke Muszkiewicz Pure Development, LLC http://puredev.com -Original Message- From: Vincent Beaulieu [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 04, 2001 9:23 AM To: [EMAIL PROTECTED] Subject: Getting apache to recognizeindex.php Can anyone tell me where to configure apache so that it recognizes index.php as the index of a directory? I tried looking through the httpd.conf file for the option to add an extension...couldn't see anything! My server treats index.html files correctly...(but is not working with index.php)! HELP! Thank you, Vincent -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] mail() - is there a limit?
olinux: I do not know the answer to your question. However, I would alternatively suggest that you send the email to each person individually. That is to say, loop through your recipient array and use mail() to send the message to each recipient, as opposed to creating a bcc array and then sending one email. This solution will take longer to execute -- you may in fact need to adjust the maximum program execution time via set_time_limit() -- but each recipient will receive an individual email, which, I think, will make your message look more personal. Plus, you no longer need to consider the number of addresses in the bcc field. Let me know if you have any questions! -luke Luke Muszkiewicz Pure Development, LLC http://puredev.com I am using a script that grabs about 100 emails from a database, loops thru and writes them to $bcc Then I use a single mail() to send a msg to everyone in the $bcc Is there a maximum nuber of emails that i can mail to this way? Thanks, olinux -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]