Re: [PHP] question about php with sql database
Sudhakar wrote: instead of using mysql database which is conventionally used as database with php, if sql server database is used with php are there any major differences to keep in mind. In syntax or what? Yes there are differences between the two as far as sql syntax goes. 1. are the connection statements ex = $conn = mysql_connect($hostname, $user, $dbpassword); etc does these remain the same or are they different. Of course they are different. Why would mysql_connect (note the MYSQL part of that) connect to anything but a mysql database? 2. unlike in mysql with phpmyadmin which is browser based to access databases and tables how to access sql server for the same functionality I think mssql has something like phpmyadmin built into the server itself. 3. can anyone provide a link about a manual for using sql database with php http://php.net/mssql -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL Group?
George J wrote: Hi John, John Taylor-Johnston [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Does anyone know of a good MySQL group? I want to make a relational link from `data` to `shopping` so when I insert a new record in `shopping`, I will see the contents of `data`.`name` and `data`.`email` as a drop-down menu in `shopping`. Where does one go to get this kind of help? Thanks, John DROP TABLE IF EXISTS `data`; CREATE TABLE `data` ( `id` int(5) NOT NULL auto_increment, `name` varchar(255) NOT NULL, `email` varchar(255) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; INSERT INTO `data` VALUES(1, 'Allen, Carolyn', '[EMAIL PROTECTED]'); INSERT INTO `data` VALUES(2, 'Atwood, Margaret', '[EMAIL PROTECTED]'); DROP TABLE IF EXISTS `shopping`; CREATE TABLE `shopping` ( `id` int(5) NOT NULL auto_increment, `name` varchar(100) NOT NULL, `address` varchar(100) NOT NULL, `email` varchar(100) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ; I'm not certain but think you need to include a 'references table_name(field_name)' clause that sets up the Foreign key relationship between the 2 tables. I think the Reference clause would replace the auto_increment in your primary key of the referencing table. The references goes into the secondary table, not the main one and it definitely doesn't replace the auto_increment field. You end up with something like this: create table person ( person_id int primary key, name varchar(255), email varchar(255) ) engine=innodb; create table shopping ( shopping_id int primary key, person_id int, foreign key (person_id) references person(person_id) ) engine=innodb; insert into person(person_id,name,email) values(1,'Name','[EMAIL PROTECTED]'); insert into shopping(shopping_id, person_id) values(1, 1); The 'person' table still needs at least a unique field for the field being referenced (the foreign key), usually a primary key (and if necessary an auto_increment). The secondary table uses that key to check: - if that id exists: insert into shopping(shopping_id, person_id) values (2,2); ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails - if it should delete that id (when using on delete cascade) mysql delete from person where person_id=1; Query OK, 1 row affected (0.00 sec) mysql select * from shopping; Empty set (0.00 sec) - if it needs to be updated (when using on update cascade) mysql update person set person_id=2 where person_id=1; Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql select * from shopping; +-+---+ | shopping_id | person_id | +-+---+ | 1 | 2 | +-+---+ 1 row in set (0.00 sec) See manual for more examples: http://dev.mysql.com/doc/refman/4.1/en/innodb-foreign-key-constraints.html -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL Group?
John Taylor-Johnston wrote: Thanks for getting me started. (Sorry, I'm a top quoter.) Below is some working code for the archives. What I've learned so far is that : 1) what I'm referring to in `person` has to be a key. It should be a unique item rather than just a 'key' (indexed item). If you add this data: insert into person(name, email) values ('my name', '[EMAIL PROTECTED]'); insert into person(name, email) values ('another name', '[EMAIL PROTECTED]'); and I share an email address, and you use email as the foreign key, which one is it going to link to? Mysql should really throw an error if you try to reference a non-unique field or combination of fields - every other db does. A unique key can cover more than one field: create table person ( person_id int primary key, name varchar(255), email varchar(255), unique key (name, email) ) engine=innodb; So you can only have one combination of name email then you can use that as a foreign key: create table shopping ( shopping_id int primary key, person_name varchar(255), person_email varchar(255), foreign key (person_name, person_email) references person(name,email) ) engine=innodb; Though I'd suggest starting off with the person_id (primary key) as the foreign key so you don't have data redundancy and integrity issues (unless you use on update cascade). I'd also suggest getting an intro-to-sql book as this is all reasonably basic stuff. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php_mssql.so
Liz Kim wrote: We have a set of PHP files which uses dl() to load the extension php_mssql.so at runtime. These were running on a server with PHP 4.3.9 and have been recently moved to a new server with PHP 5.1.6 (both RedHat). I have tried to simply copy the file php_mssql.so file to the directory of PHP modules, however it seems to be not compatible with the new version. Right. PHP4 is different to PHP5 internally so the extension files will be different too. We dont have permissions to recompile PHP on the server but can copy files on the modules/extensions directory area. I believe we just need to get the updated php_mssql.so file onto the server. Any idea where I could download or how to create one? Ideally just get the host to install the appropriate RPM's. The only other way would be to get the same hardware (i386 compared to amd64 for example), same version of redhat, same gcc, same php and compile it all yourself. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php_mssql.so
Liz Kim wrote: Maybe I could just compile it on a test machine and copy the .so file over to the working server. Would there be any incompatibility issues there? If and only if: - They are the same architecture (they both have to be i386 for example, one can't be an amd-64 and the other be a solaris sparc). - You have the same versions of gcc and other software. This may or may not be the case but instead of wasting time I'd make them the same Where could I download PHP 5.1.6? I am only able to see 5.2.5 and 4.4.8 on php.net... http://www.php.net/releases/ -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] LDAP in php
[EMAIL PROTECTED] wrote: As LDAP can have SQL back-end (I saw an example with PostgreSQL) - is it a very wild idea to implement (a simple) LDAP server in php? We have all the address data already in PostgreSQL and a php application managing all of it. I am thinking of simple uses, such as providing LDAP address books to Thunderbird/Squirrelmail users. For instance, is it too wild to think of Apache/php listening on the LDAP port (or so), get the request, parse it, get the data from PostgreSQL and send it back to the LDAP client? If ldap can already use a database backend, just use the normal ldap_* functions to do all of the work, don't re-invent it all. http://www.php.net/ldap -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Quick email address check
I have used this to good effect function isEmail($email) { if (eregi(^[a-z0-9]+([-_\.]?[a-z0-9])[EMAIL PROTECTED]([-_\.]?[a-z0-9])+\.[a-z]{2,4},$email)) { return TRUE; } else { return FALSE; } }//end function I often have a '+' in my email address (which is perfectly valid) and it really annoys me when a site refuses to accept it. Didn't notice this before but that regex ignores valid TLD's too like .museum, .travel .. Probably not that common but certainly valid. http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to possibly cache something and the theory of better performance / better speed
I used to use a script to grab a random image from a folder of images by scanning the folder, returning the list of images, getting one of them randomly and displaying it. Isn't that what the code is doing? Maybe I'm missing something but you've only mentioned one method. What's the second method to compare against? OK now, getting greedy I want to take it to another level. Instead of having to read the folder for images every time, why not read the image names into a file so that we can maintain therbey caching the list. This is based on 25-30 images in the folder you might even have more. Since in this case we're not going to add images too often, then we can upload the images delete the cache list and a new one will be generated hopefully saving time for all future executions. Assuming only 25-30 images am I splitting hairs here? Yes. I don't think you'll notice any difference with this number, though a quick script would tell you for certain. $orig_image = 'logo.jpg'; $cache_folder = '/path/to/folder'; for ($i = 0; $i 500; $i++) { copy($cache_folder.'/'.$orig_image, $cache_folder . '/' . $i . '.jpg'); } Of course if I have 200 pictures, then this is the way to go but would this really make a difference? Once you get a lot of images (500? 1000? more?) it will but if you only expect 30 there's not much point. Using a cache file you'll need extra checks (make sure nobody slips in a symlink to /etc/passwd or a url or something) - but you should be doing those checks anyway. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php + copy file
$carpeta = subidos; // nombre de la carpeta ya creada. chmool 777 (todos los permisos) copy($_FILES['file']['tmp_name'] , $carpeta . '/' . $_FILE ['file']['name']); copied straight from my reply to the same question on php-db It's $_FILES not $_FILE (an 's' on the end). It's always worth using error_reporting(E_ALL) and ini_set('display_errors', true) when doing development, this would have triggered a notice or warning (can't remember which). -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] require_once dying silently
Richard S. Crawford wrote: Hi, everyone. This one's been driving me bonkers for an hour now. Anyone have any idea why require_once would be dying silently in the script below? $CFG-dirroot = /home/rcrawford/public_html/tanktrunk/tanktrunk; $CFG-dataroot = $CFG-dirroot.'/moodledata'; require_once($CFG-dirroot/lib/setup.php); I've confirmed that the file setup.php exists and is readable. I've got error_reporting in php.ini set to E_ALL. I'm running Apache 2 and PHP5 on Kubuntu 7.10. Nothing shows up in my apache error log, and PHP itself produces absolutely no output, even though it will produce output galore when I put in a deliberate syntax error. Syntax errors in which file? The calling one (where you have the require_once) or the lib/setup.php file? Maybe something in your code is disabling your error reporting, I'd put both: error_reporting(E_ALL); ini_set('display_errors', true); in before the require_once and see what happens. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Writing MySQL Update Query with NULL value
Bill Guion wrote: I'm trying to write a MySQL UPDATE query where one or more variables may be NULL. So, I'm trying something like: $last_name = $_POST['last_name']; $first_name = $_POST['first_name']; $suffix = $_POST['suffix']; $suffix = empty($suffix) ? NULL : $suffix; $phone = $_POST['phone']; $phone_index = $_POST['phone_index']; $update_query = UPDATE 'phones' SET 'last_name' = $last_name, 'first_name' = $first_name, 'suffix' = $suffix, 'phone' = $phone WHERE 'phone_index' = $phone_index;; However, when I echo out this query, I get: UPDATE 'phones' SET 'last_name' = Doe, 'first_name' = John, 'suffix' = , 'phone' = 123-456-7890 WHERE 'phone_index' = 323; I think, for this to properly update the record, it should be: UPDATE 'phones' SET 'last_name' = Doe, 'first_name' = John, 'suffix' = NULL, 'phone' = 123-456-7890 WHERE 'phone_index' = 323; 1) You don't need quotes around your field names. 2) You do need quotes around your data, plus you should use mysql_real_escape_string to stop sql injection attacks: $phone = mysql_real_escape_string($_POST['phone']); 3) What error do you get once you fix both of those up? Your query should end up looking like: $query = UPDATE phones SET last_name=' . mysql_real_escape_string($_POST['last_name']) . ', ... or $last_name = mysql_real_escape_string($_POST['last_name']); $first_name = mysql_real_escape_string($_POST['first_name']); // set a default of NULL $suffix = NULL; if (!empty($_POST['suffix'])) { // note - you need to add the quotes around the data here $suffix = ' . mysql_real_escape_string($_POST['suffix']) . '; } $query = UPDATE phones set last_name='${last_name}', first_name='${first_name}' ..., suffix=${suffix}; -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP with NNTP?
vester_s wrote: Hi, Can anybody tell me how can php connect to NNTP to get the list of all users in the newsgroups? http://php.net/imap supports nntp. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Database abstraction?
Jason Pruim wrote: Hi Everyone! I'm back with yet another question But getting closer to sounding like I know what I'm talking about and that's all thanks to all of you. A free beer (Or beverage of choice)* for everyone who has helped me over the years! Here's my question... I have a program, where I want to take out the field names in a database table and display them... In other words instead of writing: $Query =SELECT First, Last, Middle, Add1 FROM mytable order by $order; I want to write something more like: $Query =SELECT $FIELDNAMES FROM mytable order by $order; So I need to know how to get the field names from the database so that I can populate $FIELDNAMES. I played a little bit and it looks like I might be able to get what I want by doing 2 queries... $QueryFieldNames = DESCRIBE $table; And then some sort of a foreach or maybe a while to populate $FIELDNAMES? Maybe an array so I could do $FIELDNAMES['First'] if I needed to later. then I can use my SELECT $FIELDNAMES FROM $table order by $order query to do my query... If $FIELDNAMES contains all the fields, I have to ask why? If you just want them for the header or something you could do something like this: $fields = array(); $query = select * from $table order by $order; $result = mysql_query($query); $row_counter = 0; while ($row = mysql_fetch_assoc($result)) { if ($row_counter == 0) { $fields = array_keys($row); } print_r($row); } Haven't actually tested it but saves another round trip to the db. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Query in Query problems
VamVan wrote: Hello All, We many times encounter the situations of having Queries inside loop of another query. Many times we can solve the issue by query joins but there will be some situations where we cannot do it. For Example: function Change($id){ $qry_reg = SELECT registrationID FROM registration WHERE event_id = '$id'; $res_reg = $this-mdb2-query($qry_reg); while ($row_reg = $res_reg-fetchRow()) { $userid = $row_reg['registrationid']; $sql_insert = INSERT INTO run (command, event_id, created, user_id, runtime) VALUES ('topic_change', '.$id.', NOW(), '.$userid.', NOW()); $res_insert = $this-mdb2-query($sql_insert); } } In this example you can just use a single query: $query = insert into run(command, event_id, created, user_id, runtime) select 'topic_change', registrationID, NOW(), .(int).$userid, NOW() FROM registration WHERE event_id='.(int)$id.'; -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Database abstraction?
Jason Pruim wrote: On Apr 16, 2008, at 5:37 PM, Chris wrote: Jason Pruim wrote: Hi Everyone! I'm back with yet another question But getting closer to sounding like I know what I'm talking about and that's all thanks to all of you. A free beer (Or beverage of choice)* for everyone who has helped me over the years! Here's my question... I have a program, where I want to take out the field names in a database table and display them... In other words instead of writing: $Query =SELECT First, Last, Middle, Add1 FROM mytable order by $order; I want to write something more like: $Query =SELECT $FIELDNAMES FROM mytable order by $order; So I need to know how to get the field names from the database so that I can populate $FIELDNAMES. I played a little bit and it looks like I might be able to get what I want by doing 2 queries... $QueryFieldNames = DESCRIBE $table; And then some sort of a foreach or maybe a while to populate $FIELDNAMES? Maybe an array so I could do $FIELDNAMES['First'] if I needed to later. then I can use my SELECT $FIELDNAMES FROM $table order by $order query to do my query... If $FIELDNAMES contains all the fields, I have to ask why? What I am trying to accomplish is a customer wants me to add custom fields to their table in my database, I want to use the same code to display the separate fields... In other words right now I have the field names hard coded into my app.. I want to be able to remove the actual field names and have them pulled dynamically from the database, so it doesn't matter if there is 10 fields or 30 fields, it will print a header row that contains ALL the field names and format the table properly. Sure - but you can do it all in one go. Another approach (which is database independent) is select * from table limit 0; Had to throw that in the mix :) -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_connect slowness
Waynn Lue wrote: Our site has been slowing down dramatically in the last few days, so I've been trying to figure out why. I ran some profiling scripts on our site and saw that we're spending between 3-9 seconds on mysql_connect. Then I connected to our db and saw that there were over 100 connections at the time, most of them sleeping. Is this because we don't close mysql connections until the end of script execution? Are you using mysql_pconnect or just mysql_connect? Persistent connections do what you outline and keep the connection sitting there. For this (and some other reasons) most people don't use persistent connections. PHP should clean up regular _connect resources when the script(s) are finished running, you don't need to do it explicitly. How do people generally structure their code to minimize the time they keep mysql connections open? Currently all db connections go through one file, which gets included at the top of the file. One other question, is it better to open one connection, then re-use it later, or just continually open and close per db call? It'll be even slower to open/close per db call. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Xampp question, pretty much 0T
Ryan S wrote: Hello! I have been using XAMPP for quite some time now (thanks to the recommendations from this list) without any real complaints... and the only reason I am writing here is because i am sure a lot of you guys run the same thing considering the amount of people who recommended it to me when I asked for an easy install of AMP. It was easy to install and has given me months of hassle free use... but today i have started facing some strange problems of everytime I start Apache... it crashes my laptop, anybody else run into this? You could try their forums: http://www.apachefriends.org/f/?language=english -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Xampp question, pretty much 0T
After reading a bit I see that if I just copy the data directory in the mySql directory, I can restore it from there? any idea if I have that wrong? Hmm I guess, but I'd take the safer road and open a console and run: mysqldump.exe -u username -p --all-databases --add-drop-database --opt mysql.database.dump so you have an sql file you can restore if necessary. Adjust paths/files/usernames/passwords as necessary. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best practices for using MySQL index
Index on most integer fields only. Text fields can be indexed, but is not important when you design your DB well. Don't index just all integer fields. Keep track of the cardinality of a column. If you expect a field to have 100.000 records, but with only 500 distinct values it has no use to put an index on that column. A full record search is quicker. Hmmm... That's new. :) To explain that further the idea is that if you have something like a 'status' field which can only hold 5 values, there's no point indexing it if there's a reasonably even spread. If you could only ever have a handful of fields with a status code of '1', then it's worth indexing if you have to find those particular records quickly. I don't think mysql supports partial indexes, but some databases do so you only index the fields that match a certain criteria. I'd suggest a more thorough approach to working out what to index rather than just trying to guess what's going on. Work out how long queries are taking (either use the mysql slow log or if you're using a database abstraction class, it should be easy enough to hack in) and concentrate on those first. http://www.designmagick.com/article/16/PostgreSQL/How-to-index-a-database (While it's on a postgresql site, there's nothing specifically for postgresql in that article - the same rules apply to mysql, oracle, mssql). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem imap_headerinfo
Richard Kurth wrote: I get a *Catchable fatal error*: Object of class stdClass could not be converted to string on this line $mail_head = imap_headerinfo($conn, $i); RTM. http://www.php.net/imap_headerinfo It's an object, not a string. print_r($mail_head); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best practices for using MySQL index
Point above about spread still applies, but if you can join index to index, the join goes a lot faster. (A primary key in MySQL is always indexed.) How much is the *a lot*? Thanks. :) If it's a unique (including primary) key then orders of magnitude for millions of rows. If it's a non-unique key, it depends on how many distinct values there are. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] equivalent to perl shift function
Richard Luckhurst wrote: Hi All I am in the process of porting a perl script and I am trying to fin out if there is a php equivalent to the perl shift function? I have been looking at the php manual and google searching so far with no luck. http://www.php.net/manual/en/function.array-shift.php -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Categories like wordpress
Ryan S wrote: Hey, Am not really used to using the JOIN in SQL so am a bit confused as to what kind of data I need to enter into this table: image_category_mapping table: - image_id - category_id It comes down to database normalization (http://en.wikipedia.org/wiki/Database_normalization). The idea behind database normalization is you only ever have one copy of the data, you don't have to update multiple tables to reflect a change. So you only store the image in the 'images' table: create table images ( image_id int auto_increment primary key, image_name text, .. ); For multiple categories to share a particular image, there needs to be a link between a category and an image. If you only ever want one image per category, you could put the image_id in the categories table: create table categories ( category_id int auto_increment primary key, category_name text, image_id int, . ); However the problem with that is if you want more than one image, instead of adding another field to the categories table: create table categories ( category_id int auto_increment primary key, category_name text, image_id int, image_id_two int, . ); which means if you want a category to have 3 images, you need another field and so on, so instead you create a separate table: create table category_images ( category_id int, image_id int ); which means you could have 10 images for that category and no db changes are necessary. So you create the image as normal (insert into images ...). Then when you link it to a particular category, you insert into the separate table: insert into category_images (category_id, image_id) values (.); This also means if you update the image (eg change the name or alt-value or whatever), it's automatically reflected for all categories. How do you get an image for the particular category? SELECT i.* from images i INNER JOIN category_images ci ON (image_id) WHERE category_id='X'; That will give you (multiple if necessary) images for that category. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql query and maximum characters in sql statement
Jim Lucas wrote: Waynn Lue wrote: Wouldn't using LOAD DATA INFILE be better than writing your own script? depends, does the data file match the table column for column? Doesn't have to. http://dev.mysql.com/doc/refman/5.0/en/load-data.html By default, when no column list is provided at the end of the LOAD DATA INFILE statement, input lines are expected to contain a field for each table column. If you want to load only some of a table's columns, specify a column list: LOAD DATA INFILE 'persondata.txt' INTO TABLE persondata (col1,col2,...); But load data infile requires extra mysql privileges. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Web Apps OpenID
Joe Harman wrote: Hey Ya'll! I am curious here if any of you are considering or already using OpenID or Windows CardSpace? Does anyone see this being a big deal??? from a users stand point it seems like a big hassle to get started with it and I'm not sure if it would scare people away or not? any thoughts I've been looking at some PHP scripts out there for OpenID... does anyone have one to recommend??? I have not used this (yet) but the zend framework has support for it: http://framework.zend.com/manual/en/zend.openid.html You don't have to use the whole framework to use this bit, it's designed to allow you to only use the parts you need. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql query and maximum characters in sql statement
Sanjeev N wrote: Hi Jim Lucas, You are correct... i want to run in the same way. but as my 2 tables, column name are different i cant run the LOAD DATA infile. If you're inserting the same data, then use LOAD DATA INFILE to load it into a temporary table, then use INSERT SELECT's to put them into the other tables. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_pconnect issue
bruce wrote: hi... running into a problem that i can't seem to solve... using mysql_pconnect() and i'm trying to figure out what parameters have to be used in order to connect to a local mysql session, where mysql is accessed using the defaults (ie, no user/passwd/hostIP) Use 'localhost' for the host, no idea what you'd use for the user/pass, but mysql requires a username at least. If you're not entering one, it's using the username you are logged in as. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] creating an xls file from mysql data
Richard Kurth wrote: This script will create an xls file from the data that is sent to it When I run this it only gets one recored and it is supposet to get all the records that are past by the $_POST[selectedcontactlist] I think I have a } in the wrong place but I can not figure it out anybody have a suggestion $_POST[selectedcontactlist]=3,45,65,23,12,4,56; //this is a sample of what is past $ExplodeIt = explode(,,rtrim($_POST[selectedcontactlist],,)); $Count = count($ExplodeIt); for ($i=0; $i $Count; $i++) { $sql = SELECT * FROM contacts WHERE id = '$ExplodeIt[$i]'; Instead of doing that, do this: /** * This section makes sure the id's you are going to use in your query are actually integer id's. * If they aren't, you'll get an sql error. * */ $ids = array(); foreach ($_POST['selectedcontactlist'] as $id) { if (!is_int($id)) { continue; } $ids[] = $id; } // all posted values are duds? show an error. if (empty($ids)) { echo No id's are numeric, try again; exit; } $sql = select * from contacts where id in ( . implode(',', $ids) . ); That'll get everything for all of those id's and then you can loop over it all once: // print out the header for the csv file here. // then loop over the results: while ($row = mysql_fetch_assoc($sql_result)) { // put it into file here. } // close the file // print it out. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] creating an xls file from mysql data
Or you can do it straight from MySQL, which is a lot faster: With the caveat that you need extra mysql permissions to be able to do that. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] creating an xls file from mysql data
This is what the $_POST['selectedcontactlist'] looks like 121,17,97,123,243,52,138,114,172,170,64,49,60,256,176,244,201,42,95,4, First question is why do you need to pass it through like that? it is not coming across as an array so the foreach is throwing an error I assume it always has a ',' in it if you only choose one box. if (strpos($_POST['selectedcontactlist'], ',') === false) { // no boxes were selected - or at least there is no comma. die(); } // turn it into an array $selected_contact_lists = explode(',', $_POST['selectedcontactlist']); This number are selected in a checkbox and passed with a javascript to the script should I be converting them to an array in the javascript. No need to do that either, just make the form variable an array: input type=checkbox name=selectedcontactlist[] value=X The [] turns it into an array which php can then process automatically as an array. You can check that some checkboxes are ticked using an idea similar to this: http://homepage.ntlworld.com/kayseycarvey/jss3p8.html Though I'd just either set a flag or counter instead of a message when you find one that is checked. If you're just checking that any are checked, as soon as you find one, return true out of the function. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] tracking Mials Which were bounced.
mike wrote: Seems like the general way is to create a mailbox (POP3 or IMAP) to accept the bounces, then check it periodically and mark the emails as invalid in your local database. I would set threshholds so you don't mark something failed that only bounced once - it could have been a mail setup error or something else; I'd say wait for 3 failures in a 7 day period at least. If you get 3 bounces by that point, the address is probably safely dead. You can use PHP's IMAP functions to check the mailbox (even for POP3) or a million classes or your own functions directly on the socket (POP3 is a simple protocol) - it also helps if you parse the bounced email message to process the return address and the mail code; perhaps build something better than just 3 failures = invalid, but actually determine if they're full out failures, or if they're just temporary bounces, etc. I use this method and it works reasonably well. The hard part is the last sentence - there are so many ways to say mailbox full - half don't include smtp error codes, the rest tell you the same thing in thousands of different ways. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can Safari 3 be forced to cache a large jpeg with PHP headers?
Rob Gould wrote: I am creating a touch-screen kiosk application, using a full-screen version of Safari 3.1, and was wondering if there's a way I can force Safari to cache a large background image JPEG. What I'm finding is that Safari 3 will sometimes cache my large 1.1 MB background image (1680x1050), and display perfectly fine, but on occassion Safari 3 will think about the cache and Flash the screen white for a millisecond and then draw the screen. Firefox doesn't seem to have this problem, so unfortunately this is a Safari 3 only issue. I really only want to cache this ONE image - - - nothing else. Is that possible? How are you sending it? through a php script or through a normal html tag? If it's through a php script, try setting a far-future expiry header. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] question about validation and sql injection
Dmitri wrote: your validation looks good enough to me. If you only allow alphanumerical chars, then your should not be worried about sql injection also use addslashes($username) before you insert into database and you should be fine. Usually addslashes is enough to prevent this, but the validation that you have is also enough. So if you worried about the sql injection, then use both and you should be fine. Ahh, that's just wrong. I can encode an sql query into hex code and that'll pass alpha-numeric validation. Use mysql_real_escape_string when you save your data, or use parameterized queries. http://www.php.net/mysql_real_escape_string http://www.php.net/manual/en/pdo.prepared-statements.php http://www.php.net/manual/en/mysqli.prepare.php -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_SESSION lost
$ php -v PHP 5.2.4 (cli) (built: Sep 18 2007 08:50:58) Copyright (c) 1997-2007 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies This shows the php command line version, not the webserver php version. To do that, look at a phpinfo() page. They may indeed be the same but don't think that they always will be. I can run php4 for my webserver version and php5 command line and vice-versa. It seems some PHP module might be missing, I tested it with a page1.php: More likely the session.save_path is either not writable or not accessible by this script. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with htmlspecialchars in version5.2.5
It flance wrote: Hi, this statement: echo nl2br(htmlspecialchars($row['jobdescription'], ENT_QUOTES, 'UTF-8')); works for php4.3.10 but not for php5.2.5 What doesn't work exactly? What's the output in php4 compared to php5? -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Trying to install imagick PECL module
mike wrote: It doesn't appear to -need- this MagickWand stuff, yet configure keeps failing on it. I guess it really does need the api stuff then ;) Which parts of imagemagick have you got installed or how did you install imagemagick? for configuring php (and other software) you need the headers as well as the main package (if you're installing from a package based system). -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] reretrieve header from email
Richard Heyes wrote: Yui Hiroaki wrote: Does anyone knows how to retrieve Header from email? Depends how you have your email. For example you could use Mail_mimeDecode, optionally in combination with Net_POP3. If it's an IMAP account you're checking, you could use the IMAP extension instead, which would also mean you probably won't need Mail_mimeDecode. The imap functions can check a pop3 account, it doesn't have to be an imap account. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] syntax of sprintf
the select query is $selectqueryusername = sprintf(Select username from individuals where username='%s', mysql_real_escape_string($username)); The syntax is fine. $result = mysql_query($selectqueryusername); if (!$result) { echo Error! *** . mysql_error(); } also for insert query if i have a numeric value i should be writting %d correct, i have a numeric value however before inserting that numeric value i am appending a character - to combine area code and phone number example 09-123 4567 so i am considering this as %s as there is a character. is this correct. Yes. The placeholders are all documented pretty well: http://www.php.net/sprintf -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strip_tags and nl2br
James Colannino wrote: Hey everyone, I have a little bit of a quandry. I need to strip HTML tags from user input, but I also need to convert \n's from the textarea elements to br tags so it will display properly in a browser. RTM. Supply the tags you want to keep when you call strip_tags. $stripped = strip_tags($data, 'br/br'); -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strip_tags and nl2br
James Colannino wrote: Chris wrote: RTM. Supply the tags you want to keep when you call strip_tags. $stripped = strip_tags($data, 'br/br'); I can do that, but my question had to do with strip_tags seeming to get rid of \n's, not br tags. This is why I was concerned. If I run strip_tags(), followed by nl2br, the br tags that nl2br generates should be there. Are you sure there are newlines before you run strip_tags? It doesn't touch newlines because they aren't html entities. $ cat eg.php ?php $string = bhere is a bold tag/b\na href='http://www.example.com/'Link to example.com/a\n\n; echo Strip tags only:\n; echo strip_tags($string) . \n; echo str_repeat('-', 10) . \n; echo Strip tags nl2br:\n; echo nl2br(strip_tags($string)) . \n; ? $ php eg.php Strip tags only: here is a bold tag Link to example.com -- Strip tags nl2br: here is a bold tagbr / Link to example.combr / br / -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP + MySQL transactions
Philip Thompson wrote: Hi all. I'm currently working on a project that's in its beta stage. Due to time restraints, we were unable to build in transactions from the beginning. Well, we're getting to the point where we can now put in transactions. Basically, I'm curious to find out your opinion on the best way to accomplish this. Currently, my thoughts for doing this are: ?php function someFunctionThatNeedsTransactions () { $this-db-begin(); // Start transaction $this-db-query(SELECT...); // Run my queries here $this-db-query(UPDATE...); // Do some PHP logic here $this-db-query(SELECT...); // Run more queries $this-db-query(INSERT...); $this-db-commit(); // Commit transaction } ? If there was a failure in one of the queries, that would be caught in the database class ('db' instance) and ?php $this-rollback(); ? would be called. Note that all the tables are InnoDB and the above code/functionality works. Ideally, I would have liked to use stored procedures, but that decision was not mine. So are there any complications I'm potentially missing? I'd get your db class to handle nested transactions, so if you had something like this: $db-begin(); someFunctionThatNeedsTransactions(); ... .. oops, need to rollback. $db-rollback(); the bits between someFunction and the rollback will be committed (by the function) and can't be rolled back. See http://dev.mysql.com/doc/refman/5.0/en/savepoints.html The situation might not come up but it can't hurt to have it already built in just in case. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP + MySQL transactions
See http://dev.mysql.com/doc/refman/5.0/en/savepoints.html The situation might not come up but it can't hurt to have it already built in just in case. This doesn't appear deal with *nested transactions.* It appears that it will use a single transaction and you can just save up to a certain point upon failure. As of this point, it's all or nothing b/c we are dealing with fairly crucial information. However, I will look into building savepoints into the class so that I'll have that option in the future. Sounds like a difference in semantics :P In my head they're the same thing - if the middle bit fails, it'll roll back. If it works, you continue doing whatever you're doing. If everything succeeds then you commit everything at once. If part of something fails, then you roll it all back. At least you're more protected in the situation I mentioned above where you'd get partial data saved. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Still need help with some kind of memory leak in my php database program. General hints for php would help
// IF I RUN THIS THROUGH A LOOP: // for($j=0;$j20, $j++){ $many_selected[$jj] = fu_bar($pg, $BIG_SELECT_cmd)} THE TEST PROGRAM CRASHES so I think I have more copies of the result of this query than I need. This is just going to create a multi-dimensional array - with each element being one result set - so yes that's going to take a lot of memory. To debug your memory issue, see some ideas here: http://www.davedevelopment.co.uk/2008/05/12/log-memory-usage-using-declare-and-ticks-in-php/ but instead of keeping a global variable (or session variable), log it to a file instead: http://www.davedevelopment.co.uk/2008/05/12/log-memory-usage-using-declare-and-ticks-in-php/#comment-52074 -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Still need help with some kind of memory leak in my php database program. General hints for php would help
Mary Anderson wrote: Thanks for responding. I hadn't realized memory_get_usage was available. That will be an enormous help. And I wasn't too clear in my note. Actually, it did not surprise me that the loop crashed the test code. I expected it to. What does surprise me is that the test code works with one call to the data base, but the same logic in the application crashes the system. random guess Maybe you're accidentally calling the same code multiple times? You can use xdebug to work out what code is called and where it's called from. See http://www.xdebug.org/ Extremely handy little tool that one :) -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Weird update problem..
Ryan S wrote: This is really weird... i have tried the same exact code in phpmyadmin and it works like a charm, but when i run the script... no errors then i go to phpmyadmin and nothing has changed :( this is the code: $how_many_to_update=count($cardno_array); // update the cards status to sent for($i=0;$i$how_many_to_update;$i++) { $update_sql=update greetings set is_sent=1 where cardno='.$cardno_array[$i].' and rand_str='.$rand_str_array[$i].' LIMIT 1; $result = mysql_query($sql_1); You're running the wrong query. You're building a query in $update_sql but running something else. Change the mysql_query($sql_1) line and you should be right to go. Slightly OT, any better way to run the multiple updates needed above than instead of running the update query in a loop? I searched google and the best i could find was the IN() for mySql... but that does not take 2 parameters (eg: cardno and rand_str) it would work just on card_no like this in('14','34') An IN() clause is the same as: field='x' or field='y' so you can use that: update greetings set is_sent=1 where cardno='a' or cardno='b' if you need the extra stuff (about the rand_str) you should be able to: update greetings set is_sent=1 where (cardno='a' and rand_str='a') or (cardno='b' and rand_str='b') Try it with some test data first obviously. Some of the comments here: http://dev.mysql.com/doc/refman/5.0/en/update.html Provide other suggestions. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image modifications
Ronald Wiplinger wrote: I would like to find some samples to start with. We want to upload a picture and the user may apply some filters or instructions to create a new picture, based on the uploaded picture and the available filters and instructions. The idea of it is not really mature, since we have no idea where to start and what is possible to do. Depends. What do you want to do (what is a filter, what are instructions)? imagemagick and to a (much?) lesser extent, gd - let you do image manipulations but it depends what you need to be able to do. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PEAR_Exception PEAR_Error
Al wrote: I'm using the pear class Mail_RFC822::parseAddressList() which apparently only throws an error_object for PEAR_Error. The manual says that PEAR_Error is deprecated, so I'd like to use PEAR_Exception; but; am having trouble getting it to recognize the error. Probably better to ask the pear mailing list: http://pear.php.net/support/lists.php -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Query refuses to recurse all rows
$numrows1 = pg_numrows($result1); $row = 0; do { $myrow = pg_fetch_array($result1, $row); snip $numrows2 = pg_numrows($result2); $row = 0; do { $myrow = pg_fetch_array($result2, $row); You're overwriting your variables. $myrow from result 1 is being killed off when it gets into the $myrow loop from result 2. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A problem with fgets()
Usamah M. Ali wrote: Hello, I have a function that picks up a random entry from a file consisting of city names, each name on a separate line. The random value is generated by rand() before fseek()ing to the position determined by it. The problem is that when using fgets() to get a random line, it returns a part of the city name, not the whole name. AFAIK, fgets() reads a whole line, and even if it's in the middle of a line, it reads the whole next line. fseek doesn't go to the start of a line, it goes to a particular byte - so that's where the problem lies (not with fgets). There's no function (that I could see) which would go to the start of the line based on that offset (I guess you could fseek to a particular spot then reverse char by char until you find a newline - but that'll be rather slow for anything that has a long line). You could read the whole thing into an array and do a rand on that: $cities = file('filename.txt'); // take 1 off from the max number as $cities is a 0 based array $number_of_cities = sizeof($cities) - 1; $city_number = rand(0, $number_of_cities); $city = $cities[$city_number]; Though if you have a big file that reads the whole thing into memory etc. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A problem with fgets()
I just need to figure out why when using fgets() with fseek() rand(), the script returns partial strings form the city names. Because fseek doesn't necessarily put you at the start of a line. It puts you anywhere (which could be the start, middle, 3 chars from the end) according to the number of bytes you tell it to start at. Then fgets reads the rest of the line. A file that looks like this: (numbers are the bytes for ease of explanation) 123456789 is going to be different to a file that looks like this: 1234 56 789 and if you tell me you want to start at byte 5, then in file 1, that's the middle - in file 2 that's the start of the second line (#4 is a newline char :P). -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Extensions as Shared Objects?
Weston C wrote: This might be a dumb question with an obvious answer somewhere, but I'm wondering if it's possible to build php extensions as shared objects that plug into the PHP binary much like an apache shared module plugs into apache. Yes. See http://www.php.net/dl (though a lot of hosts disable this functionality for security reasons). -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A bit 0T - WAMPSERVER
Ryan S wrote: Hello all! Had some big problems with XAMPP crashing my windows (Vista) laptop 8 times out or 10 (actual figures) as I started XAMPP so have shifted over to WAMPSERVER2 So far so good, no crash... but their website seems to be down and need one small tidbit... if anyone of you are using WAMPSERVER can you tell me how to change MySqls default login? its on root/no password presently... want to change it to root/something STW? http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Embed images in emails
Iñigo Medina GarcĂa wrote: Hi Bastien, thanks for the tip. I've already done it and it didn't run. But I'll check it again. iñigo On Thu, May 29, 2008 at 6:11 AM, Iñigo Medina GarcĂa [EMAIL PROTECTED] wrote: Hi, I'm trying to send emails with embed and dynamic images: a normal tell a friend feature which sends the email with item's data: author, title, image-cover, etc. Ideas PEAR and mime classes apart? thanks iñigo -- Iñigo Medina GarcĂa LibrerĂa DĂaz de Santos Madrid (Spain) Dpt.Desarrollo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You'll need to create a HTML email, and then embed the image with the img tag, using the entire path to the image as the source attribute img src='http://www.mysite.com/images/thisimage.jpg' You may want to look at some email that you get that have images in them and just view the source. Using an img src doesn't embed the image, it's fetched on the fly from the url (if you allow remote images to be displayed). Use something like phpmailer which can embed the images in the content for you (saves the headaches of working it all out yourself). http://phpmailer.codeworxtech.com/tutorial.html#4 -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Embed images in emails
Iñigo Medina GarcĂa wrote: Hi Chris, yep, phpmailer is a good work too. But it works the same i said about htmlMimeMail5. So use either package to figure out what it does and how it does it - you can learn a lot from other peoples code. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Imagick installation issue
This is the output for ldd -r for imagick.so. There are a number of dependencies that I don't recognize and I think there may be other packages that need to be installed. undefined symbol: zend_ce_iterator (/usr/local/lib/php/extensions/no-debug-non-zts-20060613//imagick.so) undefined symbol: core_globals (/usr/local/lib/php/extensions/no-debug-non-zts-20060613//imagick.so) undefined symbol: executor_globals (/usr/local/lib/php/extensions/no-debug-non-zts-20060613//imagick.so) undefined symbol: zval_add_ref (/usr/local/lib/php/extensions/no-debug-non-zts-20060613//imagick.so) undefined symbol: OnUpdateBool (/usr/local/lib/php/extensions/no-debug-non-zts-20060613//imagick.so) How did you create the imagick.so file? Did you reconfigure php? What configure command (and arguments) did you use? Did you get any errors when you ran configure or make? Normally when you try to build a module like this you need the -dev or -devel or -headers package (ie imagemagick-dev or -devel or -headers depending on how they decided to name it). Do you have that installed? -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Runs But Does Not Display on Linux
Wei, Alice J. wrote: Hi, I am currently using a Linux box with Fedora to run my PHP scripts, which I have seen in the download page at http://www.php.net/downloads.php that We do not distribute UNIX/Linux binaries. Most Linux distributions come with PHP these days. What I am wondering is, if I can run my scripts by using the command like php some_php.php, as long as it does not require me to have it displayed on the web page or in need of using a mssql_connect function, it does not give me any errors at all. Otherwise, it consistently gives me errors Call to undefined function: mysql_connect() I can only see the HTML code of the php functions I call within the code at the command output in text format, but I cannot see it on the browser. Are these two errors related? I tried installing PHP and Apache afterwards, but it seems that it is not providing a different message. Have I missed something here? Some servers have display_errors disabled in their php.ini files and it only logs errors. If you add: error_reporting(E_ALL); ini_set('display_errors', true); to the top of your test script, does it show any errors now? mssql is not a standard module, you'll need to get your host/server admin to install it. There are detailed instructions on the php site: http://www.php.net/manual/en/mssql.setup.php If you get stuck, at which step do you get stuck? -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink oddity
function saveRecord ($db,$POST) { $bd = /absolute_path_to_document_root; $fp = /path_to_files_from_document_root/; $ud = $bd . $fp; snip $path = $ud.$file; // absolute path to newly named file if ($fail || !$name || !$temp) continue; // @unlink($ud.$file); @move_uploaded_file($temp, $path); @chmod($path, 0777); Why not just unlink($path) ? It's the same thing but you take 2 variables out of the problem. While you're trying to debug this remove the '@' signs. An error message will be particularly useful. Check your logs if you can, otherwise turn up error reporting and display errors until you work out what's going on. error_reporting(E_ALL); ini_set('display_errors', true); -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] a questoin about the # char
Sebastian Camino wrote: Hello, I want to know what the # char does. In a url it's an anchor tag (http://www.w3schools.com/HTML/html_links.asp). In php it's used to mark a comment. ?php # this is a comment and not executed. ? It means nothing specific in a filename. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Does PHP support utf16 encode / decode
hce wrote: Hi, I know PHP supports utf8 encode/decode, but does it support utf16 encode/decode? If yes, would you please point me a php manual URL? It's listed as supported under the mbstring functions here: http://www.php.net/manual/en/mbstring.supported-encodings.php -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysqliconnect issue
Jason Pruim wrote: Okay, So I'm going to just assume that my issue is the fact that I'm tired... and my mind won't work properly. [Mon Jun 16 22:27:58 2008] [error] PHP Warning: mysqli_connect() expects parameter 5 to be long, string given Now parameter 5 is the database name, I echoed out each of the parameters and everything looks right... here's the line that's causing the problem: mysqli_connect($link, $server, $username, $password, $database) or die('Connection failed in dbmysqliconnect.php'); No, #5 is the port number (http://www.php.net/mysqli_connect). You want: $link = mysqli_connect($server, $user, $pass, $dbname); $link can't be passed to mysqli_connect because it doesn't exist yet ;) -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Case sensitive password
R.C. wrote: I have coded a php page that accepts a password. What is the code to make sure the password entered is NOT case-sensitive? Before you store the password, make it all lowercase (or uppercase, whatever you prefer). $password = strtolower($password); When you compare the passwords, turn it all to lower (or upper) case before you compare it. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Case sensitive password
R.C. wrote: Thank you for your reply. The password is not stored, actually, like in a databse. We're only dealing with one password. When the user inputs the password, he/she should be able to input either in lower or upper case or both abd they should have access to the protected file in this case. As Nathan mentioned, just compare them in the same way. $stored_password = strtolower($stored_password); $user_password = strtolower($user_password); if ($stored_password == $user_password) { echo Yay!; } else { echo No :(; } -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] losing mysql connection during cron job
Thanks for the suggestion. I am currently successfully working around this error by another method, although your suggestion is probably better. The reason I posted this problem, though, is that I want to understand *why* I'm getting the Lost connection to MySQL server during query error. If anyone has had a similar experience using cron jobs or sleep() I'd love to hear from you. - database is restarted for whatever reason (log rotation, dba does an upgrade etc etc). - mysql has a 'wait_timeout' setting which could trigger it http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#option_mysqld_wait_timeout You need to do a mysql_close(); mysql_connect(...) before mysql_query works again - otherwise mysql_connect will just return the same resource id (or I guess just use the 'new_connection' flag for mysql_connect and skip the mysql_close()). -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Associative Arrays
Paul Novitski wrote: At 6/19/2008 05:55 PM, VamVan wrote: How to create an associative array of this kind in PHP? return array( 12345 = array( 'mail' = '[EMAIL PROTECTED]', 'companyName' = 'Asdf Inc.', ), 54321 = array( 'mail' = '[EMAIL PROTECTED]', 'companyName' = 'Asdfu Corp.', ), ); This is the right PHP syntax, except that you've got an extraneous comma before the closing parenthesis of each array that's going to throw a parse error. Actually that's allowed (and by design too) :) -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 5.3 Timeline and Features(true anon functions? shorter array syntax?)
Weston C wrote: Just curious if anyone knows the rough timeline for PHP 5.3. Also curious if anyone knows whether anon functions/closures or a shorter JSON-ish array syntax are being considered for inclusion. I know there were two patches announced in December/January: Ask the -internals list - that's where those decisions are made. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Memory profiling tools
Larry Garfield wrote: Hi all. I have a rather large application on which I need to do some memory performance profiling and optimization. Basically it's eating up more RAM than it should and I'm not sure why. I have some suspects, but nothing concrete. Are there any (open source) tools that people can recommend for such a task? Or any programming tricks one can recommend to identify the size of a given data structure? Windows or Linux are both fine; I have access to both. You could use ticks: http://www.davedevelopment.co.uk/2008/05/12/log-memory-usage-using-declare-and-ticks-in-php/ though see my comments (#7) about why you don't want to store the info in php itself :P -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] prepared statement
ctx2002 wrote: Hi all: We are use PHP PDO's Prepared statement to send SQL query to Mysql server. According to PHP PDO doc, Prepared statement are fast for executing multiple SQL queries with same parameters. by using prepared statement you avoid repeating the analyze/compile/optimize cycle Our application is a web application, each request will have a new Prepared statement handler generated by PDO Lib. so prepared statement actually slower than non-prepared statement. I just want to know how can we cache Prepared statement handler, So we can re use it in later http request. for example: we have a query to pull out all product information from mysql db, each query just has a different product id , all other parts are same. The query is the same. It works out to be: select * from products where id='X'; So you can just do something like this: $product_query = $dbh-prepare('SELECT * from products where id=?'); $ids = array(1,2,3,4,5); foreach ($ids as $product_id) { $product_query-execute(array($product_id)); $product_details = $product_query-FetchAll(); print_r($product_details); } -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] prepared statement
ctx2002 wrote: I mean for each different requests/connection how can i use same prepared statements object that was generated by PDO lib/mysql Server. You can't. Resources/connections are done per request and can't be shared - it's done that way by design. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] prepared statement
ctx2002 wrote: thanks for answering my question. I have checked PHP PDO doc. PDO:: query() can send a query to server. my question is, does PDO:: query() generates prepared statement automatically? or I have to explicitly call PDO:: prepare() to use prepared statement? You have to use prepare/execute to get prepared statements. Query does a straight query (same as mysql_query or pg_query or whatever else you're using). -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] can you give me example of website using postgresql database?
I'm not sure what you're looking for in a RDMS, but the simple fact that you are having a hard time finding a robust, live site that uses PostgreSQL should scare you more than Sun's purchase of MySQL. Just because you don't know any doesn't mean there aren't any. Someone else pointed out this list on another mailing list: http://people.planetpostgresql.org/xzilla/index.php?/archives/324-The-Big-Guys.html Here's another good one: http://highscalability.com/skype-plans-postgresql-scale-1-billion-users Yahoo also just ran a story about a 2-petabyte db based on postgresql (yes it's a modified db so not 100% postgresql). http://www.informationweek.com/news/showArticle.jhtml?articleID=207801579cid=feed-yahoo-news -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: FW: [PHP] REALLY NEWB QUESTION - include issue
-Original Message- From: Thijs Lensselink [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 01, 2008 1:58 AM To: php-general@lists.php.net Subject: RE: [PHP] REALLY NEWB QUESTION - include issue Quoting TS [EMAIL PROTECTED]: Code segment? Exact error message? (Is there more context?) Include (/file); Function.include/a]: open_basedir restriction in effect. File(/var/www/vhosts/domain/httpdocs/file.php) is not within the allowed path(s): (/var/www/vhosts/differentdomain/httpdocs:/tmp) in /var/www/vhosts/samedifferentdomain/httpdocs/custom-template.php on line 151 /var/www/vhosts/domain/httpdocs/file.php is not in the paths you allowed: /var/www/vhosts/differentdomain/httpdocs or /tmp So you'll need to adjust it through your apache config or you can disable it just for that domain as well. See http://www.php.net/manual/en/configuration.changes.php#configuration.changes.apache and http://www.php.net/manual/en/features.safe-mode.php#ini.open-basedir -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: V4 Vs V5 Issue
Neil wrote: Hi Unfortunately this editor does not run in any other browsers. however I do not believe that it is the java script that is the problem because it runs and works and has done so for years on the current and earlier V4 servers. http://www.microsoft.com/downloads/details.aspx?familyid=e59c3964-672d-4511-bb3e-2d5e1db91038displaylang=en Not as powerful as firebug but it gives you a lot more help than the IE script debugger. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CURL de-bugging: So why am I not getting the results page on the target site?
ioannes wrote: I didn't get any brave response on this, but given the other thread on 'encription' I was wondering could anyone decrypt the __VIEWSTATE string at the end of this message. It is part of the input page whose results page I am trying to retrieve back onto my server for further php work. I replicated the source from that input page onto a page on my server, and when I click the submit button it correctly goes to the target results page, on the other site though, however it did not work without the whole of the string below. The experiment proved though that without the __VIEWSTATE the results page will not return. So I am just wondering, as I have not been able to repeat this using curl, what the is included in that string. There's a challenge for anyone with whatever resources it takes. echo base64_decode($view_state_string); viewstate in asp.net is like sessions in php (I believe, I could be completely wrong :P). -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CURL de-bugging: So why am I not getting the results page on the target site?
Chris wrote: ioannes wrote: I didn't get any brave response on this, but given the other thread on 'encription' I was wondering could anyone decrypt the __VIEWSTATE string at the end of this message. It is part of the input page whose results page I am trying to retrieve back onto my server for further php work. I replicated the source from that input page onto a page on my server, and when I click the submit button it correctly goes to the target results page, on the other site though, however it did not work without the whole of the string below. The experiment proved though that without the __VIEWSTATE the results page will not return. So I am just wondering, as I have not been able to repeat this using curl, what the is included in that string. There's a challenge for anyone with whatever resources it takes. echo base64_decode($view_state_string); or maybe print_r(base64_decode($view_state_string)); I don't know if it will return a string or an array or something else. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Log files
Mark Bomgardner wrote: I am writing an application in which I want to create log files. I am weighing the difference between using text files and using a database to house the data. It appears to me that there is really no advantage either way or is there? There are pros and cons to both methods, but I am concerned about opening and closing a text file some many times that it may cause and issue. The file may be opened and closed 1,000 or more times a day. Opening/closing a file that number of times won't cause a problem, 1,000 isn't a lot a day. If you needed to write something 1,000 times a minute, you probably couldn't do that with a file without getting into contention/locking issues. What will you do with the logs once you have them? Do you need to run reports based on the data in them? Will you need to search for information in the logs? If you need to run reports or search for info in the logs, I'd use a database. If you just need the logs for Person A logged in at this time type messages then a file should be fine. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Session variables disappear (some of them only)
Then the errors sometimes occur in my apache2/ssl_error_log (undefined index in $_SESSION variable). When I check the sess_12345789... file, some of the variables are missing : $_SESSION[a] and [b] are there, but not $_SESSION[c], even an empty one, it is just gone. That's all I know. Sounds like for those situations, the user doesn't have one of the options set (the database is returning a null value). Check that by matching up whatever 'a' and 'b' are with what's in the database. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP's mail(): proper way to send a 'From' header
?php $to = [EMAIL PROTECTED]; $from = [EMAIL PROTECTED]; $subject = This is a test!; $body = \tThis is a test email.\n; $body .= That is all.; $headers = From: .$from.\r\n; $headers .= Reply-To: .$from.\r\n; $headers .= X-Mailer: .basename(__FILE__).-PHP/.phpversion().\r\n; $headers .= Return-Path: .$from.\r\n; mail($to,$subject,$body,$headers,'-f'.$from); ? Note the fifth parameter passed to mail(): http://php.net/mail And also note that the 5th parameter is an email address only.. Don't do something like: ?php $from = Me [EMAIL PROTECTED]; and try to use that as the 5th parameter, it won't work. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question before I end up writing alot of extra code...
Here is a VERY simplified test :) MAIN PAGE: ?PHP if($row['Tab'] == done){ $Tchecked1 = CHECKED; $Tchecked2 = NULL; }else{ $Tchecked1 = NULL; $Tchecked2 = CHECKED; } echo fieldsetTabBR input type=radio name=rdoTab value=done $Tchecked1Done BR input type=radio name=rdoTab value=on $Tchecked2Not DoneBR /fieldset; ? PROCESSING: ?PHP $tab = $_POST['rdoTab']; $record = $_POST['txtRecord']; $updateQuery = UPDATE `current` SET Tab='$tab' WHERE Record='$record'; mysqli_real_query($link, $updateQuery); Checkboxes and radio buttons only post back the values for the ones selected. If you have: form method=post action=?php echo $_SERVER['PHP_SELF']; ? input type=checkbox name=ids[] value=1Option 1br/ input type=checkbox name=ids[] value=2Option 2br/ input type=checkbox name=ids[] value=3Option 3br/ /form view that, and tick options 1 and 3, only they will be available in $_POST. This has not changed in any version of php, it has always been this way - and it will be exactly the same in perl, python, ruby and any other language. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Should I go with the Singleton Pattern or wait for 5.3?
Luigi Perroti wrote: Hello, I'm planning out a simple project and most probably I will need the functionality provided by the Singleton pattern. However with the next 5.3 release I would be able to conveniently use classes directly without instancing them. This would be a comparable option thanks to late state binding and the possibility to reference the class using a variable. What path do you suggest I should take? I can wait for the 5.3 release since I'm not in a hurry. I would like to hear your opinions in particular regarding the performance and code maintainability aspects. Is this a decision for the whole project or just one particular part of it? Can that one part be put off until later or does it need to be done first? -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DB search and case sensitive comparison
Now what I need to do is to ensure that the lookup_string is in the useragent string and the CASE is the same: IE: Mozilla and not MOZILLA or mozilla etc... Make the database do the work if possible. mysql select * from a where a like '%MOZILLA%'; +-+ | a | +-+ | Mozilla | | MOZILLA | +-+ 2 rows in set (0.00 sec) mysql select * from a where a like BINARY '%MOZILLA%'; +-+ | a | +-+ | MOZILLA | +-+ 1 row in set (0.00 sec) -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How can i get the location of an exit()/die() from within register_shutdown_function()?
Mathijs van Veluw wrote: Hello there, I have an shutdown function to catch fatal-errors etc.. Now when there is an exit() somewhere i get an empty message from get_last_error(). I want to know the location of this exit() or die(). Is there a way to get the file and line-number from where the exit/die originated? debug_backtrace ? -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] accessing variable value
Sudhakar wrote: i need help with accessing the value of a variable from a different page. i have an index.php file which has 2 files included to display header and footer and the center portion changes based on the link clicked on the footer. header.php ?php echo h2 Text from header.php file /h2; ? footer.php ?php $title=Title of Footer Page; ? a href=index.php?page=webWeb Development/a | a href=index.php?page=softwareSoftware /a index.php ?php $pagename=$_GET[page]; $title=Index page of Company name; ? html head title?php echo $title; ? /title meta name=keywords content=?php echo $keyword; ? meta name=description content=?php echo $pagedescription; ? /head body ?php include(header.php); ? p /p centerThis is the text in the center/center p /p ?php if($pagename==web) { include(web.php); } if($pagename==software) { include(software.php); } ? ?php include(footer.php); ? /body /html whenever i click the links for Web Development or Software which appears from the footer a query string is passed to index.php I am able to display the content of web.php and software.php using the if() condition and include() what i need to display is a different title for web.php and software.php when a user clicks Web Development along with the content i want the title of the page to change for SEO purpose. i have defined $title differently in web.php and software.php however presently the title being displayed for index.php when a user clicks web.php and software.php the title is the same Index page of Company name as this is defined in index.php and my title tag is written as title?php echo $title; ? /title however the title tag remains the same whether i click web development or software link. how change i change the code to display different titles. ?php $pagename = ''; if (isset($_GET['pagename'])) { $pagename = strtolower($_GET['pagename']); } switch ($pagename) { // hardcode the pages you *know* exist. // don't just include $pagename.php // as i can make up a pagename of whatever i like // and it will break your site // i know web.php and software.php exist // so if the pagename is one of those, // just include the relevant file. case 'web': case 'software': include($pagename.'.php'); break; // just in case I remove the pagename variable from the query string // or make up a random pagename // make sure you set up some default values! default: include('defaults.php'); } ? html head title ?php echo $title; ? /title ... body ?php echo $content; include 'footer.php'; inside the 'web.php' and 'software.php' files, set your variables: in web.php: ?php $title = 'This is the web.php page title'; $keywords = 'These are the keywords for the web.php page'; $content = EOD This is the content of the page. Read up about heredoc syntax here: http://www.php.net/heredoc EOD; and to the same inside the software.php and any other files you need. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Apache blocking certain requests instead of php
Børge Holen wrote: On Thursday 24 July 2008 09:14:55 Chris wrote: I was hoping there's a way to tell apache to block requests where id=non_numeric. It's trying to do a remote inclusion. It's easy for you to fix in php: if (isset($_GET['id'])) { if (!is_numeric($_GET['id'])) { die(Die hacker die!); thats sudden! ;) ok maybe a bit harsh :P stop hacker stop ? ;) -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Apache blocking certain requests instead of php
Thanks, I'm already doing something like that, but I want to stop it getting to php. http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html Ask on an apache list how to use it. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Apache blocking certain requests instead of php
I was hoping there's a way to tell apache to block requests where id=non_numeric. It's trying to do a remote inclusion. It's easy for you to fix in php: if (isset($_GET['id'])) { if (!is_numeric($_GET['id'])) { die(Die hacker die!); } } I'm sure there would be a way to do it with ModRewrite or something but it's 5 lines of code in php so I'd do it there *shrug*. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] storing and then displaying HTML for update
Rod Clay wrote: I'm writing a php application which includes accepting and storing HTML for routine display by the application. All of this seems to be working fine. However, I also want to display the raw HTML for administrators of the system to update as necessary. I just discovered that this does NOT seem to be working. When I attempt to put this raw HTML into a textarea field on my page, I get unpredictable results. It's probably not being escaped properly when it's being put in the textarea - which means a in the content will close the textarea and start it's own tags etc. Try: $textarea_content = htmlspecialchars($content, ENT_QUOTES); -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP4 vs PHP5 classes
I have run through the script with a debugger, and sure enough, we only enter function Players once. Is this normal behaviour for PHP5 vs PHP4? Is there a way for me to force $this-max to be calculated each time function max is called? Since the Players method is a constructor, it's more about how you set the object(s) up. What does the loop look like before you create a new object? -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with using array_diff and array_combine
Richard Kurth wrote: I hope I can explain what I am trying to do. I have two tables the first one has the custom form elements elements_id elements_field_type elements_field_caption members_id 35 text test8 36 text test28 The second one has the customer id and the field value withe the field name dbelements_field_name dbelements_field_value members_id customer_id 35Test This Field 8 346 36 8 346 36Test2 8 347 If you look at the second table you will see that one field name is related to two different customers and one field name on relates to one customer. I am trying to look at these two tables and find customer that do not have a row for each field name. I have been trying with array_combine($dbelements_field_array,$dbelements_id_array) and also array_diff($customf_array,$dbelements_field_array) You can do it in sql. // find customer_id's who don't have all fields filled in $subquery = select customer_id from customformelements cfe left join dbelements de on (cfe.elements_id=de.dbelements_field_name and de.members_id=cfe.members_id) where cfe.members_id=8 and de.dbelements_field_name is null ; Then get your customers: select c.* from contacts where customer_id in ( $subquery ); Also for array_diff you have to check it both ways: $ cat diff.php ?php $array_one = array (1,2,3,4,5); $array_two = array (2,3,4); $diff_one = array_diff($array_one, $array_two); echo diff 1:\n; print_r($diff_one); $diff_two = array_diff($array_two, $array_one); echo diff 2:\n; print_r($diff_two); $ php diff.php diff 1: Array ( [0] = 1 [4] = 5 ) diff 2: Array ( ) -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP4 vs PHP5 classes
[EMAIL PROTECTED] wrote: Since the Players method is a constructor, it's more about how you set the object(s) up. What does the loop look like before you create a new object? Well see here is where it gets messy! This is not my code - I've ported a phpnuke module over to dragonflycms. The $players object is created before the loop: $players = new Players($lid); snip Which means the code is only executed once since it's in the constructor. It's not changing per loop because you're not calling the code. Maybe setting $this-max should be done in fetchSelectData since that's what is causing/creating your loop. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP4 vs PHP5 classes
[EMAIL PROTECTED] wrote: The $players object is created before the loop: $players = new Players($lid); snip Which means the code is only executed once since it's in the constructor. It's not changing per loop because you're not calling the code. Maybe setting $this-max should be done in fetchSelectData since that's what is causing/creating your loop. Thanks Chris, I will give that a shot. Just to confirm, this script works just fine in php4, so do we put that down to pure luck, or has there been a change in php5 that will be causing it? No idea why it works in php4 - if you're only calling the Players method once (or through the constructor) it should have behaved the same in php4. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP4 vs PHP5 classes
Don't forget that in PHP5, the constructor named has changed. In PHP4 it called a method with the same name as the class. But, in PHP5, it looks for __construct() instead. If __construct doesn't exist then it falls back to the php4 way - makes it backwards compatible :) -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] limiting the amount of emails sent at a time in a batch send
I've done something very similar. I have a delivery timestamp column in the table that is initially NULL, and I set it to UTC_TIMESTAMP() for each row as I send the message. My query looks like this then: SELECT * FROM mail_queue WHERE delivery_timestamp IS NULL LIMIT 100. Andrew Then what do you do to get the next 100 emails without sending the same ones Re-read the reply. After each email is sent, the timestamp is set. The original query looks for timestamp fields that are not set. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Why PHP4?
Per Jessen wrote: Lester Caine wrote: Some ISP's are still only supporting rather ancient versions of PHP4. They should simply be warned of the security risks. Some ISP's have a PHP5 offering, but again an older version simply because it causes less problems when converting from PHP4. The problem for an ISP is - with thousands of customers, he has no way of knowing who has used what PHP extension or feature. Without virtually guaranteed backwards compatibility, a mass upgrade of 4 to 5 could be a major headache. Besides, are the security risks sufficiently severe for the ISP to warrant the upgrade effort+headache? Definitely. I've been the server-admin behind this sort of stuff (actually php3 - php4 :P) and it's very hard to do even on your own servers. Clients get other developers to write their software so you have no idea what it does etc, you can't support it, you certainly don't want to break it - so as much as possible you leave the server alone (of course you upgrade for security issues, that's a given). In time you get a new server and slowly migrate people to that, kill off the old server and rinse-repeat. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] limiting the amount of emails sent at a time in a batch send
brian wrote: Richard Kurth wrote: I want to limit these script two send 100 email and then pause for a few seconds and then send another 100 emails and repeat this tell it has sent all the emails that are dated for today. This script is runs by cron so it is running in the background. How would I do this and is it the best way to do it. I am using swift mailer to send the mail. I think I would use limit 100 in the query but how would I tell it to get the next 100. There's no need to limit the DB query, nor to track what's been sent by updating the DB. Grab all of the addresses at once and let SwiftMailer deal with the throttling: Of course there is. 1) What if the server gets rebooted in the middle of the send or the database goes down in the middle? You send to everyone again. 2) What if the host has a limit on how long a script can run for? You send to everyone again and again and again each time the script tries to start. 3) What if safe-mode is enabled on the server? You have a limited send time and possibly end up with the same outcome as #2. 4) What if you are sending to 100,000 email addresses? You run out of memory because you have so much data loaded. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Kill Magic Quotes
public static function restoreSlashes($string) { // Check if Magic Quotes is turned on. if (get_magic_quotes_gpc()) { // Add escape slashes. return addslashes($string); } // Return a string that has escape slashes. return $string; } Wrong way around. If gpc is enabled, then there are already slashes - no need to add them again. If it's not, you need to addslashes. if (get_magic_quotes_gpc()) { return $string; } return addslashes($string); Though I'm curious why you need to re-add them at all. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Kill Magic Quotes
Roger Bigras wrote: you may try the ini_set('magic_quotes_gpc',0); RTM. http://www.php.net/get_magic_quotes_gpc It cannot be enabled/disabled at run time. It has to either be done in a .htaccess or through apache/php.ini changes. See this page for how to disable it: http://www.php.net/manual/en/security.magicquotes.disabling.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A dumb question regarding sending email
tedd wrote: Hi gang: I wish I had another identify for asking dumb questions, but it's late and I'm tried -- so here goes. I have a herdoc that I send out as an email -- no problems there. However, how do I include a link within it? If I use http://example.com, it's just a string but not an actual link. Your mail client determines that. You sent that email as text-only and thunderbird turned it into a link for me. If you're trying to send an a href.. link, you need to send it as a full html email (which means setting proper email headers etc).. for that I'd suggest using one of the libraries to do it all for you (phpmailer, swiftmail or whatever it is, zend_mailer)... -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parsing form with a website question...
bruce wrote: rob, i'm fully aware of the issues, and for the targeted sites that i'm focusing on, i can employ strategies to prune the tree... but the overall issue is that i'm looking for a tool/app/process that does what i've described. the basic logic is that the app needs to use a config file, and that the app should somehow find the requisite form using perhaps xpath, in combination with some kind of pattern recognition/regex functionality... once the app has the form, it can then get the underlying stuff (selects/lists/items, etc.. which will form the basis for the querystrings to the form action... Don't know of anything that does this off hand but it'd be a good project for a security check app :) See what values/options the form accepts and what it fails with.. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] On one of my computers, php can't see an external javascript I included
googling1000 wrote: Edit: I don't think Javascript is disabled on my computer. When I tried posting the code online, I see that my js functions are executed just fine on this one particular machine. Hit the file directly in your browser: http://example.com/path/to/javascript.js what do you get? -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie Q: How to say, if the fileNAME is equal to..., or better yet, if the fileNAME ends with '.jpg'?
But two of those entries are apparently named . and ... Right. That's linux doing that, not php. If you jump into a ssh connection and do an $ ls -la you will see . and .. at the top. if ($filename == '.' || $filename == '..') { continue; } I haven't yet found the 'string.ends_with' function in the docs, so I am just seeing if I can (to learn step by step) instead wrap that echo line with an if statement that says if the name of the file is equal to (.jpg), like so: $ThisDir = getcwd()./thumbs; $DirHandle = opendir($ThisDir); if ($DirHandle = opendir($ThisDir)) { echo Directory handle: $DirHandle\n; echo Files:br /hr width=\25\%\ align=\left\ /; while ((false !== ($file = readdir($DirHandle))) 1) { if (true == ($file=.jpg)) { echo $filebr /; } } closedir($DirHandle); } But instead of printing only the name of the file which is equal to .jpg, it seems to actually set the value of $file to .jpg on each iteration of the while loop, so what I get is a list of files all having the same name (.jpg) and their number is equal to the actual number of files in that dir (plus 2 - for the . and .. files). Because you have: $file = 'xxx.jpg'; That is an assignment. What you want is a comparison: $file == 'xxx.jpg'; Note the double ='s. http://www.php.net/manual/en/language.operators.php In this case, I'd use the pathinfo function to break up the file/path: http://www.php.net/manual/en/function.pathinfo.php -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php