[PHP-DB] Using a PostgreSQL refcursor.
Good morning. Is there a way to use a returned refcursor from PostgreSQL using PDO? I have scoured the web and have yet to find a good result. Here's a few things I've tried. This example simply does not work. - $database = Database::load(); // Returns a singleton object with PDO connected to the database. $sql = select my_function();; $p = $database-query($sql); $p-execute(); $result = $p-fetchAll(); $p-closeCursor(); - This example is closer but PDO complains that the cursor is already open. - $database = Database::load(); // Returns a singleton object with PDO connected to the database. $sql = BEGIN; select my_function('my_refcursor'); FETCH ALL from 'my_refcursor';; $p = $database-query($sql); $p-execute(); $result = $p-fetchAll(); $p-closeCursor(); - Matthew Hartman Programmer/Analyst Information Management, ICP Kingston General Hospital (613) 549- x4294 .now. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] currval of an index in Postgres to pass on?
Check this link. http://ca3.php.net/function.pg-query The second example shows one way to perform a transaction, or the first commit shows another potential way (sending a BEGIN; as it's own query). An easier way than using CURRVAL is to use the RETURNING clause on your first INSERT, and then pass the value as a parameter. http://www.postgresql.org/docs/8.3/interactive/sql-insert.html By the way, for obvious reasons, you should be using parameterized queries to prevent SQL injection. Matthew Hartman Programmer/Analyst Information Management, ICP Kingston General Hospital (613) 549- x4294 -Original Message- From: Carol Walter [mailto:walt...@indiana.edu] Sent: Tuesday, June 09, 2009 4:35 PM To: php-db@lists.php.net Subject: [PHP-DB] currval of an index in Postgres to pass on? I have several modules in a PHP program that access a postgres database. The program needs to create a new Name record in a table is it has a new name or use a name chosen from the database if it doesn't have a new name. I want to load the chosen id in person_id if the name is already there, but it needs to have the current value of the name record index if it is not. I'm having trouble figuring our how to load currval(person_id_seq) into person_id. My code snippet appears below. I know that this code is wrong and I know that I need to process the resulting query as an array, but I can't figure out how. begin; $query = INSERT INTO \tblPeople\(\fName\,\mName\,\lName \, ivlweb, cnsweb) VALUES ('$f_name_new', '$m_name_new','$l_name_new', '$ivl_web_peop', '$cns_web_peop'); echo First Name query: . $query . br /; $pg_peop_ins = pg_query($query) or die(Can't execute first query); $query = INSERT INTO \tblContactInformation\(\contactItem \,\contactType\) VALUES ('$contact_info1','$contact_type'); echo Second Name query: . $query . br /; pg_contact_ins = pg_query($query) or die(Can't execute 2nd query); $query = INSERT INTO \brdgPeopleContactInformation \ (\peopleId\,\contactInformationId\,rank, type) VALUES (currval('\tblPeople_peopleId_seq \'),currval('\tblContactInformation_contactInformationId_seq\'), '$cont_rank', '$cont_loc'); echo Third Name query: . $query . br /; $pg_peop_cont_ins = pg_query($query) or die(Can't execute 3rd query); $query = SELECT currval('\tblPeople_peopleId_seq\'); $person_id = pg_query($query) or die(Can't execute 4th query); echo person id is . $person_id . br /; +++ (This gives me a Resource # - I know this is because I didn't process it as an array.) commit; The other thing that puzzles me is that I thought the statements between the begin and the commit should be treated as one transaction. In this case, some of the tables get written and not others between the begin and the commit. Thanks for your time. Carol -- 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] Multiple result sets using PDO and PostgreSQL.
Is it possible? I have created a function to return setof refcursor and it executes correctly, but PDO fails when I call nextRowset. If anyone has an answer and wants StackOveflow points, I posted this here (with more details too). http://stackoverflow.com/questions/951628/can-you-return-multiple-result -sets-using-pdo-and-postgresql Matthew Hartman Programmer/Analyst Information Management, ICP Kingston General Hospital (613) 549- x4294 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] PDO bindValue ORDER BY
ok... this makes more sense now. I know in the past I tried to do something similar with table names in the WHERE clause, and that didn't work in the same manner. Is there a better way to do what I'm trying to do? that is, sorting within the SQL statement based on a supplied column name without out writing multiple SQL statements? for now my work around is to some thing like: $sort = mysql_real_escape_string($sort); $sql = SELECT * FROM `table` ORDER BY `$sort`; which makes me queasy because I spent a lot of time getting away from inlining variables in SQL statements. On Fri, Oct 31, 2008 at 6:46 PM, Post TUDBC [EMAIL PROTECTED] wrote: Technically, bound parameter is expecting a value, such as WHERE ID=:id However, ORDER BY is followed by a field name, such as ORRDER BY ID So I don't think it should work. If it does work, then it is a sign that the database driver is not really preparing the statement (as it should for performance reason), but it is just substituiting values to compose a SQL (just for your convenience). On 10/31/08, Matthew Peltzer [EMAIL PROTECTED] wrote: Are pdo bound parameters within an ORDER BY clause broken in php 5.2.5? I find that in php 5.2.6 this works as expected: ?php $sql = 'SELECT * FROM `table` ORDER BY :sort'; $stmt = $pdo-prepare($sql); $stmt-bindValue(':sort', $sort, PDO::PARAM_STR); $stmt-execute(); print_r($stmt-fetchAll(PDO::FETCH_ASSOC)); ? but under php5.2.5 the ORDER BY clause silently fails. Also, parameters bound to SELECT or WHERE or LIMIT clauses function correctly, but ORDE BY still has no effect. If I remove the $stmt-bindValue(':sort', $sort, PDO::PARAM_STR); line or the ORDER BY :sort I get a number of bound variables does not match number of tokens error. So it appears the parsing mechanism is funcitoning, but what ever is responsible for binding to ORDER BY is not. I've looked in bug reports and the change logs, but did not find a explicit reference to this issue. -- -- Matthew Peltzer -- [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- -- Matthew Peltzer -- [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] PDO bindValue ORDER BY
Are pdo bound parameters within an ORDER BY clause broken in php 5.2.5? I find that in php 5.2.6 this works as expected: ?php $sql = 'SELECT * FROM `table` ORDER BY :sort'; $stmt = $pdo-prepare($sql); $stmt-bindValue(':sort', $sort, PDO::PARAM_STR); $stmt-execute(); print_r($stmt-fetchAll(PDO::FETCH_ASSOC)); ? but under php5.2.5 the ORDER BY clause silently fails. Also, parameters bound to SELECT or WHERE or LIMIT clauses function correctly, but ORDE BY still has no effect. If I remove the $stmt-bindValue(':sort', $sort, PDO::PARAM_STR); line or the ORDER BY :sort I get a number of bound variables does not match number of tokens error. So it appears the parsing mechanism is funcitoning, but what ever is responsible for binding to ORDER BY is not. I've looked in bug reports and the change logs, but did not find a explicit reference to this issue. -- -- Matthew Peltzer -- [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] echo delay...
Hi fellow php late night peoples Thanks for everyone's help the last couple of days... I have learned so much. The best way to learn this stuff...is simple trial and error... and thanks for good old Ggle! My problem tonight is very simple. I just don't know what command I want to use. I want to echo text in a page then take a delay then echo more text/images to the same page. I tried the sleep command with the number of seconds, but it don't load the page to the sleep timer is done. any ideas of what php command I can use? Matt
[PHP-DB] IF statement in WHILE statement
Hello Everyone, Got another simple problem here I am trying to do a if statement inside a while (mysql_fetch_array) Here is my code: if ($link = mysql_tech_array($links)) { do { if ($_GET['page'] = $link[file]) { $status = 'reg_button.php'; } else { $status = 'push_button.php'; } echo a href='index.php?page=$link[file]'img src='$status?text=$link[name]\n'/a\n; } while ($link = mysql_fetch_array($links)); } else { echo Link Error; } This code loads links across a page. The active page needs to get the PUSH_BUTTON.php file The loop needs to set the status then do the echo line...then start again for each rows in the array. thanks Matt
Re: [PHP-DB] IF statement in WHILE statement
Thanks Chris... added the extra = and its working fine... Have a nice day everyone Matt - Original Message - From: Chris [EMAIL PROTECTED] To: Matthew Ferry [EMAIL PROTECTED] Cc: php-db@lists.php.net Sent: Tuesday, February 13, 2007 11:53 PM Subject: Re: [PHP-DB] IF statement in WHILE statement Matthew Ferry wrote: Hello Everyone, Got another simple problem here I am trying to do a if statement inside a while (mysql_fetch_array) Here is my code: if ($link = mysql_tech_array($links)) { do { if ($_GET['page'] = $link[file]) { You're assigning $_GET['page'] to whatever is in $link['file']. It should be '==' not '=' to do a comparison. -- 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] SQL Query - Using variable from another SQL Query
Hello Everyone Got a simple / stupid question. Worked on this all night. I'm over looking something very basic here. The query event_time brings back the calendar id for each event that is pending in the future. ie 12, 13, 14, 26 (There could be 100 of them out there) The second query events needs to meet both reqirements. 1 - cal_category='501' 2 - cal_id= a number from the event_time query I think i need to do a loop inside of a loop Thanks... Matt Here is my code: ?php $todays_year = date(Y); $todays_month = date(m); $todays_day = date(d); $tstamp = mktime(0, 0, 0, $todays_month, $todays_day, $todays_year); $event_time = mysql_query(SELECT cal_id FROM egw_cal_dates where cal_start $tstamp, $db); $events = mysql_query(SELECT * FROM egw_cal WHERE cal_category='501' and cal_id='$event_time'\n, $db); if ($event = mysql_fetch_array($events)) { echo center\n; echo HR\n; do { echo BFont Size='10'$event[cal_title]nbsp;nbsp;nbsp;nbsp;-nbsp;nbsp;nbsp;$event[cal_location]/B/Font\n; echo BR\n; echo $event[cal_description]; echo BR\n; echo HR\n; } while ($event = mysql_fetch_array($events)); } else { echo No Public Events Are Currently Scheduled...; } ?
Re: [PHP-DB] SQL Query - Using variable from another SQL Query
Thanks Everyone... After I sent that...I got thinking about doing both queries in one statement. So thats what I did. Its working fine... Here is the updated code: ?php $todays_year = date(Y); $todays_month = date(m); $todays_day = date(d); $tstamp = mktime(0, 0, 0, $todays_month, $todays_day, $todays_year); $events = mysql_query(SELECT DISTINCT * FROM egw_cal, egw_cal_dates WHERE egw_cal.cal_category='501' and egw_cal_dates.cal_start '$tstamp' and egw_cal.cal_id=egw_cal_dates.cal_id, $db); if ($event = mysql_fetch_array($events)) { echo center\n; echo HR\n; do { echo BFont Face='Times'$event[cal_title]nbsp;nbsp;nbsp;nbsp;-nbsp;nbsp;nbsp;$event[cal_location]/Font/B\n; echo BR\n; $start = date('F jS\, Y \a\t g:ia', $event[cal_start]); echo Starting Date/Time:nbsp;nbsp; $start; echo BR\n; echo BR\n; echo $event[cal_description]; echo BR\n; echo HR\n; } while ($event = mysql_fetch_array($events)); } else { echo No Public Events Are Currently Scheduled...; } ? - Original Message - From: Matthew Ferry [EMAIL PROTECTED] To: php-db@lists.php.net Sent: Monday, February 12, 2007 11:14 AM Subject: [PHP-DB] SQL Query - Using variable from another SQL Query Hello Everyone Got a simple / stupid question. Worked on this all night. I'm over looking something very basic here. The query event_time brings back the calendar id for each event that is pending in the future. ie 12, 13, 14, 26 (There could be 100 of them out there) The second query events needs to meet both reqirements. 1 - cal_category='501' 2 - cal_id= a number from the event_time query I think i need to do a loop inside of a loop Thanks... Matt Here is my code: ?php $todays_year = date(Y); $todays_month = date(m); $todays_day = date(d); $tstamp = mktime(0, 0, 0, $todays_month, $todays_day, $todays_year); $event_time = mysql_query(SELECT cal_id FROM egw_cal_dates where cal_start $tstamp, $db); $events = mysql_query(SELECT * FROM egw_cal WHERE cal_category='501' and cal_id='$event_time'\n, $db); if ($event = mysql_fetch_array($events)) { echo center\n; echo HR\n; do { echo BFont Size='10'$event[cal_title]nbsp;nbsp;nbsp;nbsp;-nbsp;nbsp;nbsp;$event[cal_location]/B/Font\n; echo BR\n; echo $event[cal_description]; echo BR\n; echo HR\n; } while ($event = mysql_fetch_array($events)); } else { echo No Public Events Are Currently Scheduled...; } ?
[PHP-DB] 2 queries -- 1 array
Hello, I need to query two different tables and create one BIG array. I can query both tables, but can't find a way to combine the results in one array. The problem comes in with the second table. It has a weird layout. The second table only has four fields. They are: contact_id, contact_owner, contact_name, and contact_value a.. The 'contact_id' needs to be linked to 'id' field from the first table. b.. The contact_name is a field I need to use to reference what i'm looking for. example... contact_name HAS values of RANO, PrevSys, Supplier, Dynamic each of them has the same contact_id different contact_names with different contact_values To query the second table I do something like this: SELECT contact_value FROM egw_addressbook_extra WHERE contact_name='Supplier' and contact_id=' XXX' The xxx is the ID from the first table. - Table 1: IDNAMEBUSINESS ADDRESSCITY PHONE 1 John SmithSmith's Phone Co. 100 Main St Someplace 555- 2 Joe Brown Brown's Shoe Store105 Grant St.This City 555-0001 Table 2: CONTACT_IDCONTACT_NAME CONTACT_VALUECONTACT_OWNER 1 PrevSys NONE 4 1 RANO 100102 4 1 Supplier TrueValue 4 1 Dynamic 192.168.0.0 4 2 PrevSys OLD POS SYS 4 2 RANO 100105 4 2 Supplier Orgill 4 2 Dynamic 192.168.100.0 4 I want to query both tables and create a array. The extra fields from table two need to have their own field in the array. I need to call those extra fields in the array by the contact_name field... example $myrow[supplier] $myrow[PrepSys] $myrow[name] I have tried alot of stuff to get this done, but i think i was very off task. Some help/guide is needed I'm new Thanks... Matt
Re: [PHP-DB] 2 queries -- 1 array
I tried a buch of JOINs, but with no luck The problem comes in with I have to do a different query for each contact_name values for every record. SELECT contact_value FROM egw_addressbook_extra WHERE contact_name='Supplier' and contact_id=' 1' SELECT contact_value FROM egw_addressbook_extra WHERE contact_name='RANO' and contact_id=' 1' SELECT contact_value FROM egw_addressbook_extra WHERE contact_name='PrevSystem' and contact_id=' 1' SELECT contact_value FROM egw_addressbook_extra WHERE contact_name='Dynamic' and contact_id=' 1' Then add those values to the array created from query of the first table Thanks... Matt - Original Message - From: Natalie Leotta To: Matthew Ferry Sent: Friday, January 12, 2007 3:41 PM Subject: Re: [PHP-DB] 2 queries -- 1 array I think this will help, but I'm not sure I understood your question correctly. http://www.w3schools.com/sql/sql_join.asp On 1/12/07, Matthew Ferry [EMAIL PROTECTED] wrote: Hello, I need to query two different tables and create one BIG array. I can query both tables, but can't find a way to combine the results in one array. The problem comes in with the second table. It has a weird layout. The second table only has four fields. They are: contact_id, contact_owner, contact_name, and contact_value a.. The 'contact_id' needs to be linked to 'id' field from the first table. b.. The contact_name is a field I need to use to reference what i'm looking for. example... contact_name HAS values of RANO, PrevSys, Supplier, Dynamic each of them has the same contact_id different contact_names with different contact_values To query the second table I do something like this: SELECT contact_value FROM egw_addressbook_extra WHERE contact_name='Supplier' and contact_id=' XXX' The xxx is the ID from the first table. - Table 1: IDNAMEBUSINESS ADDRESSCITY PHONE 1 John SmithSmith's Phone Co. 100 Main St Someplace 555- 2 Joe Brown Brown's Shoe Store105 Grant St.This City 555-0001 Table 2: CONTACT_IDCONTACT_NAME CONTACT_VALUECONTACT_OWNER 1 PrevSys NONE 4 1 RANO 100102 4 1 Supplier TrueValue 4 1 Dynamic 192.168.0.0 4 2 PrevSys OLD POS SYS 4 2 RANO 100105 4 2 Supplier Orgill 4 2 Dynamic 192.168.100.0 4 I want to query both tables and create a array. The extra fields from table two need to have their own field in the array. I need to call those extra fields in the array by the contact_name field... example $myrow[supplier] $myrow[PrepSys] $myrow[name] I have tried alot of stuff to get this done, but i think i was very off task. Some help/guide is needed I'm new Thanks... Matt
Re: [PHP-DB] 2 queries -- 1 array
yeah..that is what i'm trying to do, but I need to query WHERE contact_name='Supplier' and bring back the value for contact_value query WHERE contact_name='RANO' and bring back the value for contact_value query WHERE contact_name='Dynamic' and bring back the value for contact_value query WHERE contact_name='PrevSys' and bring back the value for contact_value Which are all different rows in the second table with the same ID field thats how they are linked to the first table thanks... Matt - Original Message - From: [EMAIL PROTECTED] To: php-db@lists.php.net Cc: [EMAIL PROTECTED] Sent: Friday, January 12, 2007 4:26 PM Subject: Re: [PHP-DB] 2 queries -- 1 array Not sure if this is exactly what you're looking for, Matt, but I think it is. ?php $query = SELECT t1.NAME, t1.BUSINESS, t1.ADDRESS, t1.CITY, t1.PHONE, t2.CONTACT_NAME, t2.CONTACT_VALUE FROM Table1 as t1, Table2 as t2 WHERE t1.ID = t2.CONTACT_ID $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { // to make it easier to read, I'll assign the values to variables for this demonstration $name = $row['NAME']; $business = $row['BUSINESS']; $address = $row['ADDRESS']; $city = $row['CITY']; $phone = $row['PHONE']; $contactname = $row['CONTACT_NAME']; $contactvalue = $row['CONTACT_VALUE']; $bigarray[$name][$contactname] = $contactvalue; } $JoeBrownPrevsys = $bigarray['Joe Brown']['Prevsys']; ? If that's not right, please re-describe the problem and let's see what we can figure out. If you have questions about what/how/why/etc... feel free to ask. -TG = = = Original message = = = Hello, I need to query two different tables and create one BIG array. I can query both tables, but can't find a way to combine the results in one array. The problem comes in with the second table. It has a weird layout. The second table only has four fields. They are: contact_id, contact_owner, contact_name, and contact_value a.. The 'contact_id' needs to be linked to 'id' field from the first table. b.. The contact_name is a field I need to use to reference what i'm looking for. example... contact_name HAS values of RANO, PrevSys, Supplier, Dynamic each of them has the same contact_id different contact_names with different contact_values To query the second table I do something like this: SELECT contact_value FROM egw_addressbook_extra WHERE contact_name='Supplier' and contact_id=' XXX' The xxx is the ID from the first table. - Table 1: IDNAMEBUSINESS ADDRESSCITY PHONE 1 John SmithSmith's Phone Co. 100 Main St Someplace 555- 2 Joe Brown Brown's Shoe Store105 Grant St.This City 555-0001 Table 2: CONTACT_IDCONTACT_NAME CONTACT_VALUECONTACT_OWNER 1 PrevSys NONE4 1 RANO 100102 4 1 Supplier TrueValue 4 1 Dynamic 192.168.0.0 4 2 PrevSys OLD POS SYS 4 2 RANO 100105 4 2 Supplier Orgill4 2 Dynamic 192.168.100.0 4 I want to query both tables and create a array. The extra fields from table two need to have their own field in the array. I need to call those extra fields in the array by the contact_name field... example $myrow[supplier] $myrow[PrepSys] $myrow[name] I have tried alot of stuff to get this done, but i think i was very off task. Some help/guide is needed I'm new Thanks... Matt ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] 2 queries -- 1 array
query1 = SELECT * FROM egw_addressbook query2 = SELECT contact_id, contact_value FROM egw_addressbook_extra WHERE contact_name='Supplier' query3 = SELECT contact_id, contact_value FROM egw_addressbook_extra WHERE contact_name='RANO' query4 = SELECT contact_id, contact_value FROM egw_addressbook_extra WHERE contact_name='PrevSys' query5 = SELECT contact_id, contact_value FROM egw_addressbook_extra WHERE contact_name='Dynamic' Then some type of array merge array1 = query1 + query2 + query3 + query4 + query5 query2 to query5 needs locked to query1 with: WHERE egw_addressbook.id=egw_addressbook_extra.contact_id Thanks... Matt - Original Message - From: [EMAIL PROTECTED] To: php-db@lists.php.net Cc: [EMAIL PROTECTED] Sent: Friday, January 12, 2007 4:26 PM Subject: Re: [PHP-DB] 2 queries -- 1 array Not sure if this is exactly what you're looking for, Matt, but I think it is. ?php $query = SELECT t1.NAME, t1.BUSINESS, t1.ADDRESS, t1.CITY, t1.PHONE, t2.CONTACT_NAME, t2.CONTACT_VALUE FROM Table1 as t1, Table2 as t2 WHERE t1.ID = t2.CONTACT_ID $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { // to make it easier to read, I'll assign the values to variables for this demonstration $name = $row['NAME']; $business = $row['BUSINESS']; $address = $row['ADDRESS']; $city = $row['CITY']; $phone = $row['PHONE']; $contactname = $row['CONTACT_NAME']; $contactvalue = $row['CONTACT_VALUE']; $bigarray[$name][$contactname] = $contactvalue; } $JoeBrownPrevsys = $bigarray['Joe Brown']['Prevsys']; ? If that's not right, please re-describe the problem and let's see what we can figure out. If you have questions about what/how/why/etc... feel free to ask. -TG = = = Original message = = = Hello, I need to query two different tables and create one BIG array. I can query both tables, but can't find a way to combine the results in one array. The problem comes in with the second table. It has a weird layout. The second table only has four fields. They are: contact_id, contact_owner, contact_name, and contact_value a.. The 'contact_id' needs to be linked to 'id' field from the first table. b.. The contact_name is a field I need to use to reference what i'm looking for. example... contact_name HAS values of RANO, PrevSys, Supplier, Dynamic each of them has the same contact_id different contact_names with different contact_values To query the second table I do something like this: SELECT contact_value FROM egw_addressbook_extra WHERE contact_name='Supplier' and contact_id=' XXX' The xxx is the ID from the first table. - Table 1: IDNAMEBUSINESS ADDRESSCITY PHONE 1 John SmithSmith's Phone Co. 100 Main St Someplace 555- 2 Joe Brown Brown's Shoe Store105 Grant St.This City 555-0001 Table 2: CONTACT_IDCONTACT_NAME CONTACT_VALUECONTACT_OWNER 1 PrevSys NONE4 1 RANO 100102 4 1 Supplier TrueValue 4 1 Dynamic 192.168.0.0 4 2 PrevSys OLD POS SYS 4 2 RANO 100105 4 2 Supplier Orgill4 2 Dynamic 192.168.100.0 4 I want to query both tables and create a array. The extra fields from table two need to have their own field in the array. I need to call those extra fields in the array by the contact_name field... example $myrow[supplier] $myrow[PrepSys] $myrow[name] I have tried alot of stuff to get this done, but i think i was very off task. Some help/guide is needed I'm new Thanks... Matt ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --
[PHP-DB] Filter array results... no copies
Hello everyone I'm back working on the website again... I'm having lots of fun. I have a sql query that looks at one field in a database. (result2 query) Then i have mysql_fetch_array statement. I then use this array to print links on the page. Works fine except I don't want duplicate links. It creates links for the states. If we have four customers from Pennsylvania. This current process gives me four different PA links on my page. I need a statement that says...if its already printed...don't print it... Thanks... Here is my code: html body ?php $db = mysql_connect(HOST, USERNAME, PASSWORD); mysql_select_db(DATABASE,$db); if ($_GET[area]==) { $master = mysql_query(SELECT * FROM egw_addressbook WHERE cat_id='8' ORDER BY org_name, $db); } else { $master = mysql_query(SELECT * FROM egw_addressbook WHERE cat_id='8' and adr_one_region='$_GET[area]' ORDER BY org_name, $db); } $result2 = mysql_query(SELECT adr_one_region FROM egw_addressbook WHERE cat_id='8' ORDER BY adr_one_region, $db); if ($area = mysql_fetch_array($result2)) { echo Sort by State: ; do { echo a href='index.php?area=$area[adr_one_region]'$area[adr_one_region]/a\n; echo - ; } while ($area = mysql_fetch_array($result2)); echo a href='index.php?area='ALL/a\n; } else { echo ERROR; } if ($myrow = mysql_fetch_array($master)) { echo CENTER\n; echo table border=0\n; echo img src=file.jpg width='611' height='136'\n; echo BR\n; echo BR\n; do { printf(tr td/tdtdb%s/b/tdtd/tdtd/tdtd%s/td/tr\n, $myrow[org_name], $myrow[fn]); printf(tr td/tdtd%s/tdtd/tdtd/tdtd%s/td/tr\n, $myrow[adr_one_street], $myrow[tel_work]); printf(tr td/tdtd%s, %s %s/tdtd/tdtd/tdtd/tdtd/td/tr\n, $myrow[adr_one_locality], $myrow[adr_one_region], $myrow[adr_one_postalcode]); } while ($myrow = mysql_fetch_array($master)); echo /table\n; echo /CENTER\n; } else { echo Sorry, no records were found!; } ? /body /html
Re: [PHP-DB] Current web page being displayed
* RaJeSh VeNkAtA [EMAIL PROTECTED] : hai .. if u r seeing http://www.google.com/blog/myblog.php then $_SERVER[SERVER_NAME] would give u www.google.com and $_SERVER[PHP_SELF] would give u /blog/myblog.php PHP_SELF also gives the PATH_INFO and QUERY_STRING of the script, which can make it problematic to determine the exact script name: http://www.example.com/path/to/script.php/extra/path/info?id=7 would give /path/to/script.php/extra/path/info?id=7 for PHP_SELF, when in liklihood you're looking for /path/to/script.php If using Apache, use SCRIPT_NAME as the $_SERVER key -- this gives just the path to the script - no PATH INFO, no QUERY_STRING. There are some regexps/functions floating around out there to remove PATH_INFO and QUERY_STRING from PHP_SELF as well, and this may be more portable than SCRIPT_NAME as not all httpd servers use it. On Sat, 6 Aug 2005, Ron Piggott wrote: What is the correct $_SERVER that tells me what page is currently being displayed? Ron -- Matthew Weier O'Phinney Zend Certified Engineer http://weierophinney.net/matthew/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Php with MySQL replication
* David Brinks [EMAIL PROTECTED]: I seem to be having a problem when using php with a replicated database and the replicated database not being updated correctly. I have verified that replication in general works. When transactions are entered through either a perl script or through console, the replicated client receives the updates almost instantly. When a transaction goes through php, on the other hand, the master database will be updated but the master does not seem to send the update to the replicated client. Mysql version are both 4.0.18. Mod_php4-4.3.7 is the php code. Sample from php script... $conn = mysql_connect($Server, $User, $Pass); $sql = INSERT INTO test.database VALUE ('','hello'); $result = mysql_query($sql,$conn); $closed = Mysql_close($conn); If anyone has any suggestions, I would appreciate it. PHP is writing to the database just as any other mysql client, so there should be no difference. The only thing I can think of that would cause the behaviour you're seeing is if PHP were writing to a different server, or if the slave server had stopped or did not have permissions to read from the master server. Are you absolutely certain that PHP is connecting to the master db server when performing the write operation? -- Matthew Weier O'Phinney Zend Certified Engineer http://weierophinney.net/matthew/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: a basic question
* babu [EMAIL PROTECTED]: i am asking a basic question which i could not understand. What is the important of @ symbol in php. i mean i have seen some people using @ symbol befor functions etc. can some one send me a link to documents. for example. @( ($conn or ($conn = ocilogon($account, $passwd, $db))) and ($stmt = ociparse($conn, $sqlstmt)) Just FYI: this question would ahve been better asked on the php-general list, as it is not specific to databases. However, judging by your example, you've probably seen it primarily in relation to database function calls. The @ operator is used to suppress errors. Many PHP functions will generate notices or warnings in addition to returning false, and these errors, if they're being displayed, could mess with headers and/or program output. Typically, it's better to try and handle the error, or to determine in development how to ensure it doesn't occur. However, if the error isn't critical, and your script can continue to function even if it occurs, suppressing the error often is a viable option. -- Matthew Weier O'Phinney Zend Certified Engineer http://weierophinney.net/matthew/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: ini_set()
* [EMAIL PROTECTED] [EMAIL PROTECTED]: In order to create a session handling function that does not rely at all on cookies, I'm trying to use ini_set('session.use_cookies', '0') to make sure that the PHP server does not set cookies on page load. However, even though the ini_set goes through (as evidenced by the 0 in the ini_get()) the page sets a cookie every time with the name PHPSESSID. No matter what I do, that cookie still gets set, and I can't seem to get it to stop. Even on the simplest pages, it still sets. The following code still sets a cookie: ?php ini_set('session.use_cookies', '0'); $x=ini_get('session.use_cookies'); echo($x); ? Even though the $x returns the correct value, ('0'), the cookie still gets set. I'm using PHP 4.3.10 on OS 10.3 Mac, but the same thing happens on my ISP who serves the same version of PHP on a Linux box. Any ideas? Is session.auto_start on (i.e., non-zero)? If so, that's occurring *before* your script is compiled, and will be using the value for session.use_cookies that is in the php.ini file. One possible way to get around this is to do your ini_set in a .htaccess file instead (assuming htaccess files are enabled, and you're using Apache): .htaccess: php_value session.use_cookies 0 Try that and see if it works. -- Matthew Weier O'Phinney | WEBSITES: Webmaster and IT Specialist | http://www.garden.org National Gardening Association| http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org mailto:[EMAIL PROTECTED] | http://vermontbotanical.org -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: sql injection attack, protection from
* Mayo [EMAIL PROTECTED]: I'm new to PHP and would like to make certain that I have the basic protection for the site: Use double quotes to contain variable This depends entirely on the variable type expected by MySQL; int and floats don't necessarily need quotes. However, it's typically a good practice. Use mysql_escape_string so that query is considered part of the WHERE clause. If you're on PHP =4.3.0, use mysql_real_escape_string(). $result=mysql_query('SELECT * FROM users WHERE username='.mysql_escape_string($_GET['username']).''); I'm pulling prices from a database and sending the item ID which has 4 characters (1001, 1002, etc.) Is the following unnecessary with mysql_escape_string? if (preg_match(/^\w{4,4}$/, $_GET['username'], $matches)) $result = mysql_query(SELECT * FROM items WHERE itemID=$matches[0]); else // we don't bother querying the database echo itemID not accepted; It's *always* better to filter your data before placing it in your database. Check to see if the data is of the correct type and/or falls within the correct range of values allowed for the field it will occupy. Doing this will help keep your data normalized and prevent headaches later on. By the way, if you want some best practices for escaping data before placing into a database, the manual page for mysql_real_escape_string has some examples: http://php.net/mysql_real_escape_string -- Matthew Weier O'Phinney | WEBSITES: Webmaster and IT Specialist | http://www.garden.org National Gardening Association| http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org mailto:[EMAIL PROTECTED] | http://vermontbotanical.org -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Transfering post data to a series of pages.
After looking at what I wanted to do I see no good reason I can't do most of what we needed with function calls. The others can be handled with plugging more data into my session array. Somehow I thought this was a poor way of coding (I don't know why). Thank you everyone for your advice! - Matthew -Original Message- From: Brad Webb [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 04, 2005 12:21 PM To: php-db@lists.php.net Subject: Re: [PHP-DB] Transfering post data to a series of pages. You may also consider using sessions to store form data.. this allows for actual user interaction with the data, back/forward etc... as well as tracking and other stuff.. you really should only have Page1.php, and use a logic object to parse the data from there.. IMHO, of course. :) [EMAIL PROTECTED] wrote: Perry, Matthew (Fire Marshal's Office) wrote: Is there a way to transfer post data to a series of PHP pages? For example, lets say I have the following 4 pages: Page1.php - this page has my original post form Page2.php - this page does one thing with the post data Page3.php - this page does another thing with the post data Page4.php - this page shows the results of everything I have done Right now I am using the header: ?header(Location: page3.php);? The problem is, the following works: Page1.php - this page has my original post form Page2.php - this page does one thing with the post data Page3.php - this page shows the results of everything I have done But when I try to add the second transfer the data is lost: Page1.php - this page has my original post form Page2.php - this page does one thing with the post data Page3.php - this page does another thing with the post data Page4.php - Only the results from Page2.php are shown ASP does this with %Server.Transfer (transferpage1.asp)% Is there a counterpart with PHP? - Matthew Martin Norland wrote: include() :P seriously though, Page1.php and Page4.php are the only two pages that should exist, if any. Page2 and Page3 should pretty much guaranteed be turned into function calls or classes and called from Page4.php. You don't need to separate logic and display in separate scripts that you push everything at, just separate your logic out into function calls. What Martin suggests makes a lot of sense. Can you say something about why you have the site design the way that you do? David -- 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] Transfering post data to a series of pages
Is there a way to transfer post data to a series of PHP pages? For example, lets say I have the following 4 pages: Page1.php - this page has my original post form Page2.php - this page does one thing with the post data Page3.php - this page does another thing with the post data Page4.php - this page shows the results of everything I have done Right now I am using the header: ?header(Location: page3.php);? The problem is, the following works: Page1.php - this page has my original post form Page2.php - this page does one thing with the post data Page3.php - this page shows the results of everything I have done But when I try to add the second transfer the data is lost: Page1.php - this page has my original post form Page2.php - this page does one thing with the post data Page3.php - this page does another thing with the post data Page4.php - Only the results from Page2.php are shown ASP does this with %Server.Transfer (transferpage1.asp)% Is there a counterpart with PHP? - Matthew -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: phpdocumentor
* Han [EMAIL PROTECTED]: I'm having to use phpdocumentor and am worried it's gonna conflict with my mysql commands and confuse the thing, so I'll have to check and recheck every line after I've done my initial check and rechecks of my code. Has anyone found it causes conflict or is there really no problem? There's no problem. PhpDoc goes into comments; there's no interaction with code whatsoever. -- Matthew Weier O'Phinney | WEBSITES: Webmaster and IT Specialist | http://www.garden.org National Gardening Association| http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org mailto:[EMAIL PROTECTED] | http://vermontbotanical.org -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: FW: [PHP-DB] mime-type related to extension?. .
* Martin Norland [EMAIL PROTECTED]: meal list_php wrote: Hi I sent this on 21st of april and got no answer... there is no way to check the real mime type of a file? even a file without extension? thanks, You can call out to an external program called file (which is pretty much guaranteed to be there, on a Linux system) which uses some magic to determine the file type. It should be able to tell you if the file is jpeg regardless, without any messy work from you. It will return a string like so: $ file false.doc false.doc: JPEG image data, JFIF standard 1.02 I'd run a few tests with some images from different sources, but it should be returning a very standard string - JPEG image data should at least be common. IIRC Sony also has a 'motion jpeg' which might cause you problems, depending on what you're doing - if you can get a hold of one of those to test (if it's a concern) you might want to. An additional tool that may be used when simply checking for image types is to use getimagesize() -- though you should be using php = 4.3.11 to do this safely (see http://security.gentoo.org/glsa/glsa-200504-15.xml for more information). One element returned by getimagesize() is the image MIME type. -- Matthew Weier O'Phinney | WEBSITES: Webmaster and IT Specialist | http://www.garden.org National Gardening Association| http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org mailto:[EMAIL PROTECTED] | http://vermontbotanical.org -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: 'OR' logic in mySQL query
* Ron Piggott [EMAIL PROTECTED]: Am I able to use the OR logic in mySQL queries? $query = SELECT * FROM table WHERE date_received LIKE '$todays_date' OR '$yesterdays_date' ORDER BY prayer_request_reference ASC; In this above example will the OR '$yesterdays_date' work? In reality I am wanting to preview new entries to the database within the past 2 days First off, did you try it? You could have tried it and had a more specific question in the time it took you to ask the above question. Second: In SQL, as in PHP, an OR requires that you have the values you're testing against on either side. To be specific, '$yesterdays_date' is a true value, and it's not what you're testing; you're wanting to see if date_received is like that value -- inother words, date_received LIKE '$yesterdays_date' is what you're actually trying to test. That said, you'll get much better results with: SELECT * FROM table WHERE date_received LIKE '$todays_date' OR date_received LIKE '$yesterdays_date' ORDER BY prayer_request_reference ASC -- Matthew Weier O'Phinney | WEBSITES: Webmaster and IT Specialist | http://www.garden.org National Gardening Association| http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org mailto:[EMAIL PROTECTED] | http://vermontbotanical.org -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Exporting pictures to Excel
I am having some difficulties exporting images to excel. I am using the following header: ?PHP header (Content-type: application/vnd.ms-excel); header (Content-Disposition: attachment ); ? Then I just create a table with my data. This works beautifully and generates the file correctly with one exception. When I include the following HTML in one of the columns: trtdimg src=images/specificitems/whatever.jpg width = 73 height = 73/td/tr It only saves the PATH to the image and not the image itself. When I am inside the correct directory the image displays. As soon as I move it outside this directory it does not display. This makes sense because that is how HTML works. But what I want to do is have PHP export the image to excel and insert this image into the file I am attempting to generate. Is there a means to insert the actual image into the generated file instead of the path? Thank you for your time, Matthew Perry
RE: [PHP-DB] grabbing data from other peoples sites
I guess my real question is how to parse the output from someone else's site. Setting up the lookup procedure from data in my database and filling their form with the address is the easy part. How do I make their form submit, parse the output, store it, and then reuse it in another function? I have never tried something like this before. - Matthew -Original Message- From: Martin Norland [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 16, 2005 10:09 AM To: php-db@lists.php.net Subject: Re: [PHP-DB] grabbing data from other peoples sites Perry, Matthew (Fire Marshal's Office) wrote: [snip] What this has to do with PHP Is there a way to write some sort of PHP script that accesses to the county auditors website, automatically enters the info into their form, grabs whatever information is outputted, imports the data into our SQL Server, and repeats the process for all addresses in our database? I will of course research the legality of this before we implement the script. I just wanted to know if this was even feasible before we meet about this. I don't even know where we should start. Sure, you're just issuing POST requests with data from your database, and parsing the output - and entering that extracted data back into your database again. A better question, however, would be how are you planning to handle this once you are ready to run it - are you just storing the address at each corner of your 'covered regions'? You'll need some kind of fuzzy lookup to be able to do all this. Maybe a better solution would be to just link directly to the county auditors website with instructions, allowing the users to do their queries as they're needed? Even if you have every current covered address on file, people may mistype things - new buildings are created - roads are renamed, etc. Someone should contact maps.google.com and see about adding this sort of information to that :) Cheers, -- - Martin Norland, Sys Admin / Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -- 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] grabbing data from other peoples sites
I have searched the archives as it this question has almost assuredly been asked countless times. Unfortunately I have no idea what sort of keyword or parameter is applicable for this topic. History Here is a brief history of the problem we are trying to solve. Feel free to skip this section if you only want to see what this has to do with PHP. We need to correlate residents of our county to their local fire departments. We receive about 10 calls a day asking this very question and someone in our office has to literally pick up a map and see find where the little lines for the fire department end. The process takes about 10 minutes where it should only take seconds. We want citizens of Harris County to enter this information into our web forms instead of calling us. Our county tax auditors have already done this through a project that costed millions of taxpayers dollars. The information is protected and available under the Open Records Act of 2000. Unfortunately the Open Records Act does NOT require any government agency to provide their information in electronic form or some sort of database dump. We have requested ALL data about EVERYTHING they have concerning ANY fire department at ANY location (which is our right and privilege). The handed us a huge stack of paper (not something we can import) with a big invoice (both of which we happily declined). The county auditor's website uses ASP and MS SQL Server to allow people to enter their address and find out this information. Unfortunately the information only makes sense to people who understand the coding scheme! What this has to do with PHP Is there a way to write some sort of PHP script that accesses to the county auditors website, automatically enters the info into their form, grabs whatever information is outputted, imports the data into our SQL Server, and repeats the process for all addresses in our database? I will of course research the legality of this before we implement the script. I just wanted to know if this was even feasible before we meet about this. I don't even know where we should start. - Matthew
[PHP-DB] GD with IIS and MS SQL Server
I work with a county office in Houston, Texas and have been forced to use Windows IIS (on Windows 2000 Server) with MS SQL Server. They have permitted me to use PHP (instead of ASP) when I showed them problems on every county ASP site. Most applications on IIS are running well including database connections and all my PHP functions but I am having problems getting GD applets to work. The GD application that I am most interested in outputs a bar code image. On the Windows Server this image does not appear and there are no error messages outputted even when the display error messages option is enabled (at least this is what our IT department claims!) This application works perfectly on my local Apache Server (which runs on my Windows XP machine). Has anyone attempted to get PHP / MS SQL Server / Windows IIS to work? If so, have you had similar difficulties when you tried to enable GD? - Matthew
Re: [PHP-DB] Join on single table
* Micah Stevens [EMAIL PROTECTED]: What kind of speed do you need? I was aiming at something that would run in 2 hours or so. Currently, it takes around 3 - 4. I had to go to temp tables for a logging application, but not until my table got upwards of a million records or so.. For the numbers your quoting, it should be pretty quick unless your engine needs optimization.. Well, actually... The index currently has around a million records, with approximately 350 words per resource id, several thousand resource ids per app_id you get the idea. I've optimized my indices, and I've got appropriate indices for the selection criteria I'm using. As I've noted, I also realize that this is a one shot deal -- after the initial link table is created, I won't be needing to recreate it every time I have data that changes -- I'll only be operating on deltas from here out, and those can be done quite quickly. Anyways, it's a moot question now -- I've got the data in, and I'm pretty happy with the results I've seen. On Friday 11 February 2005 11:56 am, Matthew Weier O'Phinney wrote: * Micah Stevens [EMAIL PROTECTED]: Sounds like a self join should work wonders. I didn't test this, but the idea should work: select t1.app_id as a1, t2.app_id as a2, t2.word, t2.score from tablename as t1 left join tablename as t2 on t1.resource_id = t2.resource_id and t1.app_id != t2.app_id group by word order by word voila, no temp tables. Am I missing something? Speed. :-) I had tried this as well. The temporary tables really do offer much better performance. The issues I was having were (1) bad resultsets (I've now got that fixed) and (2) speed. I still don't have (2) completely fixed, and it may be something I can't fix. On Thursday 10 February 2005 07:56 pm, Matthew Weier O'Phinney wrote: I have a table which contains the following: id (primary key, auto incrementing) app_id (integer, foreign key) resource_id (integer, foreign key) word score (This is a search index.) I want to find all resource_ids from one app_id that match resource_ids in another app_id by word. I have created a temporary table 'tmp1' that contains all resource_ids from the second app_id (the one whose resources I wish to retrieve). I am then looping through all resource_ids in the main table with the first app_id, and doing the following: * Creating a temporary table tmp2 with a single column 'word' populated by the words associated with resource_id in the main table * Selecting all distinct resource_ids from tmp1 INNER JOIN'd on tmp2 on the word field The issues I'm running into are that (1) each resource_id cycle takes a good amount of time, and (2) I seem to be getting either too many resource_ids or not enough. (1) may be something I just have to deal with. As it is, I'm planning on running the full indexing once, and then doing incremental updates, so it may not be that big of an issue (unless it takes too much time to create the initial index). As for (2), unfortunately, I'm not sur ehow to really trouble shoot the issue. I know, for instance, that in once case, I have a list of 343 words that generates a list of ~12,000 resource_ids (of a possible 18,000) -- but I don't quite know how to spot check 300 values to be certain that this is reasonable. In a previous incarnation of the script, I was looping through each word of each resource_id and then selecting out of tmp1 based on the single word value. The results were very different (very few matches), and, again, the script ran long. Any ideas? -- Matthew Weier O'Phinney | WEBSITES: Webmaster and IT Specialist | http://www.garden.org National Gardening Association| http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org mailto:[EMAIL PROTECTED] | http://vermontbotanical.org -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Excel headers not working anymore
Good morning, I have been using PHP4.1, Apache, and MySQL for a few years now and have never had a problem with my Excel headers. When I want to output html to Excel I place the following on the top of the page: ?header (Content-type: application/vnd.ms-excel); header (Content-Disposition: attachment ); After moving to PHP 4.3, MS SQL Server, Windows 2000 Server I am having problems with this header. I get the message: Internet Explorer cannot download myfile.php from myintranet.net The message does not always appear. Some of the files download, others do not. I have tried to find the problem with the following methods. They may shed some light on this problem: 1) I removed the header to see how the file outputs in HTML. They output fine. 2) I used my local server (which runs Apache and PHP4.3) with the same files and it downloads to excel perfectly! 3) I have compared the files that work with the ones that don't, removed anything that seems unusual, and replaced sections from the files that worked. There still does not seem to be any pattern. I thought the size of the file generated would play a roll but it doesn't. After shrinking the output to a single character, some files still do not work! Unfortunately it is more difficult to find support for PHP and Windows 2000 Server. I have some doubts that the files are not downloading because of default server security reasons (since some of the files work!). Does anyone know what might be causing this problem? - Matthew Perry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Join on single table
* Martin Norland [EMAIL PROTECTED]: Matthew Weier O'Phinney wrote: I have a table which contains the following: id (primary key, auto incrementing) app_id (integer, foreign key) resource_id (integer, foreign key) word score (This is a search index.) I want to find all resource_ids from one app_id that match resource_ids in another app_id by word. Is this at or near what you're looking for? I don't see any need for killing yourself making the temporary tables/etc. - but maybe I'm missing something. (obviously replace both 'tablename's with your tables name) SELECT b.app_id, b.resource_id, b.word, b.score FROM tablename AS a, tablename AS b WHERE a.app_id != b.app_id AND a.word = b.word; I'd tried a similar query already. The issue with this particular approach is that the query takes forever to execute, even with good indexing. The temporary table approach speeds things up tremendously -- but it's still slower than I'd like. I finally hit on a solution last night, and did finally end up with a good index -- took several hours to run, but from now on I only have to do deltas. Basically, I do the following: * foreach resource_id in a single app_id, put a list of words into a temporary table * select resource_ids from another app_id by joining on the temporary table -- Matthew Weier O'Phinney | WEBSITES: Webmaster and IT Specialist | http://www.garden.org National Gardening Association| http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org mailto:[EMAIL PROTECTED] | http://vermontbotanical.org -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Excel headers not working anymore
Wow! Removing the file that controlled the session array fixed the problem (suggestion 2). I was using ssl and session data and would never have guessed it would trip things up. I would have stared at this problem for weeks and probably not have solved the problem. Also I will change my code to include ?php instead of ? from now on just to be sure. Thank you very much for your help. - Matthew Perry -Original Message- From: Martin Norland [mailto:[EMAIL PROTECTED] Sent: Friday, February 11, 2005 10:47 AM To: php-db@lists.php.net Subject: Re: [PHP-DB] Excel headers not working anymore Perry, Matthew (Fire Marshal's Office) wrote: Good morning, I have been using PHP4.1, Apache, and MySQL for a few years now and have never had a problem with my Excel headers. When I want to output html to Excel I place the following on the top of the page: ?header (Content-type: application/vnd.ms-excel); header (Content-Disposition: attachment ); After moving to PHP 4.3, MS SQL Server, Windows 2000 Server I am having problems with this header. I get the message: Internet Explorer cannot download myfile.php from myintranet.net 1) is your server still configured to recognize ? as php (and only php)? You may want to make that ?php to be more sure. The headers likely aren't being sent if it's prompting to download .php - seems like it's not recognizing the extension, perhaps it's disabled for a certain pattern. You could also try changing it to: header(Content-disposition: attachment; filename=\$filename\); to ensure that it's going off (set $filename obviously, something distinct like my_excel.xls) 2) Are you using ssl and sessions? You'll find some fun and strange behavior trying to save output from an ssl connection and sessions - because sessions force no-cache, and (IE in particular) has real issues with storing the output of a no-cache'd https - you can't save it locally or open with an external application, because either way it has to store it somewhere other than memory, which would be caching. Cheers, -- - Martin Norland, Sys Admin / Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -- 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] Join on single table
* Micah Stevens [EMAIL PROTECTED]: Sounds like a self join should work wonders. I didn't test this, but the idea should work: select t1.app_id as a1, t2.app_id as a2, t2.word, t2.score from tablename as t1 left join tablename as t2 on t1.resource_id = t2.resource_id and t1.app_id != t2.app_id group by word order by word voila, no temp tables. Am I missing something? Speed. :-) I had tried this as well. The temporary tables really do offer much better performance. The issues I was having were (1) bad resultsets (I've now got that fixed) and (2) speed. I still don't have (2) completely fixed, and it may be something I can't fix. On Thursday 10 February 2005 07:56 pm, Matthew Weier O'Phinney wrote: I have a table which contains the following: id (primary key, auto incrementing) app_id (integer, foreign key) resource_id (integer, foreign key) word score (This is a search index.) I want to find all resource_ids from one app_id that match resource_ids in another app_id by word. I have created a temporary table 'tmp1' that contains all resource_ids from the second app_id (the one whose resources I wish to retrieve). I am then looping through all resource_ids in the main table with the first app_id, and doing the following: * Creating a temporary table tmp2 with a single column 'word' populated by the words associated with resource_id in the main table * Selecting all distinct resource_ids from tmp1 INNER JOIN'd on tmp2 on the word field The issues I'm running into are that (1) each resource_id cycle takes a good amount of time, and (2) I seem to be getting either too many resource_ids or not enough. (1) may be something I just have to deal with. As it is, I'm planning on running the full indexing once, and then doing incremental updates, so it may not be that big of an issue (unless it takes too much time to create the initial index). As for (2), unfortunately, I'm not sur ehow to really trouble shoot the issue. I know, for instance, that in once case, I have a list of 343 words that generates a list of ~12,000 resource_ids (of a possible 18,000) -- but I don't quite know how to spot check 300 values to be certain that this is reasonable. In a previous incarnation of the script, I was looping through each word of each resource_id and then selecting out of tmp1 based on the single word value. The results were very different (very few matches), and, again, the script ran long. Any ideas? -- Matthew Weier O'Phinney | WEBSITES: Webmaster and IT Specialist | http://www.garden.org National Gardening Association| http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org mailto:[EMAIL PROTECTED] | http://vermontbotanical.org -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Join on single table
I have a table which contains the following: id (primary key, auto incrementing) app_id (integer, foreign key) resource_id (integer, foreign key) word score (This is a search index.) I want to find all resource_ids from one app_id that match resource_ids in another app_id by word. I have created a temporary table 'tmp1' that contains all resource_ids from the second app_id (the one whose resources I wish to retrieve). I am then looping through all resource_ids in the main table with the first app_id, and doing the following: * Creating a temporary table tmp2 with a single column 'word' populated by the words associated with resource_id in the main table * Selecting all distinct resource_ids from tmp1 INNER JOIN'd on tmp2 on the word field The issues I'm running into are that (1) each resource_id cycle takes a good amount of time, and (2) I seem to be getting either too many resource_ids or not enough. (1) may be something I just have to deal with. As it is, I'm planning on running the full indexing once, and then doing incremental updates, so it may not be that big of an issue (unless it takes too much time to create the initial index). As for (2), unfortunately, I'm not sur ehow to really trouble shoot the issue. I know, for instance, that in once case, I have a list of 343 words that generates a list of ~12,000 resource_ids (of a possible 18,000) -- but I don't quite know how to spot check 300 values to be certain that this is reasonable. In a previous incarnation of the script, I was looping through each word of each resource_id and then selecting out of tmp1 based on the single word value. The results were very different (very few matches), and, again, the script ran long. Any ideas? -- Matthew Weier O'Phinney | WEBSITES: Webmaster and IT Specialist | http://www.garden.org National Gardening Association| http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org mailto:[EMAIL PROTECTED] | http://vermontbotanical.org -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] javascript and php
Hello all, I am having difficulties working with a JavaScript menu that should load on each page of my intranet site. Here is a brief background of the problem: 1) I am using PHP and SQL Server and it is running on Windows 2000 Server (yes I know this stinks but I have no choice in my office). 2) My users first log in. Login information is saved in the PHP session array. This information dynamically adjusts what the users will see from that point on. The higher the access level the more stuff they can see. This should be pretty common. 3) All of my PHP functions display information correctly based on the data stored in the session array. For example, if the user has an administrative login, SSN and rate of pay are displayed while this data is not displayed for other employees. 4) I am using a JavaScript application for my navigation menu. I chose this because I need collapsing menus. There are lots of functions under each category; if I were to use HTML for the menu, my users would have to scroll way down to get to where they want to go - especially the ones still using 800X600 monitor resolution. A php function calls the JavaScript menu and changes what is displayed based on the session array data. Here is the problem: My JavaScript menu DOES NOT always display. It displays about 95% of the time. When it displays, it displays correctly (based on the session data). When it doesn't display, I hit reload and it usually reappears. What's worse, it seems to happen randomly! I could click the same link 10 times and it will work perfectly. The 11th time it might not show up. Here is the small amount of information I know about the problem: I have read through the list server achieves and think the problem may lie with the fact that Javascript has to run at the Web Browser end and PHP has to run at Server Side. This probably explains how it is possible that the two are not in sync but it does not explain WHY this happens about 5% of the time. It also does not explain why it happens only to the JavaScript while always displaying the results of my php functions. Here are my questions: 1) How can make this menu display 100% of the time? I realize this may be hard to answer without looking at all of my code. 2) Should I stop using JavaScript? If so, what should I use instead that allows collapsing menus? Thank you for your time, - Matthew Perry
RE: [PHP-DB] IIS, PHP, and session data
It turns out that the real problem was problem 1) I am not personally in control of our web server. I forwarded some of the posted messages to our IT department and they decided to change what they were telling me. They actually had register globals turned off not on. I changed my code to use the session array and it works beautifully now. Thank you all for your advice! - Matthew -Original Message- From: Simon Rees [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 25, 2005 4:25 PM To: php-db@lists.php.net Cc: Perry, Matthew (Fire Marshal's Office) Subject: Re: [PHP-DB] IIS, PHP, and session data On Tuesday 25 January 2005 20:20, Perry, Matthew (Fire Marshal's Office) wrote: I am having trouble with my session data on Microsoft IIS. Here is a little background of the problem: 1) I am not personally in control of our web server. Our IT department manages it. oh dear! ;-) They have IIS running on their sever and use MS SQL Server, but they have allowed me to use PHP instead of ASP. 2) I have Apache running on a local web server in our office (not the IT department). It accesses the SQL Server database remotely. I I can't comment on the use of register_globals or session_register as I always use the $_SESSION array but I do use PHP on IIS... Something that you might like to check is that the directory specified by: session.save_path in the IIS server's php.ini is a directory writable by the user that IIS masquerades. The default value for this is: c:\php\sessiondata which if your sysadmin installed php as Administrator will not be writable by the IIS user (normally IUSR_hostname). Either get the sysadmin to specify ( create) another dir that is writable by IIS or change the permissions on c:\php\sessiondata Assuming you're running Apache on a Linux (and probably other un*x) distribution you will find that the session.save_path variable is set to /tmp which is usually world writable. I think if you posted the exact error message it would tell me if this was happening to you or not... hth, Simon -- ~~ Simon Rees | [EMAIL PROTECTED] | ORA-03113: end-of-file on communication channel ~~ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] IIS, PHP, and session data
I am having trouble with my session data on Microsoft IIS. Here is a little background of the problem: 1) I am not personally in control of our web server. Our IT department manages it. They have IIS running on their sever and use MS SQL Server, but they have allowed me to use PHP instead of ASP. 2) I have Apache running on a local web server in our office (not the IT department). It accesses the SQL Server database remotely. I have register_global turned OFF and use the following code on each page: session_start(); session_register('logged_in'); session_register('username'); etc... Everything works PERFECTLY on my local system. 3) I have ported all of my code to the IIS server location. It accesses the database correctly but displays an error message when I try to use the session data. It does NOT post messages that the session could not be started (which is the normal sign of session data not being allowed). The message says the variable does not exist. It is as if the session is started but the variables aren't being saved. The question I have is: What concerns should I have with PHP sessions when I move from Apache to IIS? I do NOT need to know how to set up IIS to allow session data correctly (that's the job of our IT department). If this sounds like something our IT department has set up wrong, please do not feel compelled to answer this question. I just would appreciate some advice on what I may need to change in my own code so that it works with IIS instead of Apache. Thank you for your time, Matthew Perry
[PHP-DB] NULL VALUE
My status column in my Employee table should have two values Active and Inactive. Right now all the active employees have the value Active and the rest have a NULL value. Why is it that the following commands do nothing? UPDATE EMPLOYEE SET STATUS='Inactive' where STATUS != 'Active'; UPDATE EMPLOYEE SET STATUS='Inactive' where STATUS 'Active'; UPDATE EMPLOYEE SET STATUS='Inactive' where STATUS IS NULL'; UPDATE EMPLOYEE SET STATUS='Inactive' where STATUS = ''; UPDATE EMPLOYEE SET STATUS='Inactive' where STATUS = NULL; - Matthew
RE: [PHP-DB] NULL VALUE
I apologize for my lack of information concerning this problem and I appreciate the advice for beginners. I also did not mean to post it on this list (If you notice my original message also contained a thank you for a question never asked in this list). I am terribly sorry about this error. HOWEVER: The question can regardless be addressed in this list since it is not appear to be version or database specific. I am using MySQL 4.1 but have experienced the same problem with MS SQL Server. The issue here is NOT whether STATUS is a keyword. Yes STATUS is a keyword and indeed it would probably be wise if I did not use keywords as column names. The reason I chose to leave this column named STATUS is that it is linked to other databases (ouch!) and such attempts have proven to cause even more problems. But in theory this does not matter. One can use keywords as column names in all recent versions of MySQL even though this is unadvised (you have to search the MySQL site for longer than 5 seconds to learn this). The problem exists for all column names. I have experimented with other test tables with more standard column names and have had the same result. mysql_error() or mysqli_error() also do not help here. Even if you enter the SQL command directly it posts a result that changes 0 rows and the query completes without any errors. I believe this problem lies in how SQL handles NULL values. Let me change the column name to avoid the question concerning STATUS as a keyword. UPDATE EMPLOYEE SET STATUS_lsdkrjg='Inactive' where STATUS != 'Active'; UPDATE EMPLOYEE SET STATUS_lsdkrjg ='Inactive' where STATUS 'Active'; UPDATE EMPLOYEE SET STATUS_lsdkrjg ='Inactive' where STATUS IS NULL'; UPDATE EMPLOYEE SET STATUS_lsdkrjg ='Inactive' where STATUS = ''; UPDATE EMPLOYEE SET STATUS_lsdkrjg ='Inactive' where STATUS = NULL; None of these work to update table Employee. According to some of my SQL reference manuals they should! I have tried the following and had success with one of these options: create table TEST ( testA varchar(30), testB varchar(30) ); insert into TEST values ('a', 'a'); insert into TEST values (NULL, 'a'); +++ | testA | testB | +++ | a | a | | [NULL] | a | +++ UPDATE TEST set testA='b' where testA=''; UPDATE TEST set testA='b' where testA'a'; +++ | testA | testB | +++ | a | a | | [NULL] | a | +++ Finally I tried this: UPDATE TEST set testA='b' where testA IS NULL; +++ | testA | testB | +++ | a | a | | b | a | +++ But the last example does not work for ANY fields in my EMPLOYEES table. I thought at first the problem might have arisen with the fact that this table is linked to other databases, but even after I removed the links this problem exists! I think the problem still lies with my understanding of NULL. What am I forgetting about the nature of NULL values? Why won't the following work for NULL values? UPDATE TEST set testA='b' where testA=''; UPDATE TEST set testA='b' where testA'a'; How is it possible that all NULL values equal any string? If this question does not belong in this list I will make no additional postings concerning this topic and will continue researching other sources. Once again I apologize for the original posting. It was meant to go to one of my associates (who also does not know the answer!). - Matthew -Original Message- From: Jochem Maas [mailto:[EMAIL PROTECTED] Sent: Monday, January 03, 2005 2:16 PM To: php-db@lists.php.net Subject: Re: [PHP-DB] NULL VALUE Norland, Martin wrote: -Original Message- From: Jochem Maas [mailto:[EMAIL PROTECTED] Sent: Monday, January 03, 2005 12:16 PM Subject: Re: [PHP-DB] NULL VALUE LightBulbMoment (tm): 5 seconds of searching on the MYSQL site tells me STATUS is a keyword. try either renaming your field or using backticks to escape the name e.g.: http://dev.mysql.com/doc/mysql/en/Reserved_words.html doesn't list status, although I am familiar with its various forms e.g. show status. I didn't even go as far looking there I made the assumption that mysql was crapping out on 'STATUS' because of its use in 'SHOW STATUS' query (and the like) - also its hard to determine whats going wrong with someones setup when you have no idea what version of stuff they are running - bare in mind we assume the chap (Matthew Perry) in question is using MySQL but he did not state this so that may be incorrect. at any rate dumping the output of mysql_error() or mysqli_error() would probably have saved him an email to this list. ;-) You're probably right, but I don't exactly see this as a 'clearly documented'. Still, backticking all field names is a good idea anyway. I didn't mean to say it was clearly documented (IMHO reading understanding documentation is one of the hardest parts
[PHP-DB] get primary key
This one should be easy for most of you. What is the SQL query to select the column name for the primary key of a table? -Matthew
[PHP-DB] to many addresses
We have about 20,000 addresses in our database. If my users are filling out a form that requires an address already in our database I have to make sure they enter it in a format already in the db (such as West Road not West Rd.). I have to also allow for new addresses. Obviously having a dropdown of 20,000 entries and a second field called Other Address Not Here will not work. It would also be nice if the field auto fills with suggested addresses from the database. Does anyone have advice on how I should do this? I have been scratching my head over this problem all morning. -Matthew
[PHP-DB] mysql to access
Does anyone know of a FREE program that exports MySQL to access? The trial versions of the ones I have downloaded do not export all the records of the database. - Matthew
RE: [PHP-DB] mysql to access
Here is the problem: I am currently using MySQL and PHP for this application but have realized recently that the bulk of my work is setting up three forms (add, view, modify) for each table I create. It takes hours for each table with MySQL and PHP but takes only minutes with Access. Also, other office administrators have been trained in Access instead of MySQL and will not be able to update my tables directly or set up new forms if I only use MySQL and PHP. On the other hand, PHP and ASP are easier and more flexible with user control options. Also, directly entering SQL can be much more efficient than using Access's embedded SQL applications. I really would like to exploit the advantages of both databases but do not know the best means by which to do this. We are creating a standard that will be followed by everyone in our department and need the best and most efficient solution possible. People move around from different positions constantly and it seems we are making radical changes to our system every year. Here are three questions with which I still need help: 1) Would it really make sense to split the data management between two linked databases (Access and MySQL) or would this just cause problems? 2) If I must use Access, should I use ASP(grrr) instead of PHP? 3) If I must use Access, should I use MS SQL Server(grrr) instead of MySQL? Thank you all for your time and patience. - Matthew -Original Message- From: Bastien Koert [mailto:[EMAIL PROTECTED] Sent: Friday, December 17, 2004 10:01 AM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] mysql to access it would depend on what you need the app to do...if you are looking to use access to do reporting and/ or act as a front end, then it may be feasible... more details, if you care to share them, may help in this consideration bastien From: Perry, Matthew (Fire Marshal's Office) [EMAIL PROTECTED] To: Bastien Koert [EMAIL PROTECTED] Subject: RE: [PHP-DB] mysql to access Date: Fri, 17 Dec 2004 09:59:25 -0600 You mean link the tables? I haven't yet considered this. - Matthew -Original Message- From: Bastien Koert [mailto:[EMAIL PROTECTED] Sent: Friday, December 17, 2004 9:42 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: [PHP-DB] mysql to access why not just link the mysql to access? bastien From: Perry, Matthew (Fire Marshal's Office) [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: [PHP-DB] mysql to access Date: Fri, 17 Dec 2004 09:33:39 -0600 Does anyone know of a FREE program that exports MySQL to access? The trial versions of the ones I have downloaded do not export all the records of the database. - Matthew -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Excel - merging cells with PHP
When you export a table to excel, is there a way to merge cells and create borders? I want my excel file to look exactly like my html table looks. Matthew Perry
[PHP-DB] PHP vs ASP
I need some ammo to convince my boss not to use ASP but use PHP instead. Anyone have some info I can give him? - Matthew
[PHP-DB] passing both an anchor and a variable
How do you append both an anchor and a variable to a URL with PHP? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MySQL data harvester
My office purchased 21 fascinating cell phones that have GPS locaters and bar codes. When we scan a bar code with one of these cell phones, the data is sent to a third party company; information about this scan is stored on their database. I have installed a harvester on my pc that downloads this data off of the third party database into my own MySQL database. I want to link this data with my other tables to modify my inventory information. What is the best way to continuously update all tables when new transactions occur? With MS SQL Server or ORACLE I would write a stored procedure or trigger that could do this. What tools can I use with MySQL instead of procedures or triggers? Matthew
[PHP-DB] MySQL backup software
Does anyone know a free MySQL backup program to schedule regular backups?
RE: [PHP-DB] backing up database with mysqldump
How do I provide a password? I have been trying -p password[mypass] mysqldump sampledb ./backup/file.txt -Matt _ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, October 25, 2004 11:24 AM To: Perry, Matthew (Fire Marshal's Office) Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] backing up database with mysqldump MySQLdump is an executable program. From the command line: C:\mysqldump databasename ./path/to/backup/file.sql (or file.txt ) C:\mysqldump --help gives all the options dave Perry, Matthew (Fire Marshal's Office) [EMAIL PROTECTED] 10/25/2004 11:14 AM To: [EMAIL PROTECTED] cc: Subject: [PHP-DB] backing up database with mysqldump I have attempted to follow the documentation for mysqldump both on mysql.com and previous emails to this list server. Unfortunately none of the advice has helped me successfully backup my database. I have been spoiled by phpmyadmin backup procedures and have never had to manually set up a backup system for a local server. From shell what should I enter tot to backup my database called sampdb to a location c:/backups? Everything I have tried spits out an error message. -Matt
[PHP-DB] imagecreatefromjpeg()
I am using PHP 4.1 Why would the php function imagecreatefromjpeg() not be recognized? Fatal error: Call to undefined function: imagecreatefromjpeg() in C:\Program Files\Apache Group\Apache2\htdocs\Inventory\updateitem.php on line 77 -Matthew Perry
RE: [PHP-DB] setting root password
I entered select user(); It outputs: --- user() [EMAIL PROTECTED] --- After I enter: SET PASSWORD FOR [EMAIL PROTECTED]('mypassword'); ERROR 1146: Table mysql.user does not exist. How is this possible? - Matt -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 19, 2004 8:37 AM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] setting root password Matt, Is there a space between PASSWORD and the opening parenthesis? There shouldn't be, if there is. Otherwise, your statement worked without errors for me on MySQL Version 4.0.16.max-nt. Make sure that you are logged in as root. C : \ select user(); Sometimes MySQL is cryptic about its error messages for security reasons. dave Perry, Matthew (Fire Marshal's Office) [EMAIL PROTECTED] 10/19/2004 08:24 AM To: [EMAIL PROTECTED] cc: Subject: RE: [PHP-DB] setting root password After going to the command prompt I have done exactly this: c:\cd C:\mysql\bin c:\mysql\binmysql -uroot -p mysqlSET PASSWORD FOR [EMAIL PROTECTED]('mypassword'); I get the following familiar message: You have an error on your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'PASSWORD('mypassword')' at line 1 Why does this not set my password correctly? -Matt _ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, October 18, 2004 1:35 PM To: [EMAIL PROTECTED]; Perry, Matthew (Fire Marshal's Office) Subject: Re: [PHP-DB] setting root password If you haven't yet deleted the localhost root account, you can log onto the mysql client with: mysql mysql -uroot -p then press enter again when it prompts you for a password. You should now be able to manage all your account info. dave Perry, Matthew (Fire Marshal's Office) [EMAIL PROTECTED] 10/18/2004 01:28 PM To: [EMAIL PROTECTED] cc: Subject: [PHP-DB] setting root password I have tried the step-by-step methods listed on mysql.com for setting a root password for my local server but I keep getting the message you must have privileges to update tables in the mysql database to be able to change passwords for others. What could I be doing incorrectly? -Matt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] setting root password
How embarrassing. Yes I must have accidentally deleted the table. I reinstalled and it works fine now. Thank you very much for your help. -Matt _ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 19, 2004 11:14 AM To: Perry, Matthew (Fire Marshal's Office) Subject: RE: [PHP-DB] setting root password try mysql\ use mysql then mysql\show tables is the user table there? if not, have you dropped the user table? David Perry, Matthew (Fire Marshal's Office) [EMAIL PROTECTED] 10/19/2004 11:09 AM To: [EMAIL PROTECTED] cc: Subject: RE: [PHP-DB] setting root password I entered select user(); It outputs: --- user() [EMAIL PROTECTED] --- After I enter: SET PASSWORD FOR [EMAIL PROTECTED]('mypassword'); ERROR 1146: Table mysql.user does not exist. How is this possible? - Matt -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 19, 2004 8:37 AM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] setting root password Matt, Is there a space between PASSWORD and the opening parenthesis? There shouldn't be, if there is. Otherwise, your statement worked without errors for me on MySQL Version 4.0.16.max-nt. Make sure that you are logged in as root. C : \ select user(); Sometimes MySQL is cryptic about its error messages for security reasons. dave Perry, Matthew (Fire Marshal's Office) [EMAIL PROTECTED] 10/19/2004 08:24 AM To: [EMAIL PROTECTED] cc: Subject: RE: [PHP-DB] setting root password After going to the command prompt I have done exactly this: c:\cd C:\mysql\bin c:\mysql\binmysql -uroot -p mysqlSET PASSWORD FOR [EMAIL PROTECTED]('mypassword'); I get the following familiar message: You have an error on your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'PASSWORD('mypassword')' at line 1 Why does this not set my password correctly? -Matt _ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, October 18, 2004 1:35 PM To: [EMAIL PROTECTED]; Perry, Matthew (Fire Marshal's Office) Subject: Re: [PHP-DB] setting root password If you haven't yet deleted the localhost root account, you can log onto the mysql client with: mysql mysql -uroot -p then press enter again when it prompts you for a password. You should now be able to manage all your account info. dave Perry, Matthew (Fire Marshal's Office) [EMAIL PROTECTED] 10/18/2004 01:28 PM To: [EMAIL PROTECTED] cc: Subject: [PHP-DB] setting root password I have tried the step-by-step methods listed on mysql.com for setting a root password for my local server but I keep getting the message you must have privileges to update tables in the mysql database to be able to change passwords for others. What could I be doing incorrectly? -Matt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] setting root password
I have tried the step-by-step methods listed on mysql.com for setting a root password for my local server but I keep getting the message you must have privileges to update tables in the mysql database to be able to change passwords for others. What could I be doing incorrectly? -Matt
[PHP-DB] how many databases should I create
I am developing a variety of different web based systems including inventory, payroll, incident reports etc. Should I create a new database for each project category or one huge database with every table I will ever use in it? -Matt
[PHP-DB] backing up off of web host
The MySQL database on my web host has only non-sensitive information. How bad an idea is it to have a backup copy emailed to me at a designated time so I don't have to depend on myself and the host for backups? I am worried this cheep web host will go out of business and take my backups with him. The file will be rediculously huge for email of course. Is this the only problem? What other solutions do I have that do not depend on my web host? Matt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MySQL nested subqueries
Anyone know when there will be a version of MySQL that can handle nested subqueries? -Matt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] PHP functions independant executions
How do I get my PHP funcitons to execute independantly based on what time of day it is and not on the user? This may not be how PHP was designed but I would like to do things like send out an email to someone based on suchandsuch criteria, backup DB on regular schedule etc. - Matt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] moving from MS Access
I have finally convinced my office manager to move from Access to MySQL. Unfortunately the office users are used to Access forms instead of web forms. I have attempted to make my web forms look as much like the Access forms they are used to but I am not a web designer. Does anyone know a good application that can help me with this so I can get away from UI development back to my DB management? I realize this is not a web design list server. Matthew Perry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] DB will INSERT wont UPDATE..error in code?
forgive the poor structure of my code, im pretty new at this and havent figured out exactly what it should be formed like to look its best, anyway whenever i run this code it works on inserting new information into the database, however when i want to update the SQL query returns an output like this 'SQL statement = UPDATE badges (staff,ttlpst,mnthpst,ttlicon,mnthicon) VALUES ('1','1','1','/ribbons','/ribbons') WHERE fid=2' but when i try to pull the information from the database it hasnt updated, can someone help me out with this...im not sure why it wouldnt update even though the statement looks correct. if (empty($form_status)){ $staff = $HTTP_POST_VARS[staff]; $ttlpst = $HTTP_POST_VARS[ttlpst]; $mnthpst = $HTTP_POST_VARS[mnthpst]; $ttlicon = $HTTP_POST_VARS[ttlicon]; $mnthicon = $HTTP_POST_VARS[mnthicon]; $exists = SELECT * FROM badges WHERE fid = $fid; $result = mysql_query($exists); if (mysql_num_rows($result) == 0) { $sql = INSERT INTO badges (fid,staff,ttlpst,mnthpst,ttlicon,mnthicon) VALUES ('$fid','$staff','$ttlpst','$mnthpst','$ttlicon','$mnthicon'); db_query($sql); $form_status = span class=\msgUpdated\Description Updated!/spanbr\n; } else { $sql = UPDATE badges SET staff = '.$HTTP_POST_VARS[staff].' ttlpst = '.$HTTP_POST_VARS[ttlpst].' mnthpst = '.$HTTP_POST_VARS[mnthpst].' ttlicon = '.$HTTP_POST_VARS[ttlicon].' mnthicon = '.$HTTP_POST_VARS[mnthicon].' WHERE fid = $fid; db_query($sql); $form_status = span class=\msgUpdated\Description Updated!/spanbr\n; } } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] DB will INSERT wont UPDATE..error in code?
sorry this is the output i meant to post SQL statement = UPDATE badges SET staff = '1' ttlpst = '1' mnthpst = '1' ttlicon = '/trophies' mnthicon = '/ribbons' WHERE fid = 61 and this is the error i getyet i still cant for the life of me find a problem Update query = UPDATE badges SET staff = '1' ttlpst ='1' mnthpst = '1' ttlicon = 'trophies' mnthicon = 'medals' WHERE fid = 61Query3 failed: You have an error in your SQL syntax near 'ttlpst ='1' mnthpst = '1' ttlicon = 'trophie' at line 3 thanks for your help -- Advanced Forums, For Free! - Speak EZ forums ( http://www.speakezforums.com ) Jason Wong [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Wednesday 13 October 2004 04:08, Matthew Kiehne wrote: database, however when i want to update the SQL query returns an output like this 'SQL statement = UPDATE badges (staff,ttlpst,mnthpst,ttlicon,mnthicon) VALUES ('1','1','1','/ribbons','/ribbons') WHERE fid=2' but when i try to pull the information from the database it hasnt updated, can someone help me out with this...im not sure why it wouldnt update even though the statement looks correct. I don't see how you get the above output when $sql is defined like so: $sql = UPDATE badges SET staff = '.$HTTP_POST_VARS[staff].' ttlpst = '.$HTTP_POST_VARS[ttlpst].' mnthpst = '.$HTTP_POST_VARS[mnthpst].' ttlicon = '.$HTTP_POST_VARS[ttlicon].' mnthicon = '.$HTTP_POST_VARS[mnthicon].' WHERE fid = $fid; echo $sql; Make use of mysql_error(). -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* There are three things I always forget. Names, faces -- the third I can't remember. -- Italo Svevo */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] DB will INSERT wont UPDATE..error in code?
Jason Wong [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] If you look up the manual entry for UPDATE, you'll find that you're missing the commas separating the columns. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* I'm free -- and freedom tastes of reality. -- The Who */ Thanks I dont know how i missed that! Gave it a go and it works perfectly, thanks again -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] ER diagram class
Does anyone know a good class or program that automatically generates an ER diagram from all tables in a MySQL database? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Importing Excel and Access data to MySQL
Simple question, How does one import excel and access data to MySQL? -- Matthew Perry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Newbie needs help with multiple MySQL databases
Hi, im fairly new to php and mysql and need a little help. im running a forum community and would like to have it run on multiple databases because of performance issues others have encountered using the same software on on database. My question is is it possible to have the software connect to 2 different databases depending on which is needed? and if so will users need to login again when accessing the second database (their user info will only be on the 1st database.) Thank You -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] which DB to use?
Thank you very much for your help. If I had to choose between MS SQL Server or or mysql, which would you recommend? I prefer nested subqueries, triggers, procedures etc supported by SQL Server but am completely unfamiliar with any problems that may be accociated with using Microsoft's product and PHP. Ideally, I would use Oracle but it is probably outside of our budget. - matt Bastien Koert wrote: Here is a basic connect script. I would stringly recommend against using access, use mysql instead. HTML HEAD /HEAD BODY ?php // Program to test connecting to a Microsoft Access ODBC Data Source $connection = odbc_connect(postcard, , ); print Connected to datasourceBRBR; if ($result = odbc_exec($connection, SELECT * FROM postcard)) print Command executed successfullyBRBR; else print Error while executing commandBRBR; // Print results while(odbc_fetch_row($result)) print odbc_result($result, 1) . . odbc_result($result, 2) . . odbc_result($result, 3) . . odbc_result($result, 4) . . odbc_result($result, 5) . BR; odbc_close($connection); print BRConnection closed.; ? /BODY /HTML bastien From: Matthew Perry [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: [PHP-DB] microsoft access Date: Thu, 30 Sep 2004 21:28:48 -0500 Does anyone know of a good online source for using php and microsoft access. I don't want to have to use asp. Thank you for your time. Matthew Perry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ MSN® Calendar keeps you organized and takes the effort out of scheduling get-togethers. http://join.msn.com/?pgmarket=en-capage=byoa/premxAPID=1994DI=1034SU=http://hotmail.com/encaHL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN® Premium right now and get the first two months FREE*. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] search form w/ multiple fields
since: ?php echo $_POST['firstname']; ? does not work on your installation, try: ?php echo $GLOBALS['HTTP_POST_VARS']['firstname']; ? when the form is submitted. there is an obvious oversight in the SQL query below. You are currently checking whether or not the firstname, lastname, phone or email data from the form is present in only the firstname field. also, an elegant solution would be to build the SQL query based on which form fields have been populated. Vincent Jordan wrote: I have a form with firstname, lastname, phone, and email fields. I would like to search the database and return results to the same page in an iframe. I want to be able to search my just one or multiple. For example I can search by firstname with value of john and it will return all john rows in iframe or search firstname value john and lastname value smith and again will return all rows with data in iframe. I have tried this but don't think I am doing something correct: $result = mysql_query (select * from customerinfo where firstname like '%.$_POST['firstname'].%' or '%.$_POST['lastname'].%' or '%.$_POST['phone'].%' or '%.$_POST['email'].%'); I cant seem to figure out how to display. I have tried ?php echo $_POST['firstname']; ? in the HTML but there was no return of data. This is my form: form action=search.php method=post name=search id=search First Name: input type=text name=firstname / Last Name: input type=text name=lastname / Phone : input type=text name=phone / Email : input type=text name=email / input type=submit value=search /form all of this is on the same page, the page is called search.php -- _ Matthew McNicol yellowmarker.co.uk PHP / MySQL web development -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] RE: [SPAM] Re: [PHP-DB] DB table creation question
at the moment if a value is say inserted into the 'warranty_info' table you are just checking that the 'product_id' or 'cust_id' already exists in 'product_info' and 'customer_info'. you still have to populate them first, otherwise the referential integrity will return an error when you insert into 'warranty_info'. similarly if you delete a record from 'warranty_info' you might actually delete the associated customer record. is this what you want? at the moment it looks like the 'rma_info' table is not linked to any other table? personally, I would not go so far as to specify 'FOREIGN KEY ... REFERENCES' or 'ON UPDATE CASCADE ON DELETE RESTRICT' in the create table code. I would use the application code to make sure a customer exists before referencing them in the 'product_info' or 'warranty_info' tables. similarly I would use the application code to delete table record out of each appropriate table. I would use the primary and secondary index assuming you are working with more than 100 records in each table. Vincent Jordan wrote: Does this seem to be correct? With this if value was inserted into a table will the tables with the FK's automatically be updated? Here is the DB design as I have it now. Let me know if all is correct please. CREATE TABLE customer_info ( cust_id int (6) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, first_name varchar (50) NOT NULL, last_name varchar (50) NOT NULL, address varchar (50) NOT NULL, address2 varchar (50) NULL, city varchar (50) NOT NULL, state varchar (50) NOT NULL, zip varchar (50) NOT NULL, home_phone varchar (15) NOT NULL, work_phone varchar (15) NULL, other_phone varchar (15) NULL, email varchar (50) NOT NULL, ); CREATE TABLE product_info ( product_id int (6) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, cust_id int (6) NOT NULL, model varchar (50) NOT NULL, serial varchar (20) NULL, FOREIGN KEY (customer_info_cust_id), REFERENCES customer_info(cust_id), ON UPDATE CASCADE ON DELETE RESTRICT, INDEX (cust_id), FOREIGN KEY (cust_id), REFERENCES customer_info(cust_id), ); CREATE TABLE warranty_info ( warranty_id int (6) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, product_id int (6) NOT NULL, cust_id (6) NOT NULL, mfg_warranty tinyint (1) NOT NULL default '1', gold_warranty tinyint (1) NOT NULL default '0', gold_warranty_id int (16) NULL, FOREIGN KEY (customer_info_cust_id), REFERENCES customer_info(cust_id), ON UPDATE CASCADE ON DELETE RESTRICT, INDEX (cust_id), FOREIGN KEY (cust_id), REFERENCES customer_info(cust_id), FOREIGN KEY (product_info_product_id), REFRENCES product_info(product_id), ON UPDATE CASCADE ON DELETE RESTRICT, INDEX (product_id), FOREIGN KEY (prod_id), REFRENCES product_info (product_id), ); CREATE TABLE rma_info ( rma_id int (6) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, assigned_to varchar (50) NULL, logged_by varchar (50) NULL, date datetime NOT NULL, time_spent datetime (6) NULL, status varchar (50) NOT NULL, priority varchar (50) NULL, closed_by varchar (50) NULL, completed_by varchar (50) NULL, date_closed datetime (6) NULL, billable tinyint(1)NULL, billed tinyint (1) NULL, cost varchar (6) NULL, last_modified_by varchar (50) NULL, last_modified_date datetime NULL, ); -Original Message- From: Matthew McNicol [mailto:[EMAIL PROTECTED] Sent: Sunday, July 18, 2004 5:46 PM To: Vincent Jordan Cc: [EMAIL PROTECTED] Subject: [SPAM] Re: [PHP-DB] DB table creation question use the mysql 'auto increment' on a 'int' 'customer_id' field to generate a unique customer id. the RMA number is associated with a 'customer_id' since the 'customer_id' field is in both the customers table and the RMA table. Note that currently you have 'custid' and 'Customerid' respectively which you should change so that they are uniform (it helps with database maintenance is foreign keys are spelt the same as the primary key equivalent). to assign a product to a customer, first create a products table which defines each product. each product would have a unique 'product_id'. second, create a table which will link the products (zero, one or more) a customer has selected to the 'rma_id'. such tables would have the following structure: table: product product_id product_desc ... table: rma_product rma_id product_id table: customer customer_id firstname lastname ... table: rma rma_id assignedto loggedby customer_id ... Do you follow? Do you understand in what order you should populate the tables and how you can now create SQL queries to get the information you need? Vincent Jordan wrote: I am creating a database to keep
Re: [PHP-DB] DB table creation question
use the mysql 'auto increment' on a 'int' 'customer_id' field to generate a unique customer id. the RMA number is associated with a 'customer_id' since the 'customer_id' field is in both the customers table and the RMA table. Note that currently you have 'custid' and 'Customerid' respectively which you should change so that they are uniform (it helps with database maintenance is foreign keys are spelt the same as the primary key equivalent). to assign a product to a customer, first create a products table which defines each product. each product would have a unique 'product_id'. second, create a table which will link the products (zero, one or more) a customer has selected to the 'rma_id'. such tables would have the following structure: table: product product_id product_desc ... table: rma_product rma_id product_id table: customer customer_id firstname lastname ... table: rma rma_id assignedto loggedby customer_id ... Do you follow? Do you understand in what order you should populate the tables and how you can now create SQL queries to get the information you need? Vincent Jordan wrote: I am creating a database to keep track of our warranty returns. Currently we do not have anything to track warranty info besides a big excel file. I would like to keep customer data, product info and RMA data in separate tables but still keep them related. If I had table customers: custid Firstname Lastname Address Address2 City State Zip Phone Email And table RMA Rmaid Assignedto Loggedby Customerid Date Timespent Status Priority Closedby Completedby Dateclosed Billable Billed Cost Lastmodifiedby Lastmodifieddate What I want to ensure is that if john smith fills out an RMA request online a customer id is assigned to John, the RMA number is associated with Johns customerid and I need to figure out how to assign a product to John. Also if john has more than one product assign products so when I pull up Johns information I can see all of Johns products owned. I am running mysql latest version.. Any help would be greatly appriciated -- _ Matthew McNicol yellowmarker.co.uk PHP / MySQL web development -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Printing selected characters (strcnt?)
Try this: // takes the 1st character from $last_name and adds // datetime in format of DDMMYYhhmm $rma = substr( $last_name, 0, 1) . date(dmyHi); See: aspn.activestate.com/ASPN/docs/PHP/function.substr.html uk2.php.net/date Vincent Jordan wrote: I am trying to figure out how to select the first letter of from the form field print it then append by datetime. Here is an example: snip $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $name = $first_name . ' ' . $last_name $rma = ?strcnt($last_name), 1 . Datetime(?) // takes the 1st character from $last_name and adds datetime in format of 715041200 /snip Thanks any help appreciated Vincent Jordan Technical Support Smart Parts, Inc. Loyalhanna Business Complex 100 Station Street Loyalhanna, PA 15661 800-992-2147 X 5617 -- _ Matthew McNicol yellowmarker.co.uk PHP / MySQL web development -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] headers and if statements
?if($logIn != 1) {header(Location: loginError.php);}? Why does this direct me to loginError.php even when $logIn = 1? - Matt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Page cannot be displayed problems
My bosses computer gets a Page cannot be displayed message when she uses some of my pages. I have tried to find a pattern as to why this happens on only her computer. I think the problem only occurs when she links to a page that links to a page. Say I have 3 pages: page1.php, page2.php, and page3.php On page1.php form action=page2.php method=PUT input type=submit value=GO /form And on page2.php meta http-equiv=refresh content=0;URL=page3.php If I click go on page1.php I SOMETIMES get the cannot be displayed message. SOMETIMES it works even on her computer! Anyone know why? - Matthew Perry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Page cannot be displayed continues
Everyone, Thank you very much for your advice about not using PUT. I will use GET or POST from now on. I am, however, failing to understand how to use headers to change pages instead of meta tags. After checking if the user has logged in correctly I do this: if ($loginGood){ echo 'meta http-equiv=refresh content=0;URL=welcome.php'; } else { echo 'meta http-equiv=refresh content=0;URL=loginerror.php'; } How can I use a header like the following one to do change pages based on variable input? Thank you for your time and patience, - Matt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] First letter
What PHP function returns just the first letter of a string? - Matt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Cursor in text box.
My users complain about everything. The most common is Why do I have to move the mouse over to this box every time? Wh! How do I get the cursor to que into the first input area of my form? -Matt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Scrolling drop down menu
When my users choose an option in the drop down menu, they sometimes accidentally change what they have chosen when the move the center scrolling button of their mouse. I was giving a presentation in front of my company's owner and did this myself. 5 or so index fingers instantly pointed at me saying See you do that to! Wh! Is there a way to stop a menu from scrolling with the center scrolling mouse button? - Matt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] scrolling drop down menu
Then I withdraw the question. Thank you for your time. John W. Holmes wrote: matthew perry wrote: When my users choose an option in the drop down menu, they sometimes accidentally change what they have chosen when the move the center scrolling button of their mouse. I was giving a presentation in front of my company's owner and did this myself. 5 or so index fingers instantly pointed at me saying See you do that to! Wh! Is there a way to stop a menu from scrolling with the center scrolling mouse button? Your questions have nothing to do with PHP. And absolutely nothing to do with DB...
[PHP-DB] move_uploaded_file
I have a file uploading function that works well on my local server. It finds a picture and uploads it into a defined directory. Unfortunately this function does not work when I try to upload to my web host. It says I do not have the proper permissions. I believe this has to do with the fact that my web host requires a user name and password for all file transfers for security reasons. I still want my users to be able to upload files or pictures to my web host (if I have granted them proper access through my log in). How do I indicate the correct login sequence for my web host with a function like move_uploaded_file? - Matt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Macs and sessions
Macintosh users can't log in on my web site. I don't require anything unusual for log ins - simply a form with a user id and password that queries a MySQL database. The form is not encripted and I don't even use any security precautions for the data transfer (users can't do much anyway). After the log in I store all information in session data. The rest of my site's pages work fine including my PHP pages. Anyone know why macs might have problems with PHP/MySQL data transfers? Matt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] headers already sent
When I insert the following header: header (Content-type: application/vnd.ms-excel); header (Content-Disposition: attachment ); I get the messages: *Warning*: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\trial.php:2) in *C:\Program Files\Apache Group\Apache2\htdocs\trial.php* on line *3* *Warning*: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\trial.php:2) in *C:\Program Files\Apache Group\Apache2\htdocs\trial.php* on line *4 *I get similar messages when I use my web host. How do I use these headers correctly? Matt
[PHP-DB] links to maps
Anyone know a quick and easy way to fill in the address on a yahoo maps form? I want a link from my page to fill in all the details I already know so my users don't have to enter it. - Matt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] pdf editor
Does anyone know a free pdf editor? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] pdf editor
I use Windows XP. Really all I need to do is remove a single line in a pdf file and I can't convince myself to spend $749 for Acrobat Pro to do it. - Matt On 7 Apr 2004, at 16:34, matthew perry wrote: Does anyone know a free pdf editor? what platform do you require it for? -- Mike Karthauser Managing Director - Brightstorm Ltd Email [EMAIL PROTECTED] Web http://www.brightstorm.co.uk Tel 0117 9426653 (office) 07939 252144 (mobile) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Graphing - bar charts
Bar graphs are very easy to use with PHP. It's just a table columns of varying height. I wrote this a long time ago. To be honest it isn't very good code and I think I got the ideas from someone else. Regardless it should give you an idea. You basically pass in an array of dollar amounts and it outputs a bar graph. You can also manually adjust the scale of the graph by varying the values $minval and $maxval. The function bar makes a single bar of the graph. Use it at your own risk though. It is pretty poor PHP but it did the trick for me! //graph looks best when values are between 50 and 250 function bargraph ($bararray, $xminval, $xmaxval){ function bar($height,$val, $minval, $maxval){ $n_bars=count($bararray); $newmargin = $maxval - $minval; $newdifference = $height - $minval; $newchange = $newdifference / $newmargin; $newheight = 200 * $newchange + 25; echo (td valign=bottom . table bgcolor=#aa height= . $newheight . cellpadding=0 cellspacing=0); echo(trtd align=center valign=bottom); echo (font color=#0 size=-1 ); echo ($); printf(%.2f, $val); echo (/font); echo (/td/tr/table/td); } $n_bars=count($bararray); $border=0; echo(table bgcolor=#a0a0a0 height=200 width= . $n_bars*$width . border= . $border . ); if (!$xminval) $minval= min ($bararray); else $minval = $xminval; if (!$xmaxval)$maxval= max ($bararray); else $maxval = $xmaxval; for ($x = 0; $xcount($bararray); $x++){ bar($bararray[$x], $bararray[$x], $minval, $maxval); } echo(/table); } -- - Matt John W. Holmes wrote: From: Craig Hoffman [EMAIL PROTECTED] I am looking for an open source and simple PHP script that will graph (bar) a few MySQL fields. Does anyone have any recommendations? The easiest way is to just have an image that you dynamically vary with width of img src=dot.jpg height=10 width=$width Or take a look at JPGraph, which offers a lot of features. ---John Holmes...
[PHP-DB] password input type
Does using a pasword input type input name=password type=password make the transfer more secure from someone sniffing my connection or does it only shield an onlooker from seeing what the user enters? - Matt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] to many files!
I am accumulating way to many PHP files in my home directory. It is very difficult to sift through all the files. I use a lot of includes and requires so it is difficult to organize them in folders even if I change back a directory with my requires using ..\. Does anyone know of a better way to organize a huge spiderweb of documents? Matt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] checkboxes and loops
OK lets see if I can figure out how to ask this: I am setting up a system for my company to filter through employee applications. Most of the applications do not fit the criteria and I want to allow my bosses a checkbox to the right of them which they can check or uncheck to remove an applicant. So I run a loop that generates a bunch of check boxes with the name box1, box2, box3... by running a loop that runs this and increments counter every time: { input type = checkbox name = box?echo $counter;? value = delete $counter++; } But when I try to create my query that updates the table I have a problem generating these variable again by referring to them indirectly: *Bad solution 1 (to much work)*** if ($box1 == 'delete') do whatever if ($box2 == 'delete') do whatever if ($box3 == 'delete') do whatever if ($box4 == 'delete') do whatever if ($box5 == 'delete') do whatever if ($box6 == 'delete') do whatever *** *Bad solution 2 (doesn't work)*** $counter = 1; while (whatever) { if ($box . $counter == 'delete') do whatever $counter++; } *** How do I get around this problem? Hopefully someone understands what I am trying to say. Matt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] exporting data to excel
I am looking for the easiest way to export data to an excel file. Is the easiest way to use PHP's file handling functions? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] escape chars continued
Filip de Waard wrote: On Mar 22, 2004, at 12:17 PM, Jimmy Brock wrote: Matt, love your show! Use the addslahses function to escape ' \ characters. See http://php.net/addslashes for details. Actually, you shouldn't use addslashes, but a database specific function like mysql_escape_string(). http://phundamentals.nyphp.org/PH_storingretrieving.php Regards, Filip de Waard Jimmy Brock Matthew Perry [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I am trying to allow my users to enter quotes in their strings. For instance instead of writing:2 inch rod, they can write 2 rod. The problem is, of course, that ends the string and all that is saved is any value before the . How do I get around this without using textarea? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Actually I think the problem is before you can use either addslashes or mysql_escape_string() functions. The value with or ' never reaches the database. I think I need a way to ignore quotes for input values in HTML. Say I have this: input type=text size = 2 name=Q And my user enters:2 copper tubing The value for Q will be: 2 When I add it to the database with addslashes there will be no , ' or \ to add a slash to! And when I retreive it from the database and use mysql_real_escape() there will be the same problem. Thank you for your time, and yes I am the real Matthew Perry of course. Matthew Perry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL - separating web and database servers
Hi Piotr, Everyone else is suggesting edit all of the code. Alternatively you could setup an iptables rule which forwards all incoming requests on 127.0.0.1:3306 (or whatever port your mysql server is running on) to 192.168.0.1:3306 (repolace 192.168.0.1 wit the IP of your DB server). This way if your DB moves again, you change your forward rule. If, however, you try to put the PHP code on another system, you will need to either put the DB on the same system, or change the iptables ruleset for the new webserver. It's worth a shot. Matt Vos On Thu, 2004-03-18 at 03:57, Operator wrote: Hi everyone, I need to put my database server on the another machine - how can I configure system(Debian Linux)/php/mysql etc. to make it work without changing all 'localhost' in a hundreds of customer's scripts? The problem is, when localhost is specified as a host the connection is made using unix socket, not TCP (is it possible to change this?). I tried to export the socket from database server via NFS, but with no success: (...) munmap(0x2e1f2000, 4096) = 0 rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_DFL}, 8) = 0 socket(PF_UNIX, SOCK_STREAM, 0) = 3 fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR) connect(3, {sin_family=AF_UNIX, path=/var/run/mysqld/mysqld.sock}, 110) = -1 ECONNREFUSED (Connection refused) shutdown(3, 2 /* send and receive */) = 0 close(3) = 0 (...) Any ideas? Regards Piotr Babula
Re: [PHP-DB] msql perfomance: fast through mysql, slow through php
Try putting a separate network connection between your webserver box and your db, specifically for data between PHP and your DB. Don't route that traffic through the same network as you are using to retrieve the webpage, as the DB connection will eat up all of your bandwidth, leaving none available for sending the data to the browser. On Tue, 2004-02-10 at 23:17, jde wrote: Aha!!! In preparing to give more info, as requested by Sebastian, I have discovered that: You are right, but not exactly for the reasons you describe. The problem is the fact that I was interleaving the mysql_fetch with echo. However, I do not believe it is simply an 'adding the latency'. The two reasons this is probably not the case are because 1) the timing measures I made where from within the code, not by watching the browser, so I knew exactly the time it was taking. Secondly, the mysql server and the web client are co-located (i.e. in my house) and the latency between web server + mysql server would be the same as between web server + web browser, of which I know with high confidence is never as long as the timings would indicate. And actually a third reason for knowing it isn't simply latency is because, when I did perform all the data fetching before doing any output, the times decreased by a factor of 1000: from on order 1 to 6 seconds per fetch down to around .0001 second per fetch. This order of magnitude of difference is too much for simply latency. Nevertheless, clearly the mixing of I/O between the mysql connection and the web client creates a HUGH impact on the php efficiency. Thanks for the discussion!!! This got the job done!!! Question is now: is this a mysql library issue or a php/mysql interaction issue...will make sure the php and mysql folks know this (which they may already know about, I just didn't). Thank you Thank you! jde Brent Baisley wrote: You're also writing out to screen as you get the data, so you may be adding the latency from the web server to the client on top of your data fetching. You can probably get a boost by getting all the data into PHP first and then formatting and sending it to the client. At a minimum you should be able to determine if the client is the big slow down. Matthew Vos Systems Analyst Product Development Techcom Software Solutions Inc. 416.398.5764 [EMAIL PROTECTED] * * * * * * * * * * This message contains information from Techcom Software Solutions Inc. which is confidential and privileged. If you are not an intended recipient, please refrain from any disclosure, copying, distribution or use of this information and note that such actions are prohibited. If you have received this transmission in error, please notify [EMAIL PROTECTED]. This message and any attachments have been scanned for viruses. This message has been digitally signed to ensure authenticity. Key ID: CFEA28EC Fingerprint: 009F E13D 0450 55AF DC1C 4D77 1FE9 0DBB CFEA 28EC signature.asc Description: This is a digitally signed message part
Re: [PHP-DB] Creating temp tables in MSSQL
Hi Frank. When does this table get deleted? when the DB connection closes or does one have to run a process to clear the temp tables? Thanks, Matt On Tue, 2003-12-16 at 17:29, Frank M. Kromann wrote: Hi, Any table that starts with # is a temp table. You can use create table #mytemp (...) or you should be able to use the query you suggest. You just have to make sure you have enough space in tempdb (a system database) - Frank Hi all, I've been handed a query which I'm trying to get to work. I'm using PHP to talk to MSSQL 7. My question is this: Can I create temp tables with mssql without executing the code in a stored procedure? The simplified version of the query is as follows: $query = SELECT distinct convert(varchar(36),traineeID); $query.= INTO #tempdata1; $query.= FROMtblSignIn_trainee a; Later on I could make a stored procedure, but at the moment I would like to just work with the query directly in the code if at all possible. Thanks, John -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Matthew Vos Systems Analyst Product Development Techcom Software Solutions Inc. 416.398.5764 [EMAIL PROTECTED] * * * * * * * * * * This message contains information from Techcom Software Solutions Inc. which is confidential and privileged. If you are not an intended recipient, please refrain from any disclosure, copying, distribution or use of this information and note that such actions are prohibited. If you have received this transmission in error, please notify [EMAIL PROTECTED]. This message and any attachments have been scanned for viruses. This message has been digitally signed to ensure authenticity. Key ID: CFEA28EC Fingerprint: 009F E13D 0450 55AF DC1C 4D77 1FE9 0DBB CFEA 28EC signature.asc Description: This is a digitally signed message part
Re: [PHP-DB] MySQL Query not working via PHP
I would say try single quotes instead of double quotes ... let me know if that works ... Regards, Matt. - Original Message - From: Sean Smitz [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, October 17, 2003 4:32 PM Subject: [PHP-DB] MySQL Query not working via PHP I have a query that works in MySQL but when I try to execute it in PHP I encounter the following error: //Generated by the script Couldn't execute query! // Generated by MySQL MySQL reports: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM cadet, cadet_phone WHERE cadet.ssn = cadet_phone.ssn AND ( //Query outputted by the script Query was: SELECT cadet.rank, cadet.lname, cadet.fname, cadet.mname, cadet.address1, cadet.address2, cadet.city, cadet.state, cadet.zipcode, cadet.email, cadet.guardian1, cadet.relation1, cadet.guardian2, cadet.realtion2, cadet.photo, FROM cadet, cadet_phone WHERE cadet.ssn = cadet_phone.ssn AND (cadet.lname = Smith AND cadet.fname = John AND cadet.mname = Doe) Attached is the entire page. Any help is appreciated. Sean Smitz -- 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] CONGRATULATIONS You Win
So does this mean we all won? lol On Thu, 2003-10-09 at 18:37, Francis Weeny wrote: SUNSWEETWIN PROMO LOTTERY,THE NETHERLANDS. ALFONSTRAAT B56, 1002 BS AMSTERDAM, THE NETHERLANDS. TO THE MANAGER FROM: THE DESK OF THE PROMOTIONS MANAGER, INTERNATIONAL PROMOTIONS/PRIZE AWARD DEPARTMENT, REF: OYL /26510460037/02 BATCH: 24/00319/IPD ATTENTION: RE/ AWARD NOTIFICATION; FINAL NOTICE We are pleased to inform you of the announcement today, 9th October 2003 of winners of the SUNSWEETWIN PROMO LOTTERY,THE NETHERLANDS/ INTERNATIONAL, PROGRAMS held on 28th August 2003 Your company,is attached to ticket number 023-0148-790-459, with serial number 5073-11 drew the lucky numbers 43-11-44-37-10-43, and consequently won the lottery in the 3rd category. You have therefore been approved for a lump sum pay out of US$5,500.000.00 in cash credited to file REF NO. OYL/25041238013/02. This is from total prize money of US$80,400,000.00 shared among the seventeen international winners in this category. All participants were selected through a computer ballot system drawn form 25,000 names from Australia, New Zealand, America, Europe, North America and Asia as part of International Promotions Program, which is conducted annually. CONGRATULATIONS! Your fund is now deposited with a Security company insured in your name. Due to the mix up of some numbers and names, we ask that you keep this award strictly from public notice until your claim has been processed and your money remitted to your account. This is part of our security protocol to avoid double claiming or unscrupulous acts by participants of this program. We hope with a part of you prize, you will participate in our end of year high stakes US$1.3 billion International Lottery. To begin your claim, please contact your claim agent; Mr Francis weeny at this email address below. [EMAIL PROTECTED] For due processing and remittance of your prize money to a designated account of your choice. Remember, all prize money must be claimed not later than19th October 2003. After this date, all funds will be returned as unclaimed. NOTE: In order to avoid unnecessary delays and complications, please remember to quote your reference and batch numbers in every one of your orrespondences with your agent. Furthermore, should there be any change of your address, do inform your claims agent as soon as possible. Congratulations again from all our staff and thank you for being part of our promotions program. Sincerely, Clark Wood THE PROMOTIONS MANAGER, SUNSWEETWIN PROMO LOTTERY,THE NETHERLANDS. NB. Any breach of confidentiality on the part of the winners will result to disqualification. SORRY FOR THE LATE INFORMATION THANKS CLARK WOOD -- Matthew Moldvan [EMAIL PROTECTED] Trilogy International, Inc. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] serving up images
I have about 25 or so images that I would like to serve up on my site's home page. I would like the image to change every 3 days or so. Does anyone have a hint as to how I might go about doing this in a simple fashion? I don't want it to be random, but I do want it to cycle through the images and then start over again. Some initial thoughts: I could just set up a custom index rather than a simple series (1,2,3...). I could then serve up the image that matches the current day of the month or matches a day range. But this gets tricky because I don't have exactly 31 images, and there are obviously shorter months. AND, I want to be able to enter more images without breaking the code. I could do it randomly, and also store an exclusion list, so every three days, my page gets a new random image whose index is not stored in this exclusion list. This seems like the most likely approach, but sounds like extra work. Any ideas? tnks Matthew J. Horn Principal Spielboy.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Host check?
- Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, August 20, 2003 1:24 PM Subject: [PHP-DB] Host check? http://www.beamhost.co.uk/hosting.html I'm moving hosts with our site at work... I found these guys and am very impressed. Has anyone had any dealings with them? Know if they are any good? Have not used them but their marketing does look good. I've been a satisfied customer of www.supanames.co.uk for the past year. Their prices are great (value host pro £23.99 p.a.). Only sticking point is that they are always 6+ months behind the lastest versions of php and mysql... the price of stability. Still, it could be more money in your pocket. Tris... * The information contained in this e-mail message is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail, and delete the original message. *** --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.510 / Virus Database: 307 - Release Date: 14/08/2003 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] % operator
Well, it looks like your previous response was correct, but $a%$b in this case returns 4, not the 0.8 as intended ... fmod($a, $b) (I have php 4.1.2, so I can't test fmod()) will probably return 0.8 though. As a side note, this message seems a little off-topic ... though it is PHP, it has nothing to do with databases. :) Regards, Matt. -Original Message- From: Andrew D. Luebke [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 12, 2003 3:04 PM To: 'Alain Barthélemy'; php-db Subject: RE: [PHP-DB] % operator Although now that I look at: http://us4.php.net/manual/en/language.operators.arithmetic.php You'll see that $a % $b resturns the modulus so that is probably the easiest. Andrew, At 11:43 AM 8/12/2003, you wrote: There's probably a better way to do this, but to retrieve only the 0.8 from 24/5 try this: ($a/$b)-floor($a/$b) Regards, Matt. -Original Message- From: Alain Barthélemy [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 12, 2003 5:05 AM To: php-db Subject: [PHP-DB] % operator Hello, If you have $a = 24; $b = 5; and $c = $a/$b; === $c = 4.8 To retrieve the .8 (reste in french) I saw instruction: $a%$b Where can I find a manual for this '%' operator? Of course I already looked in all the Php manuals (operators, etc ...). Thanks, -- Alain Barthélemy [EMAIL PROTECTED] http://bartydeux.be Linux User #315631 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] % operator
There's probably a better way to do this, but to retrieve only the 0.8 from 24/5 try this: ($a/$b)-floor($a/$b) Regards, Matt. -Original Message- From: Alain Barthélemy [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 12, 2003 5:05 AM To: php-db Subject: [PHP-DB] % operator Hello, If you have $a = 24; $b = 5; and $c = $a/$b; === $c = 4.8 To retrieve the .8 (reste in french) I saw instruction: $a%$b Where can I find a manual for this '%' operator? Of course I already looked in all the Php manuals (operators, etc ...). Thanks, -- Alain Barthélemy [EMAIL PROTECTED] http://bartydeux.be Linux User #315631 -- 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] PHP MSSQL
Shaun, the MySQL manual suggests that you have hit your limit using the VARCHAR field type (255 characters). To store 6,000 characters have you not considered using the TEXT field type? 6.2.3.1 The CHAR and VARCHAR Types The CHAR and VARCHAR types are similar, but differ in the way they are stored and retrieved. The length of a CHAR column is fixed to the length that you declare when you create the table. The length can be any value between 1 and 255. (As of MySQL Version 3.23, the length of CHAR may be 0 to 255.) When CHAR values are stored, they are right-padded with spaces to the specified length. When CHAR values are retrieved, trailing spaces are removed. Values in VARCHAR columns are variable-length strings. You can declare a VARCHAR column to be any length between 1 and 255, just as for CHAR columns. However, in contrast to CHAR, VARCHAR values are stored using only as many characters as are needed, plus one byte to record the length. Values are not padded; instead, trailing spaces are removed when values are stored. (This space removal differs from the SQL-99 specification.) No case conversion takes place during storage or retrieval. If you assign a value to a CHAR or VARCHAR column that exceeds the column's maximum length, the value is truncated to fit. - Original Message - From: Shaun Bentley [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, August 11, 2003 11:23 AM Subject: [PHP-DB] PHP MSSQL Hi I am currently trying to use PHP and MSSQL together but I am having a few problems. I can enter data into the Db OK, but when pulling the data back to display on the page, the string cuts to around 250 chars. The Db field is VarChar 6000 and I can see the whole data in the field. I have tried pulling the data out as object, array row but always lose the end. Any help please! Shaun -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.506 / Virus Database: 303 - Release Date: 01/08/2003 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] subtracting dates...
In mySQL, I store dates as -MM-DD, a standard DATE type. It stores users date of births. I need to calculate in a PHP script, the users age from this DOB. I get a PHP date in the same format as the mySQL and subtract, which returns the year rounded off. ie, it doesnt matter if your birthdays in june of 1983 and the date is januray 2003, your age is still returned as 20, when it should be 19. Does anyone know how can i get the right age? Okay, so you just want to know the age in years. Must you use php? Here is a solution using mysql : SELECT name, dob, CURDATE() as today, ( YEAR(CURDATE()) - YEAR(dob) ) + LEAST( SIGN( DAYOFYEAR(CURDATE()) - DAYOFYEAR(dob) ), 0) as age_in_years FROM test_age; Here is the output : +--+++--+ | name | dob| today | age_in_years | +--+++--+ | jim | 1990-08-02 | 2003-08-03 | 13 | | paul | 1990-08-03 | 2003-08-03 | 13 | | tom | 1990-08-04 | 2003-08-03 | 12 | | matt | 1990-09-01 | 2003-08-03 | 12 | | sam | 1990-12-31 | 2003-08-03 | 12 | | sam | 1991-01-01 | 2003-08-03 | 12 | | sam | 1991-07-02 | 2003-08-03 | 12 | | sam | 1991-08-02 | 2003-08-03 | 12 | | sam | 1991-09-02 | 2003-08-03 | 11 | +--+++--+ 9 rows in set (0.01 sec) Here is how I generated my test data : DROP TABLE IF EXISTS test_age; CREATE TABLE test_age ( id int(6) NOT NULL auto_increment, name varchar(20) default NULL, dob date default NULL, PRIMARY KEY (id) ) TYPE=MyISAM; INSERT INTO test_age (id, name, dob) VALUES ('', 'jim', '1990-08-02'); INSERT INTO test_age (id, name, dob) VALUES ('', 'paul', '1990-08-03'); INSERT INTO test_age (id, name, dob) VALUES ('', 'tom', '1990-08-04'); INSERT INTO test_age (id, name, dob) VALUES ('', 'matt', '1990-09-01'); INSERT INTO test_age (id, name, dob) VALUES ('', 'sam', '1990-12-31'); INSERT INTO test_age (id, name, dob) VALUES ('', 'sam', '1991-01-01'); INSERT INTO test_age (id, name, dob) VALUES ('', 'sam', '1991-07-02'); INSERT INTO test_age (id, name, dob) VALUES ('', 'sam', '1991-08-02'); INSERT INTO test_age (id, name, dob) VALUES ('', 'sam', '1991-09-02'); -Original Message- From: John Ryan [mailto:[EMAIL PROTECTED] Sent: Saturday, August 02, 2003 2:31 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: [PHP-DB] subtracting dates... Hi, In mySQL, I store dates as -MM-DD, a standard DATE type. It stores users date of births. I need to calculate in a PHP script, the users age from this DOB. I get a PHP date in the same format as the mySQL and subtract, which returns the year rounded off. ie, it doesnt matter if your birthdays in june of 1983 and the date is januray 2003, your age is still returned as 20, when it should be 19. Does anyone know how can i get the right age? -- 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 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.506 / Virus Database: 303 - Release Date: 01/08/2003 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php