[PHP-DB] PDO::ATTR_TIMEOUT with unixODBC not working the way I expect?
I'm connecting to a closed-source database called Vertica via unixODBC and PDO. Everything is working great but I am having trouble getting PDO::ATTR_TIMEOUT attribute working when I create a connection via: $this-conn = new PDO($dsn, $user, $password, array(PDO::ATTR_DEFAULT_FETCH_MODE = PDO::FETCH_ASSOC, PDO::ATTR_TIMEOUT = 2)); or $this-conn-setAttribute(PDO::ATTR_TIMEOUT, 2); I also found this bug from 2008 (https://bugs.php.net/bug.php?id=45287), which contains a patch for this issue. But browsing the php mirror on github, I don't see this patch applied: https://github.com/php/php-src/blob/master/ext/pdo_odbc/odbc_driver.c#L339-L352 Does anyone have any experience or advice with how I could implement a database connection timeout without this patch? Thanks! --Rob
Re: [PHP-DB] Slooooow query in MySQL.
select h.addr, h.city, h.county, h.state, h.zip, 'yes' as show_prop, h.askingprice, '' as year_built, h.rooms, h.baths, '' as apt, '' as lot, h.sqft, h.listdate, '' as date_sold, h.comments, h.mlsnum, r.agency, concat(r.fname, ' ', r.lname) as rname, r.phone as rphone, '' as remail, '' as status, '' as prop_type, ts.TSCNfile as picture, h.homeid as homeid, 'yes' as has_virt from ProductStatus ps, home h, realtor r, ProductBin pb left join TourScene ts on ts.TSCNtourId = pb.PBINid and ts.TSCN_MEDIAid = '3' where ps.PSTSstatus = 'posted' and pb.PBINid = PSTS_POid and h.id = pb.PBINid and h.listdate DATE_SUB(NOW(), INTERVAL 2 YEAR) and (h.homeid is not null and h.homeid '') and r.realtorid = pb.PBIN_HALOid limit {l1}, {l2} Here is the query. I didn't know that it needed to have an ORDER clause in it for the limit to work properly. I'll probably order by h.listdate -- Rob Stut [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Chris wrote: Stut wrote: Chris wrote: Rob Adams wrote: I have a query that I run using mysql that returns about 60,000 plus rows. It's been so large that I've just been testing it with a limit 0, 1 (ten thousand) on the query. That used to take about 10 minutes to run, including processing time in PHP which spits out xml from the query. I decided to chunk the query down into 1,000 row increments, and tried that. The script processed 10,000 rows in 23 seconds! I was amazed! But unfortunately it takes quite a bit longer than 6*23 to process the 60,000 rows that way (1,000 at a time). It takes almost 8 minutes. I can't figure out why it takes so long, or how to make it faster. The data for 60,000 rows is about 120mb, so I would prefer not to use a temporary table. Any other suggestions? This is probably more a db issue than a php issue, but I thought I'd try here first. Sounds like missing indexes or something. Use explain: http://dev.mysql.com/doc/refman/4.1/en/explain.html If that were the case I wouldn't expect limiting the number of rows returned to make a difference since the actual query is the same. Actually it can. I don't think mysql does this but postgresql does take the limit/offset clauses into account when generating a plan. http://www.postgresql.org/docs/current/static/sql-select.html#SQL-LIMIT Not really relevant to the problem though :P How many queries do you run with an order? But you're right, if there is no order by clause adding a limit probably will make a difference, but there must be an order by when you use limit to ensure the SQL engine doesn't give you the same rows in response to more than one of the queries. -Stut -- http://stut.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Slooooow query in MySQL.
I have a query that I run using mysql that returns about 60,000 plus rows. It's been so large that I've just been testing it with a limit 0, 1 (ten thousand) on the query. That used to take about 10 minutes to run, including processing time in PHP which spits out xml from the query. I decided to chunk the query down into 1,000 row increments, and tried that. The script processed 10,000 rows in 23 seconds! I was amazed! But unfortunately it takes quite a bit longer than 6*23 to process the 60,000 rows that way (1,000 at a time). It takes almost 8 minutes. I can't figure out why it takes so long, or how to make it faster. The data for 60,000 rows is about 120mb, so I would prefer not to use a temporary table. Any other suggestions? This is probably more a db issue than a php issue, but I thought I'd try here first. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] mysql ORDER BY problems
Ok, here's what i got in my mysql db. I got a table listed with numbers as follows 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17 18 19 20 21 22 25 These numbers I can display fine. I'm using .. $query=SELECT * FROM db ORDER BY numbers ASC; Right now it displays it as 1 10 11 12 . 2 22 23 25 3 4 5 6 7 Is there a way with my mysql query so that I can list the numbers in correct order? Any help is appricated. - Rob
[PHP-DB] MySQLi Prepared Statements
Hi I am current trying to migrate an existing system using MySQLi to use PDO and I have a quick question with regards to Prepared Statements. Essentially I'd like to replicate the Prepared Statement functionality of PDO using MySQLi so that I can gradually update all the required pages to use similar function calls, and then swap everything over in one go rather than spending ages on a big rewrite. Using PDO you can pass parameters as an array which are bound to the query. Something like: $stmt = $pdo-prepare(SELECT * FROM Blah WHERE foo = ?); $params = array(SomeValue); $stmt-execute($params) The PDO function execute takes 1 parameter which is an array. There are similar functions in MySQLi such as bind_param and bind_result of which one of the parameters is of type mixed var1 [, mixed ...]. Is it possible to construct an array of this type and pass it to these functions, and if so how? I know is's possible to call these functions with something like: $stmt = $db-prepare(SELECT * FROM Blah WHERE foo = ?); $paramTypes = s; $params = array(SomeValue); $stmt-bind_param($paramTypes, $params[0]); But it seems you cannot pass the array itself using the '' operator. Cheers Rob Hamilton -- ___ Play 100s of games for FREE! http://games.mail.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Finding a process in *nix
Heres what i'm trying to do. $proc=exec('ps aux | grep proc'); if ($proc != ) { echo True; } if ($proc == ) { echo False; } but some time's it show's the ps aux so I dont get a true reading. Anybody have a way that I might be able to extract this out of there to get a true reading to find out if the process is running?
Re: [PHP-DB] Text file (rw) question...
Nevermind. I figured it out. - Original Message - From: Rob W. [EMAIL PROTECTED] To: php-db@lists.php.net Sent: Tuesday, March 14, 2006 1:45 AM Subject: [PHP-DB] Text file (rw) question... I'm trying to figure out how to read specific data from a text file that is already written. Example MaxUser=3D32 PortBase=3D8000 I want to be able to have php read them specific pieces of info so I can put them in to forms and update them via php. Any help would be appreciated. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Text file (rw) question...
Ok, The fix is just doing something like this... list($variable, $data) = explode(=, $x); But now my problem is trying to figure out how to update that data with form post ect... So the main page would get MaxUser=32 It would read that info and put it in to a form field, which I have. Now I gotta get it to take and make it so that a new value can be put in that field and updated back in to the text file. I have searched all over google for about 4 hrs looking for something like this but no go, any help would be appricated. - Original Message - From: Dwight Altman [EMAIL PROTECTED] To: 'Rob W.' [EMAIL PROTECTED]; php-db@lists.php.net Sent: Tuesday, March 14, 2006 9:13 AM Subject: RE: [PHP-DB] Text file (rw) question... How about posting your solution as well? Maybe someone will find it useful. -Original Message- From: Rob W. [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 14, 2006 2:07 AM To: php-db@lists.php.net Subject: Re: [PHP-DB] Text file (rw) question... Nevermind. I figured it out. - Original Message - From: Rob W. [EMAIL PROTECTED] To: php-db@lists.php.net Sent: Tuesday, March 14, 2006 1:45 AM Subject: [PHP-DB] Text file (rw) question... I'm trying to figure out how to read specific data from a text file that is already written. Example MaxUser=3D32 PortBase=3D8000 I want to be able to have php read them specific pieces of info so I can put them in to forms and update them via php. Any help would be appreciated. -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Text file (rw) question...
That works, but it just throws it in to a big loop and fills up the file, any suggestions? - Original Message - From: Chris [EMAIL PROTECTED] To: Rob W. [EMAIL PROTECTED] Cc: php-db@lists.php.net Sent: Tuesday, March 14, 2006 5:54 PM Subject: Re: [PHP-DB] Text file (rw) question... Rob W. wrote: Ok, The fix is just doing something like this... list($variable, $data) = explode(=, $x); But now my problem is trying to figure out how to update that data with form post ect... So the main page would get MaxUser=32 It would read that info and put it in to a form field, which I have. Now I gotta get it to take and make it so that a new value can be put in that field and updated back in to the text file. I have searched all over google for about 4 hrs looking for something like this but no go, any help would be appricated. This is a simple example but it should work for you: $new_textcontent = ; foreach($_POST as $area = $value) { $new_textcontent .= $area . = . $value . \n; } $fp = fopen($filename, 'w'); fputs($fp, $new_textcontent); fclose($fp); - Original Message - From: Dwight Altman [EMAIL PROTECTED] To: 'Rob W.' [EMAIL PROTECTED]; php-db@lists.php.net Sent: Tuesday, March 14, 2006 9:13 AM Subject: RE: [PHP-DB] Text file (rw) question... How about posting your solution as well? Maybe someone will find it useful. -Original Message- From: Rob W. [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 14, 2006 2:07 AM To: php-db@lists.php.net Subject: Re: [PHP-DB] Text file (rw) question... Nevermind. I figured it out. - Original Message - From: Rob W. [EMAIL PROTECTED] To: php-db@lists.php.net Sent: Tuesday, March 14, 2006 1:45 AM Subject: [PHP-DB] Text file (rw) question... I'm trying to figure out how to read specific data from a text file that is already written. Example MaxUser=3D32 PortBase=3D8000 I want to be able to have php read them specific pieces of info so I can put them in to forms and update them via php. Any help would be appreciated. -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Text file (rw) question...
Yeah, It's exactally what I needed, but I just want it to replace that one value that is sent via $_POST. What i'm trying to do is just make a web intigration to edit shoutcast .conf files. I have everything else execpt for now like I was saying, that code worked, I just want it to halt after it updates that line of code. - Original Message - From: Chris [EMAIL PROTECTED] To: Rob W. [EMAIL PROTECTED] Cc: php-db@lists.php.net Sent: Tuesday, March 14, 2006 6:23 PM Subject: Re: [PHP-DB] Text file (rw) question... Rob W. wrote: That works, but it just throws it in to a big loop and fills up the file, any suggestions? What do you want it to do? We have absolutely no idea exactly what you're trying to achieve - that was just a guess because you're posting a form and want the new values written to a file. - Original Message - From: Chris [EMAIL PROTECTED] To: Rob W. [EMAIL PROTECTED] Cc: php-db@lists.php.net Sent: Tuesday, March 14, 2006 5:54 PM Subject: Re: [PHP-DB] Text file (rw) question... Rob W. wrote: Ok, The fix is just doing something like this... list($variable, $data) = explode(=, $x); But now my problem is trying to figure out how to update that data with form post ect... So the main page would get MaxUser=32 It would read that info and put it in to a form field, which I have. Now I gotta get it to take and make it so that a new value can be put in that field and updated back in to the text file. I have searched all over google for about 4 hrs looking for something like this but no go, any help would be appricated. This is a simple example but it should work for you: $new_textcontent = ; foreach($_POST as $area = $value) { $new_textcontent .= $area . = . $value . \n; } $fp = fopen($filename, 'w'); fputs($fp, $new_textcontent); fclose($fp); - Original Message - From: Dwight Altman [EMAIL PROTECTED] To: 'Rob W.' [EMAIL PROTECTED]; php-db@lists.php.net Sent: Tuesday, March 14, 2006 9:13 AM Subject: RE: [PHP-DB] Text file (rw) question... How about posting your solution as well? Maybe someone will find it useful. -Original Message- From: Rob W. [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 14, 2006 2:07 AM To: php-db@lists.php.net Subject: Re: [PHP-DB] Text file (rw) question... Nevermind. I figured it out. - Original Message - From: Rob W. [EMAIL PROTECTED] To: php-db@lists.php.net Sent: Tuesday, March 14, 2006 1:45 AM Subject: [PHP-DB] Text file (rw) question... I'm trying to figure out how to read specific data from a text file that is already written. Example MaxUser=3D32 PortBase=3D8000 I want to be able to have php read them specific pieces of info so I can put them in to forms and update them via php. Any help would be appreciated. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Text file (rw) question...
Yeah, but will that just replace the data that is present already there? I dont wanna have duplicate entries in there or i'm affraid it wont read it. The origional code you gave worked but it just ran in a big loop. - Original Message - From: Chris [EMAIL PROTECTED] To: Rob W. [EMAIL PROTECTED] Cc: php-db@lists.php.net Sent: Tuesday, March 14, 2006 6:42 PM Subject: Re: [PHP-DB] Text file (rw) question... Rob W. wrote: Yeah, It's exactally what I needed, but I just want it to replace that one value that is sent via $_POST. What i'm trying to do is just make a web intigration to edit shoutcast .conf files. I have everything else execpt for now like I was saying, that code worked, I just want it to halt after it updates that line of code. In the simplest form: $new_textcontent = 'post_field=' . $_POST['post_field'] . \n; $fp = fopen($filename, 'w'); fputs($fp, $new_textcontent); fclose($fp); I'd suggest cleaning up $_POST['post_field'] before just writing it (eg making sure it is only numbers, whatever data you actually want to keep in it). - Original Message - From: Chris [EMAIL PROTECTED] To: Rob W. [EMAIL PROTECTED] Cc: php-db@lists.php.net Sent: Tuesday, March 14, 2006 6:23 PM Subject: Re: [PHP-DB] Text file (rw) question... Rob W. wrote: That works, but it just throws it in to a big loop and fills up the file, any suggestions? What do you want it to do? We have absolutely no idea exactly what you're trying to achieve - that was just a guess because you're posting a form and want the new values written to a file. - Original Message - From: Chris [EMAIL PROTECTED] To: Rob W. [EMAIL PROTECTED] Cc: php-db@lists.php.net Sent: Tuesday, March 14, 2006 5:54 PM Subject: Re: [PHP-DB] Text file (rw) question... Rob W. wrote: Ok, The fix is just doing something like this... list($variable, $data) = explode(=, $x); But now my problem is trying to figure out how to update that data with form post ect... So the main page would get MaxUser=32 It would read that info and put it in to a form field, which I have. Now I gotta get it to take and make it so that a new value can be put in that field and updated back in to the text file. I have searched all over google for about 4 hrs looking for something like this but no go, any help would be appricated. This is a simple example but it should work for you: $new_textcontent = ; foreach($_POST as $area = $value) { $new_textcontent .= $area . = . $value . \n; } $fp = fopen($filename, 'w'); fputs($fp, $new_textcontent); fclose($fp); - Original Message - From: Dwight Altman [EMAIL PROTECTED] To: 'Rob W.' [EMAIL PROTECTED]; php-db@lists.php.net Sent: Tuesday, March 14, 2006 9:13 AM Subject: RE: [PHP-DB] Text file (rw) question... How about posting your solution as well? Maybe someone will find it useful. -Original Message- From: Rob W. [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 14, 2006 2:07 AM To: php-db@lists.php.net Subject: Re: [PHP-DB] Text file (rw) question... Nevermind. I figured it out. - Original Message - From: Rob W. [EMAIL PROTECTED] To: php-db@lists.php.net Sent: Tuesday, March 14, 2006 1:45 AM Subject: [PHP-DB] Text file (rw) question... I'm trying to figure out how to read specific data from a text file that is already written. Example MaxUser=3D32 PortBase=3D8000 I want to be able to have php read them specific pieces of info so I can put them in to forms and update them via php. Any help would be appreciated. -- Postgresql php tutorials http://www.designmagick.com/ -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Text file (rw) question...
So how do I make it so it just set's the variable's that are sent in the $_POST because i wanna write it so that if the value isnt changed, it wont send the $_POST and wont update the config file.. - Original Message - From: Chris [EMAIL PROTECTED] To: Rob W. [EMAIL PROTECTED] Cc: php-db@lists.php.net Sent: Tuesday, March 14, 2006 7:02 PM Subject: Re: [PHP-DB] Text file (rw) question... Rob W. wrote: Yeah, but will that just replace the data that is present already there? I dont wanna have duplicate entries in there or i'm affraid it wont read it. The origional code you gave worked but it just ran in a big loop. That particular example will replace the whole file. If you only want to replace a particular option then that's different - but we don't know what you are trying to do. - Original Message - From: Chris [EMAIL PROTECTED] To: Rob W. [EMAIL PROTECTED] Cc: php-db@lists.php.net Sent: Tuesday, March 14, 2006 6:42 PM Subject: Re: [PHP-DB] Text file (rw) question... Rob W. wrote: Yeah, It's exactally what I needed, but I just want it to replace that one value that is sent via $_POST. What i'm trying to do is just make a web intigration to edit shoutcast .conf files. I have everything else execpt for now like I was saying, that code worked, I just want it to halt after it updates that line of code. In the simplest form: $new_textcontent = 'post_field=' . $_POST['post_field'] . \n; $fp = fopen($filename, 'w'); fputs($fp, $new_textcontent); fclose($fp); I'd suggest cleaning up $_POST['post_field'] before just writing it (eg making sure it is only numbers, whatever data you actually want to keep in it). - Original Message - From: Chris [EMAIL PROTECTED] To: Rob W. [EMAIL PROTECTED] Cc: php-db@lists.php.net Sent: Tuesday, March 14, 2006 6:23 PM Subject: Re: [PHP-DB] Text file (rw) question... Rob W. wrote: That works, but it just throws it in to a big loop and fills up the file, any suggestions? What do you want it to do? We have absolutely no idea exactly what you're trying to achieve - that was just a guess because you're posting a form and want the new values written to a file. - Original Message - From: Chris [EMAIL PROTECTED] To: Rob W. [EMAIL PROTECTED] Cc: php-db@lists.php.net Sent: Tuesday, March 14, 2006 5:54 PM Subject: Re: [PHP-DB] Text file (rw) question... Rob W. wrote: Ok, The fix is just doing something like this... list($variable, $data) = explode(=, $x); But now my problem is trying to figure out how to update that data with form post ect... So the main page would get MaxUser=32 It would read that info and put it in to a form field, which I have. Now I gotta get it to take and make it so that a new value can be put in that field and updated back in to the text file. I have searched all over google for about 4 hrs looking for something like this but no go, any help would be appricated. This is a simple example but it should work for you: $new_textcontent = ; foreach($_POST as $area = $value) { $new_textcontent .= $area . = . $value . \n; } $fp = fopen($filename, 'w'); fputs($fp, $new_textcontent); fclose($fp); - Original Message - From: Dwight Altman [EMAIL PROTECTED] To: 'Rob W.' [EMAIL PROTECTED]; php-db@lists.php.net Sent: Tuesday, March 14, 2006 9:13 AM Subject: RE: [PHP-DB] Text file (rw) question... How about posting your solution as well? Maybe someone will find it useful. -Original Message- From: Rob W. [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 14, 2006 2:07 AM To: php-db@lists.php.net Subject: Re: [PHP-DB] Text file (rw) question... Nevermind. I figured it out. - Original Message - From: Rob W. [EMAIL PROTECTED] To: php-db@lists.php.net Sent: Tuesday, March 14, 2006 1:45 AM Subject: [PHP-DB] Text file (rw) question... I'm trying to figure out how to read specific data from a text file that is already written. Example MaxUser=3D32 PortBase=3D8000 I want to be able to have php read them specific pieces of info so I can put them in to forms and update them via php. Any help would be appreciated. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Text file (rw) question...
It's all fixed and works. If anybody is wondering how this turned out, here's the begining of the results. index.php ?php if (!($f=fopen(sc_serv.conf,r))) exit(Unable to open file.); while (!feof($f)) { $x=fgets($f, 100); list($variable, $data) = explode(=, $x); echo form method=\POST\ action=\update.php\; if ($variable == MaxUser) { echo Max Users: input type=\text\ value=\$data\ name=\MaxUser\ size=\3\br /; } if ($variable == Password) { echo Password: input type=\text\ value=\$data\ name=\Password\ size=\15\br /; } // echo $variable $databr /; } fclose($f); echo p /input type=\SUBMIT\ value=\Submit\ //form; ? update.php ? $newconfig = ; $maxuser=$_POST['maxuser']; $password=$_POST['password']; foreach($_POST as $area = $value) { $newconfig .= $area . = . $value . \n; } $fp = fopen('sc_serv.conf', 'w'); fputs($fp, $newconfig); fclose($fp); exit(); ? Thankyou to everyone who helped. Special thanks to Chris.
Re: [PHP-DB] Text file (rw) question...
Ah yes, that's true. I didnt realize that. Thanks for pointing that out. - Original Message - From: Chris [EMAIL PROTECTED] To: Rob W. [EMAIL PROTECTED] Cc: php-db@lists.php.net Sent: Tuesday, March 14, 2006 9:02 PM Subject: Re: [PHP-DB] Text file (rw) question... Rob W. wrote: It's all fixed and works. If anybody is wondering how this turned out, here's the begining of the results. index.php ?php if (!($f=fopen(sc_serv.conf,r))) exit(Unable to open file.); while (!feof($f)) { $x=fgets($f, 100); list($variable, $data) = explode(=, $x); echo form method=\POST\ action=\update.php\; if ($variable == MaxUser) { echo Max Users: input type=\text\ value=\$data\ name=\MaxUser\ size=\3\br /; } if ($variable == Password) { echo Password: input type=\text\ value=\$data\ name=\Password\ size=\15\br /; } // echo $variable $databr /; } fclose($f); echo p /input type=\SUBMIT\ value=\Submit\ //form; ? update.php ? $newconfig = ; $maxuser=$_POST['maxuser']; $password=$_POST['password']; You're not using these variables anywhere so it'd be best to remove them (might be confusing later on if you need to come back to it). or you can leave them there and do: $newconfig = ''; $newconfig .= MaxUser= . $maxuser . \n; $newconfig .= Password= . $password . \n; instead of the foreach($_POST... loop. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Text file (rw) question...
I'm trying to figure out how to read specific data from a text file that is already written. Example MaxUser=3D32 PortBase=3D8000 I want to be able to have php read them specific pieces of info so I can put them in to forms and update them via php. Any help would be appreciated.
[PHP-DB] Re: Amount of characters a variable is able to contain
I don't believe there is a way with file(), but there are alternatives. Firstly, does it need to be in an array? Does your script do anything else with $lineArray? If not, you'd be much better off just using file_get_contents() (http://php.net/file_get_contents) or, if you just want to output the file, readfile() (http://php.net/readfile), which dumps the file contents straight out to the visitor. If you do need to get it into an array, fgets() should work. Here's an example on the site (http://php.net/fgets), butchered to suit: $lineArray = array(); $handle = @fopen(/tmp/inputfile.txt, r); if ($handle) { while (!feof($handle)) { $lineArray[] = fgets($handle, 4096); } fclose($handle); } That will get up to 4096 characters per line, and I'm sure increasing this isn't too complex :) Rob Ron Piggott wrote: This is a sample of code which takes the $web_page and puts it into $message The problem I have is that I have lines in my $web_page files which are longer (have more characters) than $message is able to handle and chunks of web page text are simply truncated after the character limit has been reached. Is there a way to deal with this and allow $message (for example) to hold 500 or 1,000 characters --- twice of whatever the default setting is? Ron $lineArray = file($web_page); // make an empty variable first $message = ; // concat all array element foreach($lineArray as $eachLine) { $message .= $eachLine; } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] [PDO] Number of rows found by Select
So would it be possible to write a select() function to handle the wierdness? I'm attempting to write one but I'm getting buffered query errors. This function is part of a Database Manager class and is supposed to return a PDO::Statement with the number of rows being stored in a referenced paramater. Error: 'SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.' in E:\Server\swi\qpf\mng\data.class.php:64 Stack trace: #0 E:\Server\swi\qpf\mng\data.class.php(64): PDOStatement-execute() #1 E:\Server\swi\www\db.php(13): DM::select('* FROM cdrs WHE...', 20, -1) #2 {main} thrown in E:\Server\swi\qpf\mng\data.class.php on line 64 Function: public static function select($sql, $count = NULL, $limit = NULL) { $db = self::handle(); #Singleton method to create/retrieve db handle $buf = array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY = TRUE); $sql = 'SELECT '.(!is_null($count)?'SQL_CALC_FOUND_ROWS ':'').$sql; $stmt = $db-prepare($sql, $buf); $stmt-execute(); if (!is_null($count)) { $rows = $db-prepare('SELECT found_rows() AS rows', $buf); $rows-execute(); #ERROR HERE $rows_array = $rows-fetch(PDO::FETCH_NUM); $rows-closeCursor(); $count = $rows_array[0]; if (!is_null($limit) $count $limit) { $count = $limt; } } return $stmt; } Where am I going wrong here? Rob Micah Stevens wrote: There's a function called 'found_rows()' function, so you could try issuing a query, then issuing a second one 'SELECT FOUND_ROWS();' and it should give the number of rows returned by the previous select. Here's details: http://dev.mysql.com/doc/refman/4.1/en/information-functions.html On Tuesday 08 November 2005 9:13 am, Micah Stevens wrote: yeah, it would help if I read the whole post. Sorry. On Tuesday 08 November 2005 9:06 am, Dwight Altman wrote: I suppose you could use count( PDOStatement::fetchAll() ), but I understand your amazement. mysql_num_rows() is specific to MySQL. He wants a PDO version. -Original Message- From: Micah Stevens [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 08, 2005 10:51 AM To: php-db@lists.php.net Subject: Re: [PHP-DB] [PDO] Number of rows found by Select mysql_num_rows() On Tuesday 08 November 2005 5:17 am, Rob C wrote: What is the recommended way to find the number of rows found by a SELECT query? PDOStatement::rowCount() doesn't work with MySQL and is a bit of a hack anyway. Doing a COUNT(*) before the SELECT is very hackish - the data could have changed and it's an extra query. What is there that's better than either of these? Is there any way to use COUNT(*) without risking data change, such as inside a transaction? I'm amazed that there is no mysql_num_rows() equivilent, I get the feeling that I'm missing something obvious. I can only presume there is some technical limitation that I'm not appreciating, if anyone can shed some light on this, I'd like to know. I'm new to both PDO and this mailing list, so please be gentle with me. I'm using PDO 1.0RC2, PHP 5.0.5 and MySQL 4.1.15. Rob -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] [PDO] Number of rows found by Select
Cracked it! The buffer command (setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, TRUE)) needs to be sent to the PDO object, not PDO::Statement objects. The documentation is wrong here, in a number of ways. This is the function that (fingers crossed) runs a SELECT query and returns the statement, while setting the variable passed as the second parameter to the number of rows. If no second paramater is passed, of course nothing is set and function avoids unnecessary DB calls. found_rows() returns the total number of turns regardless of any LIMIT clause in the SQL so if you use LIMIT, pass the same number as the last parameter. Offset doesn't matter. Example Call (notice chopped SQL, no SELECT): $c = -1; $s = DM::select( '* FROM foo WHERE bar 40 LIMIT 4 OFFSET 2', $c, 4); var_dump($s-fetchAll()); # Normal dump of found data var_dump($c); # The number of rows found, at most 4. Function: public static function select($sql, $count = NULL, $limit = NULL) { $db = self::handle(); # Get PDO $sql = 'SELECT '.(!is_null($count)?'SQL_CALC_FOUND_ROWS ':'').$sql; try { $stmt = $db-prepare($sql); $stmt-execute(); if (!is_null($count)) { $rows = $db-prepare('SELECT found_rows() AS rows'); $rows-execute(); $rows_array = $rows-fetch(PDO::FETCH_NUM); $rows-closeCursor(); $count = $rows_array[0]; if (!is_null($limit) $count $limit) { $count = $limit; } } } catch (PDOException $e) { # todo } return $stmt; } Rob Rob C wrote: So would it be possible to write a select() function to handle the wierdness? I'm attempting to write one but I'm getting buffered query errors. This function is part of a Database Manager class and is supposed to return a PDO::Statement with the number of rows being stored in a referenced paramater. Error: 'SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.' in E:\Server\swi\qpf\mng\data.class.php:64 Stack trace: #0 E:\Server\swi\qpf\mng\data.class.php(64): PDOStatement-execute() #1 E:\Server\swi\www\db.php(13): DM::select('* FROM cdrs WHE...', 20, -1) #2 {main} thrown in E:\Server\swi\qpf\mng\data.class.php on line 64 Function: public static function select($sql, $count = NULL, $limit = NULL) { $db = self::handle(); #Singleton method to create/retrieve db handle $buf = array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY = TRUE); $sql = 'SELECT '.(!is_null($count)?'SQL_CALC_FOUND_ROWS ':'').$sql; $stmt = $db-prepare($sql, $buf); $stmt-execute(); if (!is_null($count)) { $rows = $db-prepare('SELECT found_rows() AS rows', $buf); $rows-execute(); #ERROR HERE $rows_array = $rows-fetch(PDO::FETCH_NUM); $rows-closeCursor(); $count = $rows_array[0]; if (!is_null($limit) $count $limit) { $count = $limt; } } return $stmt; } Where am I going wrong here? Rob Micah Stevens wrote: There's a function called 'found_rows()' function, so you could try issuing a query, then issuing a second one 'SELECT FOUND_ROWS();' and it should give the number of rows returned by the previous select. Here's details: http://dev.mysql.com/doc/refman/4.1/en/information-functions.html On Tuesday 08 November 2005 9:13 am, Micah Stevens wrote: yeah, it would help if I read the whole post. Sorry. On Tuesday 08 November 2005 9:06 am, Dwight Altman wrote: I suppose you could use count( PDOStatement::fetchAll() ), but I understand your amazement. mysql_num_rows() is specific to MySQL. He wants a PDO version. -Original Message- From: Micah Stevens [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 08, 2005 10:51 AM To: php-db@lists.php.net Subject: Re: [PHP-DB] [PDO] Number of rows found by Select mysql_num_rows() On Tuesday 08 November 2005 5:17 am, Rob C wrote: What is the recommended way to find the number of rows found by a SELECT query? PDOStatement::rowCount() doesn't work with MySQL and is a bit of a hack anyway. Doing a COUNT(*) before the SELECT is very hackish - the data could have changed and it's an extra query. What is there that's better than either of these? Is there any way to use COUNT(*) without risking data change, such as inside a transaction? I'm amazed that there is no mysql_num_rows() equivilent, I get the feeling that I'm missing something obvious. I can only presume there is some technical limitation that I'm not appreciating, if anyone can shed some light on this, I'd like to know. I'm new to both PDO and this mailing list, so please be gentle with me. I'm using PDO 1.0RC2, PHP 5.0.5 and MySQL 4.1.15. Rob -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe
[PHP-DB] [PDO] Number of rows found by Select
What is the recommended way to find the number of rows found by a SELECT query? PDOStatement::rowCount() doesn't work with MySQL and is a bit of a hack anyway. Doing a COUNT(*) before the SELECT is very hackish - the data could have changed and it's an extra query. What is there that's better than either of these? Is there any way to use COUNT(*) without risking data change, such as inside a transaction? I'm amazed that there is no mysql_num_rows() equivilent, I get the feeling that I'm missing something obvious. I can only presume there is some technical limitation that I'm not appreciating, if anyone can shed some light on this, I'd like to know. I'm new to both PDO and this mailing list, so please be gentle with me. I'm using PDO 1.0RC2, PHP 5.0.5 and MySQL 4.1.15. Rob -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Letters loop
hi Miguel I wanna a do a for loop with letters, Is this possible? for ($i = 'A'; $i = 'Z'; $i++){ // code } you can, but it doesn't do what you think it should do. Apparently it gets to Z, restarts with AA, AB, AC etc and continues like that until it hits YZ. feck knows why :-/ hth (a bit) Rob -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Connecting to MS Access DB in PHP, on Linux, Apache
Anyone got any good websites or resources on how to connect to an access database and perform sql querrys etc, in Linux running apache? or if anyone has the connection strings required thanks in advance !! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] quotes/private
hi Melanie From: mel list_php [mailto:[EMAIL PROTECTED] My question is : 1/ the normal syntax into the brackets: with , ' or nothing? I think it should be but I'm unsure. Single quotes, but check out http://au2.php.net/types.string for details why :) 2/it's working with other words wihtout the quotes (eg $ownerId=$row_resultTask[ownerID];) is it because private is a reserved word or something? yep. PHP interprets any word it doesn't recognise as a constant, which is why it worked before. if you do this ?php error_reporting(E_ALL | E_STRICT); echo something_not_defined; ? You'll get this: Notice: Use of undefined constant something_not_defined - assumed 'something_not_defined' but if you change something_not_defined to a reserved word like private, you'll get a parse error as you found. any idea where I could find a list? I don't know about a list as such, but http://www.php.net/manual/en/ will help. Rob -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] display connection type - newbie
Hello, I'm a newbie. I made a persistent connection, but I have to prove it's persistent for a class I'm in. So far I haven't found anything in the MySQL manual about it. Does anyone know what I can do? Thanks Rob -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Can't conect with mysql_connect(), please help.
How can I run php from the command line? Thanks, Rob Gillen Clipart Downloads http://www.GifArt.com - Original Message - From: Tyler Lane To: Gabriel Peugnet Cc: [EMAIL PROTECTED] Sent: Tuesday, October 14, 2003 5:31 PM Subject: Re: [PHP-DB] Can't conect with mysql_connect(), please help. On Tue, 2003-10-14 at 15:23, Gabriel Peugnet wrote: My site is hosted in a remote server. You should contact your remote hosting company and have them help you get mysql running. I can't find /etc/init.d/mysqld /etc does exists but /etc/init.d doesn't What I found is /usr/bin/msql2mysql /usr/bin/mysql_config /usr/bin/mysql /usr/bin/mysql_install_db /usr/bin/mysql_find_rows ... and a lot of files like /usr/bin/mysql The one that seems to be useful is /usr/lib/php4/mysql.so it's the socket, isn't? I guess that running /etc/init.d/mysqld start is kind of command line executing So, how can I start mysql from inside a php script? Thanks again. Gabriel. Joe Nilson Zegarra Galvez [EMAIL PROTECTED] escribi en el mensaje news:[EMAIL PROTECTED] You must start your mysql server : do it: /etc/init.d/mysqld start and when you read the line mysql start [OK] your problem will be fix ;) Regards Nilson Gabriel Peugnet dijo: phpinfo() says: MySQL Support enabled MYSQL_SOCKET /var/lib/mysql/mysql.sock but in fact the file /var/lib/mysql/mysql.sock doesn't exists. So I understand that the first step is to check the configuration of MySQL, is it? Dan Brunner [EMAIL PROTECTED] escribi en el mensaje news:[EMAIL PROTECTED] Hello!! Does that file /var/lib/mysql/mysql.sock exist?!!?!? Check to make sure mysql is running. Dan On Oct 14, 2003, at 4:34 PM, [EMAIL PROTECTED] wrote: I'm starting to use MySQL, well, trying to, and I get the next message: Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) The manual says that mysql_connect() can be called without arguments. That's what I'm doing. What's wrong? Thanks, Gabriel. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php - Joe Nilson Zegarra Galvez Sistemas Kola Real Telefax : 0051-54-256658 Movil: 0051-54-9603244 -- Tyler Lane [EMAIL PROTECTED] Lyrical Communications -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Hyperlinking to a new page
I believe what you want to do is just add the variable onto the URL, like this... script.php?variable or script.php?variablevariable Does that help? Thanks, Robert Gillen http://www.GifArt.com - Original Message - From: Shiloh Madsen To: [EMAIL PROTECTED] Sent: Thursday, October 09, 2003 3:41 PM Subject: [PHP-DB] Hyperlinking to a new page Ok, I know this should be easy, but im just blanking on how to do it. I have a webpage where you put in a city name, and it queries a database of all the cities in the US and brings back all cities matching that name. This part works just fine. What I want to do now is to create a hyperlink for each city name which, when clicked on will then call up a second page listing the details of that city. What I need to do is pass this page the city id (or any other identifying variable) to the detail page, but I cant for the life of me remember how to pass the data from one page to another outside of a form. Any help would be appreciated. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Hyperlinking to a new page
Sorry I made a little mistake in my reply. Here is the correct syntax for what I think will work for you... script.php?variable=1 or script.php?variable=1variable=2 Thanks, Robert Gillen http://www.GifArt.com - Original Message - From: Rob To: Shiloh Madsen ; [EMAIL PROTECTED] Sent: Thursday, October 09, 2003 3:51 PM Subject: Re: [PHP-DB] Hyperlinking to a new page I believe what you want to do is just add the variable onto the URL, like this... script.php?variable or script.php?variablevariable Does that help? Thanks, Robert Gillen http://www.GifArt.com - Original Message - From: Shiloh Madsen To: [EMAIL PROTECTED] Sent: Thursday, October 09, 2003 3:41 PM Subject: [PHP-DB] Hyperlinking to a new page Ok, I know this should be easy, but im just blanking on how to do it. I have a webpage where you put in a city name, and it queries a database of all the cities in the US and brings back all cities matching that name. This part works just fine. What I want to do now is to create a hyperlink for each city name which, when clicked on will then call up a second page listing the details of that city. What I need to do is pass this page the city id (or any other identifying variable) to the detail page, but I cant for the life of me remember how to pass the data from one page to another outside of a form. Any help would be appreciated. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] variable within regular expression
-Original Message- From: Robbie Staufer [mailto:[EMAIL PROTECTED] Sent: Friday, April 04, 2003 3:59 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] variable within regular expression I have a php query form in which the user input must be converted to a regular expression before querying the db. Something like this pseudo code: $var = $_GET['usr-input']; $var = '%$var%'; SELECT * FROM table WHERE field LIKE $var. I can't find the right syntax to make this work. Does anyone know? I think maybe the single quotes don't interpolate the value of the variable. In other words, let's say $var is 'fubar': $var = '%$var%'; // - is literally %$var% vs. $var = %$var%; // - is %fubar% Anyway, here's some of my code that is similar to (what I think) you're trying to do: if (isset($_GET['nstring'])) { $nstring = addslashes($_GET['nstring']); $squery = SELECT * FROM lead WHERE name LIKE '%{$nstring}%' ORDER BY source, ref_by, date DESC; $sresult = mysql_query($squery); } // etc... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] print table truncated
Dan, It is more of a HTML-related question: Need to change the table width in percentage (%) rather than just numbers. HTH, -rob Dan Liu [EMAIL PROTECTED] 03/31/2003 01:17 PM To: [EMAIL PROTECTED] cc: Subject:[PHP-DB] print table truncated Hi, I havea question about printing.When the table in HTML page is too big and I print the page,part of the table got truncated.Is there a way to print the web page without truncation? Thanks in advance. Dan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: check boxes and php
The trick here is to use the right HTML field name and PHP syntax to receive the information. For your checkboxes in HTML, name them like this: input type=checkbox name=del[] value=1Favorite 1/input input type=checkbox name=del[] value=2Favorite 2/input Then, in your PHP code, first check to see if there is more than one value: if (is_array($_POST[del])) { // works only if id is all integers. $in_list = implode(, , $_POST[del]); $query = delete from table where id in ($in_list); } else $query = delete from table where id = {$_POST['del']}; That should work, no javascript necessary. -- Rob John Dillon [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] m... I want to create a page where the user will have a list of its favorites and by ticking a box opposite the item will be able to delete it by clicking the submit button. I want to make this dynamic so that the php works out the one to delete based on the value of the tickbox (I'm thinking), having first - done a query to retrieve the favorites of the user - listed the favorites on the browser and set the tick boxes with a value corresponding to the ID of the favorite...thus knowing which one to delete. I was wondering what's the best approach - the one above or to mix in some javascript? Any examples out there? I know it's a popular idea. Maybe there's a better approach than tickboxes. John http://www.cantor.com CONFIDENTIAL: This e-mail, including its contents and attachments, if any, are confidential. If you are not the named recipient please notify the sender and immediately delete it. You may not disseminate, distribute, or forward this e-mail message or disclose its contents to anybody else. Copyright and any other intellectual property rights in its contents are the sole property of Cantor Fitzgerald. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. Although we routinely screen for viruses, addressees should check this e-mail and any attachments for viruses. We make no representation or warranty as to the absence of viruses in this e-mail or any attachments. Please note that to ensure regulatory compliance and for the protection of our customers and business, we may monitor and read e-mails sent to and from our server(s). For further important information, please read the Important Legal Information and Legal Statement at http://www.cantor.com/legal_information.html -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MySQL JOIN problem
I'm having trouble getting the results I want. The database deals with libraries and reports they've submitted. Here are the relevant tables with the primary keys marked with a star (*): +--+ | libinfo | +--+ | lib_id* | | lib_name | | city | +--+ +---+ | reportinfo| +---+ | report_id*| | lib_id| | exclude | | quarter | +---+ In reportinfo.quarter there are currently two possible values, 0 and 2. I want libinfo.lib_name and libinfo.city for all entries in libinfo, where libinfo.lib_id = reportinfo.lib_id, that do not have an entry in reportinfo where reportinfo.quarter = 0. I don't care if there is an entry in reportinfo where quarter = 2. Can someone please help me construct this query? Thanks. -Rob P.S. I realize that this question has nothing to do with PHP. But be assured that this is one small part of a PHP/MySQL web application. Thank you for your indulgence. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Query Help...
- Original Message - From: NIPP, SCOTT V (SBCSI) [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, March 10, 2003 9:23 AM Subject: [PHP-DB] Query Help... I am having a lot of trouble with a query that works fine from a basic SQL command line, but fails in my web script. Here is the portion of code including the query: mysql_select_db($database, $Prod); $query_groups = SELECT name FROM group; $groups = mysql_query($query_groups, $Prod) or die(mysql_error()); Here is the error I am receiving: You have an error in your SQL syntax near 'group' at line 1 Have you tried using backticks in your query? E.g., $query_groups = SELECT name FROM `group`; -- rob -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] heredoc and coding standards
I try to write very clean code. However, there is one thing that always bugs me - using heredoc syntax in a function. Code in the function really should be indented (or 4 spaces for PEAR types), but, to quote the documentation, the closing identifier must begin in the first column of the line. That means no tabs, right? So is that just the way it is? Do I just need to not worry about my tabs for heredoc? Is there some way to maintain consistency without breaking my code? -Rob -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] another parse error
I keep getting the following error: Parse error: parse error in /var/www/cgi-bin/ld/lslreporting_edit/libs_by_house.php on line 8 I've included all my code below and marked line 8 with * The curios thing is that I copied and pasted the first 8 lines of code from another script, and that other script works just fine. Both of these scripts are in the same directory and the lsladmin_connection.inc file is there. The #! path is correct. I just can't seem to see it. Sorry to burden the list with another parse error. Thanks. -Rob #!/usr/bin/php ?php require_once('lsladmin_connection.inc'); $ip = getenv('REMOTE_ADDR'); $pattern = ^10\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$; if ((eregi($pattern, $ip)) || ($ip == 127.0.0.1)) { * mysql_select_db($database_loanstar, $loanstar_connection); selectSQL = SELECT SUM(num_adult_books) + SUM(num_child_books) + SUM(num_largeprint_books) + SUM(num_spanish_books) + SUM(num_youngadult_books) + SUM(num_other_books) AS num_books, libinfo.house_district FROM materials, reportinfo, libinfo WHERE reportinfo.report_id=materials.report_id AND libinfo.lib_id=reportinfo.lib_id AND reportinfo.exclude='0' GROUP BY libinfo.house_district; $result = mysql_query($selectSQL, $loanstar_connection); } ? html body div align=center h1Number of books purchased with LoanStar Fundsbr / sorted by House District/h1 table width=90% tr tdHouse District/td tdBooks Purchased/td tr ? if (mysql_affected_rows 0) { while ($row = mysql_fetch_array($result) { echo tr\n\ttd . $row['house_district'] . /td\n; echo \ttd . $row['num_books'] . /td\n/tr; } } else { echo tr\n\ttd colspan=\2\query failed/td\n/tr; } ? /table /div body html -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySql Statement inside a function?
i'm certainly no expert, but here are my thoughts: the variable $tbn2 probabyl has no value inside of your function. so the query is really just select name from. i'd suggest you pass the $tbn2 value to the function. also, it is generally a bad idea to have a echo statements in function. rather you should return the results. hope that helps. -rob -Original Message- From: Dave Carrera [mailto:dave;davecarrera.com] Sent: Friday, October 18, 2002 10:52 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] MySql Statement inside a function? Hi All I have created a function and insde that function it dose a standard select, fetch_arry, while loop. I get a error from mysql saying not a vaild resource but if I take the statemnet out of the function all works fine and dandy. Are there things I should be aware of when trying to include mysql statements inside a function? I have include my code here if it helps. function getnames(){ $gnlistsql = select name from $tbn2; $gnlistres = mysql_query($gnlistsql); while($nlist = mysql_fetch_array($gnlistres)){ $nlistop = option value=\$nlist[name]\$nlist[name]/option; $nlistsel = select name=\getname\$nlistop/select; echo $nlistsel; } } There error is reported back in the while line... Any help or advice is appreciated as always. P.S reason for the fuction is that I will call the select a name list a few times so I thought of making it a function then calling it when needed. Thank You Dave C -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] advise needed for 'authorized only' site
I had a similar problem, but I can't promise that my solution is the best way to go about it. After the user was validated, I set a cookie. I then had all subsequent pages start with an if statement that checked for the cookie. If there was no cookie, they were sent back to the entry point. Another option if your application is somehow linear would be to make sure that the referring page is what you wanted it to be. -Rob -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Monday, September 23, 2002 10:14 AM To: PHP_DB Subject: [PHP-DB] advise needed for 'authorized only' site I have set up a section of my company site for use by authorized dealers only. I am currently using mysql authorization, which works for the first page, but if someone were to type in the url of an underlying page they would be able to get in without authorization. I know I could use .htaccess for handling this but with a minimum of 350 -400 users to keep track of that would be unwieldly to say the least, especially for my boss who doesn't have a clue about *nix and has never even heard of .htaccess. What other options do I have to keep the underlying pages from being accessed without the user being forced to go through the logon screen? Thanks, -- Chip Wiegand Computer Services Simrad, Inc www.simradusa.com [EMAIL PROTECTED] There is no reason anyone would want a computer in their home. --Ken Olson, president, chairman and founder of Digital Equipment Corporation, 1977 (They why do I have 9? Somebody help me!) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MySQL timestamp field update problem
Hi all, I have a table in MySQL with the following field: 'time_date' timestamp(14) NOT NULL When a record is inserted into the table, NULL is inserted into the time_date field giving me a normal timestamp with the time of the INSERT. That much is fine. However, it is necessary for me to update some of the records in my table. But whenever I send an UPDATE, the timestamp changes. I would like for the timestamp value to remain unchanged. Is there a way to do this without reading the old value of the timestamp and reinserting with my UPDATE query? Thanks. -Rob -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Checkbox/mySQL issues
Stephanie, Take a look at this: input type=checkbox name=option_val[] value=1Option 1 input type=checkbox name=option_val[] value=2Option 2 input type=checkbox name=option_val[] value=3Option 3 Look at the names of the checkboxes. If they are all the same and end with [] as above, PHP will toss them into an array. So in the script that processes the form you will have access to an array named $option_val. Hope that helps. -Rob -Original Message- From: Stephanie [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 15, 2002 2:18 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Checkbox/mySQL issues Here's my problem: I have a form in which there is a question and 5 checkboxes to select from (ex: you can select more than one checkbox) I need to get each checkbox that is selected to show up when it is inputed into the mySQL DB. I can get the first selected checkbox in, but nothing I've done seems to work. Any help would be much appreciated :-) Stephanie -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] variables gone?
Dear All, I am probably doing something silly but I don't know what (story of my life). I have just upgraded to 4.2.1 and now all the variables I post in forms or in query strings are now coming up undefined errors and are in absent. I'm running PHP under IIS 4. What am I doing wrong? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Recommendation needed: a php/mySQL program to batch e-mail announcements
why not just use a mailing list manager (i.e. majordomo, ezmlm, etc.)? writing a web interface for users to subscribe/unsubscribe would be no big deal. -Original Message- From: Al [mailto:[EMAIL PROTECTED]] Sent: Monday, April 29, 2002 11:37 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Recommendation needed: a php/mySQL program to batch e-mail announcements Need: Users can register to receive announcements automatically. And unregister. Admin can generate simple messages and send to all on the registry [e.g., meeting planned for 5 May 2002 at Joe's house] Thanks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] mssql problems
Dear All, I hope somebody can help me. I am new to PHP (I've used ASP for three years:-( ) and I'm loving PHP and trying to get my work to convert but I've coming across a error with mssql_query() explorer its just crashes with a php.exe 'memory could not be read error'. I'm sure it a school boy error from me but I'm just stuck, please help me code is.. === $link = mssql_connect (laptop, sa, elmwood); print (brLINK was $link); $back = mssql_select_db ( elmback,$link); print(brback was $back); $query = SELECT * FROM tblperson; print(brquery was $query); $result = mssql_query($query,$link); //JUST CRASHES ON THIS LINE $r = mssql_rows_affected ( $link); print(brrows affected was $r); $close = mssql_close ($link); print(brclose was $close); = I run IIS4, NT4 (SP6a) and SQL 7 on the same machine as its my development one, out of date maybe but you should see my clothes but PHP was test downloaded a month ago - any ideas from a white knight? best regards Rob -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] IP Address?
How can I find out the IP address of the client requesting a given php file? I know that you can use $HTTP_SERVER_VARS[REMOTE_ADDR] in more recent versions of PHP. Unfortunately, we only have PHP3.0.14 and I don't think that this option is available in our ancient version. I also can't use server side includes. An upgrade to PHP4 is in the works, but I can't wait that long. How can I get a client's IP address with PHP3.014 and/or JavaScript? Thanks in advance. -Rob -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] IP Address?
Thanks, Craig. That was exactly what I was looking for! -Rob -Original Message- From: Craig Vincent [mailto:[EMAIL PROTECTED]] Sent: Friday, April 19, 2002 2:35 PM To: Rob Day; [EMAIL PROTECTED] Subject: RE: [PHP-DB] IP Address? How can I find out the IP address of the client requesting a given php file? I know that you can use $HTTP_SERVER_VARS[REMOTE_ADDR] in more recent versions of PHP. Unfortunately, we only have PHP3.0.14 and I don't think that this option is available in our ancient version. I also can't use server side includes. An upgrade to PHP4 is in the works, but I can't wait that long. How can I get a client's IP address with PHP3.014 and/or JavaScript? Thanks in advance. I believe $ip = getenv('REMOTE_ADDR'); will do what you want. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: php-db Digest 18 Mar 2002 18:40:25 -0000 Issue 1105
At 06:40 PM 3/18/2002 +, you wrote: Subject: How to add 2 years to todays date ? Hi All I think the subject line says it all. How to add 2 years to today's date ? Any helps as always most appreciated. Dave Carrera Php Developer Subject: Re: [PHP-DB] How to add 2 years to todays date ? In php $your_timestamp += gmmktime(0,0,0,1,1,1972); MySQL has INTERVALling options. Regards, Andrey Subject: RE: [PHP-DB] increase date() Try this: $six_months_from_now = date(Y-m-d, mktime(0,0,0, date(m)+6, date(1), date(Y))); echo Six Months From Now: $six_months_from_nowP; In my coding, I've used: $date_var=date(Y-m-d,strtotime(+0 days)); In your case, you could do it like: $date_var=date(Y-m-d, strtotime(+2 years)) or $date_var=date(Y-m-d H:i, strtotime(+2 years)) if you wanted hours/minutes either example formats in a way that MySQL wants to see a date or datetime field (respectively) hope it helps, ~ Rob Small c0demonkey Fresno, CA -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Re: parse error
Sorry for not giving enough info. This is right in the middle of the script. I do have the opening and closing tags. It must ne something else. -Original Message- From: Matthew Crouch [mailto:[EMAIL PROTECTED]] Sent: Thursday, December 13, 2001 4:04 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Re: parse error you haven't shut your script with the ? before starting your HTML, near as I can figure it Rob Day wrote: I've written a small script that processes a form from a webpage and sends the submitted data as an HTML e-mail that has the form all filled out already. I've gotten smaller versions of this script to work without any problem just to test the idea.I can't figure out why I'm now getting the following error: Parse error: parse error in /home/httpd/cgi-bin/rday/lists/do_listapp.php3 on line 358 Here is the offending code: 353 if ($moderation == no){ 354 $message .= checked; 355 } 356 357$message .= ' 358nobr 359pAnswer yes if you want all postings to the list to be sent to 360 a moderator for approval before distribution to the list./p Any help would be greatly appreciated. Thanks! Rob Day Web Team Leader Texas State Library and Archives Commission phone: 512.936.4463 fax: 512.463.5436 [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Speeding up database access
I am just starting out on a project that has to be multi-lingual. i.e. every word/sentence I output has to be translated. The user logs in, and I read the language they use, by looking at the user record. I then need to get the language translations from a database. I just select label, text from language where lang = English; Fields: [label],[text],[language] Example: M1002,Please enter the delivery address,English At the moment I download them into a associative array, so I can access the text like this. txt['M1002'] where 'M1002' is a label. I have made txt a session variable. The trouble is, there are so many text translations (6000+), that it takes about 10 seconds to download them all into this array. I don't want to access the database every time I need to print out some text. Question:- How can I improve the startup time?? In case it was not obvious from the above, I am a newbie at PHP!! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Re: Speeding up database access
I forgot to say, I am using Oracle OCI to access the database: : $sSQL = select label, text from language_text where language = 'English'; $stmt = OCIParse($conn,$sSQL); OCIExecute($stmt); $nrows = OCIFetchStatement($stmt,$results); -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] pear db and pgsql
i'm having a hell of a time figuring out how to connect to a postgresql database using the pear db abstraction...here's some code snippets: with mysql (works fine): require_once('DB.php'); $db = DB::connect(mysql://username:password@localhost/audio); if (DB::isError($db)) { print $db-getMessage(); } $select_query = SELECT * FROM items; $result = $db-query($select_query); while ($row = $result-fetchRow()) { print $row[1]BR; } $db-disconnect(); with pgsql (dies with this error: DB Error: unknown error Fatal error: Call to undefined function: query() in /path/pg_test.php on line 8) require_once('DB.php'); $db = DB::connect(pgsql://username:password@localhost/audio); if (DB::isError($db)) { print $db-getMessage(); } $select_query = SELECT * FROM items; $result = $db-query($select_query); while ($row = $result-fetchRow()) { print $row[1]BR; } $db-disconnect(); both databases exist, along with the tables$10 says i'm being dumb, and need to put the port # someplace on the postgres connect, but i can't seem to put it in the right place. tia, r -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] PHP4 to PHP3 problem
I have a simple little corporate phonebook app that I developed in PHP4/mySQL, but our work department is only running PHP3 (and they want to leave it that way, for fear of breaking other PHP apps ... sigh). Anyway, the following code snippet produces this error message when I run it in PHP3: Parse error: parse error, expecting `STRING' or `NUM_STRING' or `'$'' in subs3.php3 on line 50 Here's what line 50 looks like, with a bit of surrounding syntax, and the dbquery routine, in case that's the problem. line 51 causes the same problems (both are shown on multiple-lines, but they're one line in the source file) ... various bits deleted ... function dbquery($sql) { $db = mysql_connect('localhost','foo','bar'); @mysql_select_db('phonelist') or die(); $result = @mysql_query($sql,$db); if (mysql_errno() == 0 !empty($result)) { return $result; } else { return "There was an error"; exit; } } function searchit($sql) { global $words,$howsort,$first,$last,$dep,$ext,$mgr; $result = dbquery($sql); $nrows = mysql_num_rows($result); if ($nrows 0) { ... various bits deleted ... for ($x=1;$x=$nrows;$x++) { $A = mysql_fetch_array($result); if ($A["ismgr"] == "Yes") { **50** print "tr bgcolor=#66td{$A["fname"]}/td" . "td{$A["lname"]}/td" . " td{$A["dept"]}/td" . " td{$A["manager"]}/td" . "td{$A["extension"]}/td/tr\n"; } else { print "tr bgcolor=#CCFFCCtd{$A["fname"]}/td" . "td{$A["lname"]}/td" . "td{$A["dept"]}/td" .= " td{$A["manager"]}/td" . "td{$A["extension"]}/td/tr\n"; } print "/div"; } ... various bits deleted ... } If anyone can help me "back convert" this routine into something PHP3 likes, I'd be greatly appreciative! It runs fine in PHP4, so I know the code works (even if it's not the most elegant of examples). I'm not a developer by trade, and I've never used PHP3, so I'm not sure what could be different that's making it go crash. I've checked the FAQ's and searched the annotated documentation, but I must be missing something basic. thanks; -rob. [EMAIL PROTECTED] -- -- Rob Griffiths | 00 Audi A4 2.8 | 00 Ford Explorer | 99 Mazda Miata | [EMAIL PROTECTED] | The Griffiths: A front-wheel-drive-free household! | -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Soap in php
Anyone here know of a good php soap tutorial? I have tried the one at gigatrends, but had no luck -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Robust OO Shopping Cart 4 sale
Hello all, PHP\MySQL shopping cart for sale www.firegarden.com/cart/ still under development (good price if you buy now). Top notch OO coding garenteed. go to firegarden.com and click the email link for more info. Rob -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Sessions and MySQL
I am trying to implement session support with mysql. I am using session.set_save_handler but don't really have a great set of functions does anyone have some good ones? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]