RE: [PHP-DB] MySQL query failing on apostrophe in data
try putting a \ before the apostrophe -Original Message- From: Dillon, John [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 27, 2003 12:59 PM To: 'PHP-DB' Subject: [PHP-DB] MySQL query failing on apostrophe in data How do I avoid the problem in the subject hereto? SELECT query uses variable in the WHERE clause. Fails on the following query: SELECT Tbl.fld FROM Tbl WHERE Tbl.fld2='11301201 0603A HKA 3902 #3708_JD's AE Exp' AND ... John http://www.cantor.com CONFIDENTIAL: This e-mail, including its contents and attachments, if any, are confidential. If you are not the named recipient please notify the sender and immediately delete it. You may not disseminate, distribute, or forward this e-mail message or disclose its contents to anybody else. Copyright and any other intellectual property rights in its contents are the sole property of Cantor Fitzgerald. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. Although we routinely screen for viruses, addressees should check this e-mail and any attachments for viruses. We make no representation or warranty as to the absence of viruses in this e-mail or any attachments. Please note that to ensure regulatory compliance and for the protection of our customers and business, we may monitor and read e-mails sent to and from our server(s). For further important information, please read the Important Legal Information and Legal Statement at http://www.cantor.com/legal_information.html -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL query failing on apostrophe in data
> How do I avoid the problem in the subject hereto? SELECT query uses > variable in the WHERE clause. Fails on the following query: > > SELECT Tbl.fld FROM Tbl WHERE Tbl.fld2='11301201 0603A HKA 3902 #3708_JD's > AE Exp' AND ... Escape it. SELECT Tbl.fld FROM Tbl WHERE Tbl.fld2='11301201 0603A HKA 3902 #3708_JD\'s AE Exp' AND ... Use mysql_escape_string() or addslashes() http://www.php.net/manual/en/function.mysql-escape-string.php http://www.php.net/manual/en/function.addslashes.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL, PHP or ghost?
Yeah, but Peter stated that he entered year="" and the query inserted 2000 in the column. > > mysql> update plate set year="" where pid=65; > > Query OK, 1 row affected (0.01 sec) > > Rows matched: 1 Changed: 1 Warnings: 1 > > > > mysql> select * from plate where pid=65; > > +-+-+--+- > > | pid | plate | year | > > +-+-+--+- > > | 65 | DVF0343 | 2000 | > > +-+-+--+- If year="" is converted to the integer 0 as you state, then, according to the MySQL manual, it should have inserted into the database, not 2000. See below: >From the MySql Manual: "As a two-digit number in the range 1 to 99. Values in the ranges 1 to 69 and 70 to 99 are converted to YEAR values in the ranges 2001 to 2069 and 1970 to 1999. Note that the range for two-digit numbers is slightly different than the range for two-digit strings, because you cannot specify zero directly as a number and have it be interpreted as 2000. You must specify it as a string '0' or '00' or it will be interpreted as ." So it looks like an empty string, year="" is actually converted to the STRING 0, resulting in the value 2000 being inserted into the table. According to the manual, the YEAR type expects/requires either a two or four digit integer or a two or four digit number as a string. If it gets anything else, it's supposed to spit out . Therefore, instead of converting Peter's year="" to something else, it should just insert . It sounds like a small bug in the way the YEAR type handles data. Maybe a search through the MySQL bug list would yield something in the way of an explanation. I'm just as puzzled by this as Peter is/was and I'm just interested in the explanation. I'm not trying to start an argument here. Rich > -----Original Message- > From: Ignatius Reilly [mailto:[EMAIL PROTECTED] > Sent: Wednesday, August 27, 2003 9:31 AM > To: Peter Beckman; [EMAIL PROTECTED] > Subject: Re: [PHP-DB] MySQL, PHP or ghost? > > > Read the MySQL manual. > > "0" value is interpreted as 2000. > Your empty string is converted to an integer, thus 0. > > HTH > Ignatius > _ > - Original Message - > From: "Peter Beckman" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, August 27, 2003 3:39 AM > Subject: [PHP-DB] MySQL, PHP or ghost? > > > > Seems that either I don't understand mysql, or something. > > > > My table, with the non-important things removed... > > > > mysql> explain plate; > > > +-+---+--+-+-- > ---+-- > --+ > > | Field | Type | Null | Key | > Default | > Extra | > > > +-+---+--+-+-- > ---+-- > --+ > > | pid | mediumint(8) unsigned | | PRI | NULL > | > auto_increment | > > | year| year(4) | YES | | NULL > | > | > > [...] > > > > So my assumption is that if I insert with year="" it should use the > > default. Or at least . > > > > mysql> update plate set year=NULL where pid=65; > > Query OK, 1 row affected (0.00 sec) > > Rows matched: 1 Changed: 1 Warnings: 0 > > > > mysql> select * from plate where pid=65; > > +-+-+--+- > > | pid | plate | year | > > +-+-+--+- > > | 65 | DVF0343 | NULL | > > +-+-+--+- > > > > But if I do this: > > > > mysql> update plate set year="" where pid=65; > > Query OK, 1 row affected (0.01 sec) > > Rows matched: 1 Changed: 1 Warnings: 1 > > > > mysql> select * from plate where pid=65; > > +-+-+--+- > > | pid | plate | year | > > +-+-+--+- > > | 65 | DVF0343 | 2000 | > > +-+-+--+- > > > > 2000? What? Why? Confused. PHP or Mysql fault? > > > > Beckman > > > -- > > - > > Peter Beckman >Internet > Guy > > [EMAIL PROTECTED] > http://www.purplecow.com/ > > > -- > > - > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MySQL query failing on apostrophe in data
How do I avoid the problem in the subject hereto? SELECT query uses variable in the WHERE clause. Fails on the following query: SELECT Tbl.fld FROM Tbl WHERE Tbl.fld2='11301201 0603A HKA 3902 #3708_JD's AE Exp' AND ... John http://www.cantor.com CONFIDENTIAL: This e-mail, including its contents and attachments, if any, are confidential. If you are not the named recipient please notify the sender and immediately delete it. You may not disseminate, distribute, or forward this e-mail message or disclose its contents to anybody else. Copyright and any other intellectual property rights in its contents are the sole property of Cantor Fitzgerald. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. Although we routinely screen for viruses, addressees should check this e-mail and any attachments for viruses. We make no representation or warranty as to the absence of viruses in this e-mail or any attachments. Please note that to ensure regulatory compliance and for the protection of our customers and business, we may monitor and read e-mails sent to and from our server(s). For further important information, please read the Important Legal Information and Legal Statement at http://www.cantor.com/legal_information.html -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL, PHP or ghost?
On Wed, 27 Aug 2003, Ruprecht Helms wrote: > you have chosen a wrong format. The format for year is . With string > the field years don't know what to do. Right -- and if it doesn't know what to do, why would it insert a value that isn't correct and not give me an error? It does give a warning, but I haven't figured out how to view the warnings (or detect them) in PHP, much less in MySQL. Thanks to all who responded -- I wanted to make sure it was a MySQL thing rather than a PHP thing before I posted on the MySQL lists. Beckman --- Peter Beckman Internet Guy [EMAIL PROTECTED] http://www.purplecow.com/ --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL, PHP or ghost?
It dosent say this in the docs but I presume its because you need to pass the value as a string or the value will result in , which in year terms is wrong because there never was a year . I guess their reasoning is that if you have passed a "" then you havent broken this rule and so it shouldnt default to a none existant year, i.e. . like i said, its not in the docs (at least I couldnt find anything in the time / dates part), if you feel its important you could maybe insert a comment in the the YEAR section of the docs. -Original Message- From: Peter Beckman [mailto:[EMAIL PROTECTED] Sent: 27 August 2003 15:29 To: Griffiths, Daniel Subject: RE: [PHP-DB] MySQL, PHP or ghost? On Wed, 27 Aug 2003, Griffiths, Daniel wrote: > mysql will default to 2000 for a year value if you pass it "" as an entry > because it will accept short values for the years this century, eg pass > it "1" and it'll give you 2001, so it thinks "" is nothing. if you want > to default to this year pass it NOW(). I guess that's why I'm confused. An empty quoted string shouldn't assume that I mean "0"; if I meant "0" I would enter "0". It should assume I mean to make it nothing, and by nothing I mean an unquoted 0, or . I just want to know where in the manual it says that passing YEAR an empty quoted value will cause MySQL to understand that value as a quoted "0" and then make the year 2000. It's not in the YEAR section. Beckman --- Peter Beckman Internet Guy [EMAIL PROTECTED] http://www.purplecow.com/ --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL, PHP or ghost?
Hi Peter Beckman, > Seems that either I don't understand mysql, or something. > > My table, with the non-important things removed... > > mysql> explain plate; > > +-+---+--+-+-++ > | Field | Type | Null | Key | Default | Extra > | > > +-+---+--+-+-++ > | pid | mediumint(8) unsigned | | PRI | NULL| > auto_increment | > | year| year(4) | YES | | NULL| > | > [...] > > mysql> select * from plate where pid=65; > +-+-+--+- > | pid | plate | year | > +-+-+--+- > | 65 | DVF0343 | NULL | > +-+-+--+- > > But if I do this: > > mysql> update plate set year="" where pid=65; > Query OK, 1 row affected (0.01 sec) > Rows matched: 1 Changed: 1 Warnings: 1 > > mysql> select * from plate where pid=65; > +-+-+--+- > | pid | plate | year | > +-+-+--+- > | 65 | DVF0343 | 2000 | > +-+-+--+- > you have chosen a wrong format. The format for year is . With string the field years don't know what to do. Regards, Ruprecht --- Ruprecht Helms IT-Service & Softwareentwicklung Tel./Fax +49[0]7621 16 99 16 Homepage: http://www.rheyn.de email:[EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL, PHP or ghost?
Peter, et al -- ...and then Peter Beckman said... % % On Wed, 27 Aug 2003, David T-G wrote: % % > Looks like it, though I admit that the manual doesn't adequately explain % > your results. Check out section 6.2.2.4 for details. % % I did; see my previous (moments ago) email on my read on that manual % section. Ah; I will when it comes through :-) % % > % So my assumption is that if I insert with year="" it should use the % > % default. Or at least . % > % > That makes sense. And so what is the default? Looks like it is, for % > some reason, 2000. [This isn't a TIMESTAMP field, so we don't % > necessarily expect it to be "this year".] % % The default at the time was . At the time of the mysql release, you might mean? Certainly at the time of the manual writing... % ... % > Looks like it's standard mysql behavior: % % But that's what I'm questioning. Should it be that way? If so, the % manual page for YEAR should be altered. If it shouldn't work that way, it % should be submitted as a bug. Makes sense. Having removed all php elements, you'd probably get a better answer on the mysql list. HTH & HAND & Good luck! :-D -- David T-G * There is too much animal courage in (play) [EMAIL PROTECTED] * society and not sufficient moral courage. (work) [EMAIL PROTECTED] -- Mary Baker Eddy, "Science and Health" http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg! pgp0.pgp Description: PGP signature
Re: [PHP-DB] MySQL, PHP or ghost?
On Wed, 27 Aug 2003, David T-G wrote: > Looks like it, though I admit that the manual doesn't adequately explain > your results. Check out section 6.2.2.4 for details. I did; see my previous (moments ago) email on my read on that manual section. > % So my assumption is that if I insert with year="" it should use the > % default. Or at least . > > That makes sense. And so what is the default? Looks like it is, for > some reason, 2000. [This isn't a TIMESTAMP field, so we don't > necessarily expect it to be "this year".] The default at the time was . After I saw the problem I changed it to the below, but that didn't solve the problem: | year| year(4) | YES | | NULL| Before the change it was: | year| year(4) | NO | | | > Looks like it's standard mysql behavior: But that's what I'm questioning. Should it be that way? If so, the manual page for YEAR should be altered. If it shouldn't work that way, it should be submitted as a bug. > Note that I sometimes get warnings and sometimes don't. I haven't dug > into them, though. Hmmm. Unfortunately I can't use "show warnings" to show the warnings since I don't have 4.1.0, I have 3.23.49. I can't find the manual on the MySQL site for 3.23.49, just 4.1.1. I've checked the .err file in my /var/db/mysql directory but no avail on the warning. Obviously I shouldn't be using year="", and I've since stopped. However, I do want to learn what is going on and why when given an empty quoted string MySQL translates that to 2000 versus the default value (if not null, ; if null, NULL). Beckman --- Peter Beckman Internet Guy [EMAIL PROTECTED] http://www.purplecow.com/ --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL, PHP or ghost?
its nothing to do with php as your working from the shell in your eg. mysql will default to 2000 for a year value if you pass it "" as an entry because it will accept short values for the years this century, eg pass it "1" and it'll give you 2001, so it thinks "" is nothing. if you want to default to this year pass it NOW(). -Original Message- From: Peter Beckman [mailto:[EMAIL PROTECTED] Sent: 27 August 2003 02:40 To: [EMAIL PROTECTED] Subject: [PHP-DB] MySQL, PHP or ghost? Seems that either I don't understand mysql, or something. My table, with the non-important things removed... mysql> explain plate; +-+---+--+-+-++ | Field | Type | Null | Key | Default | Extra | +-+---+--+-+-++ | pid | mediumint(8) unsigned | | PRI | NULL| auto_increment | | year| year(4) | YES | | NULL| | [...] So my assumption is that if I insert with year="" it should use the default. Or at least . mysql> update plate set year=NULL where pid=65; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from plate where pid=65; +-+-+--+- | pid | plate | year | +-+-+--+- | 65 | DVF0343 | NULL | +-+-+--+- But if I do this: mysql> update plate set year="" where pid=65; Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 1 mysql> select * from plate where pid=65; +-+-+--+- | pid | plate | year | +-+-+--+- | 65 | DVF0343 | 2000 | +-+-+--+- 2000? What? Why? Confused. PHP or Mysql fault? Beckman --- Peter Beckman Internet Guy [EMAIL PROTECTED] http://www.purplecow.com/ --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL, PHP or ghost?
On Wed, 27 Aug 2003, Ignatius Reilly wrote: > Read the MySQL manual. Hmmm, I thought I did. 6.2.2.4: Illegal YEAR values are converted to . > "0" value is interpreted as 2000. > Your empty string is converted to an integer, thus 0. What confuses me (what I can't find) is why a quoted empty string "" is converted to a quoted integer "0" for a YEAR type. Based on the manual, I assumed an empty string is considered an Illegal YEAR and thus converted to . The empty string is NOT converted to an UNQUOTED digit 0, because otherwise the field would be set to (the intended and expected action). You must specify it as a string '0' or '00' or it will be interpreted as . Can you point me to the correct portion of the manual that explains that? What you explain sounds like MySQL is working as designed, but I'm a bit embarrassed that I missed that in the manual, so I want to read up on it. Seems a bit obscure; I've been using mysql for 4+ years and have never came across this. Thanks, Beckman > - Original Message - > From: "Peter Beckman" <[EMAIL PROTECTED]> > > > Seems that either I don't understand mysql, or something. > > > > My table, with the non-important things removed... > > > > mysql> explain plate; > > > +-+---+--+-+-+-- > --+ > > | Field | Type | Null | Key | Default | > Extra | > > > +-+---+--+-+-+-- > --+ > > | pid | mediumint(8) unsigned | | PRI | NULL| > auto_increment | > > | year| year(4) | YES | | NULL| > | > > [...] > > > > So my assumption is that if I insert with year="" it should use the > > default. Or at least . > > > > mysql> update plate set year=NULL where pid=65; > > Query OK, 1 row affected (0.00 sec) > > Rows matched: 1 Changed: 1 Warnings: 0 > > > > mysql> select * from plate where pid=65; > > +-+-+--+- > > | pid | plate | year | > > +-+-+--+- > > | 65 | DVF0343 | NULL | > > +-+-+--+- > > > > But if I do this: > > > > mysql> update plate set year="" where pid=65; > > Query OK, 1 row affected (0.01 sec) > > Rows matched: 1 Changed: 1 Warnings: 1 > > > > mysql> select * from plate where pid=65; > > +-+-+--+- > > | pid | plate | year | > > +-+-+--+- > > | 65 | DVF0343 | 2000 | > > +-+-+--+- > > > > 2000? What? Why? Confused. PHP or Mysql fault? --- Peter Beckman Internet Guy [EMAIL PROTECTED] http://www.purplecow.com/ --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL, PHP or ghost?
Peter -- ...and then Peter Beckman said... % % Seems that either I don't understand mysql, or something. Looks like it, though I admit that the manual doesn't adequately explain your results. Check out section 6.2.2.4 for details. % % My table, with the non-important things removed... ... % % So my assumption is that if I insert with year="" it should use the % default. Or at least . That makes sense. And so what is the default? Looks like it is, for some reason, 2000. [This isn't a TIMESTAMP field, so we don't necessarily expect it to be "this year".] % ... % mysql> update plate set year="" where pid=65; ... % +-+-+--+- % | 65 | DVF0343 | 2000 | % +-+-+--+- % % 2000? What? Why? Confused. PHP or Mysql fault? Looks like it's standard mysql behavior: mysql> create table ytest (pid int unsigned not null auto_increment primary key, y year(4)); Query OK, 0 rows affected (0.00 sec) mysql> describe ytest; +---+--+--+-+-++ | Field | Type | Null | Key | Default | Extra | +---+--+--+-+-++ | pid | int(10) unsigned | | PRI | NULL| auto_increment | | y | year(4) | YES | | NULL|| +---+--+--+-+-++ 2 rows in set (0.00 sec) mysql> insert into ytest values ('',1),('',''),('','2000'); Query OK, 3 rows affected (0.00 sec) Records: 3 Duplicates: 0 Warnings: 4 mysql> select * from ytest; +-+--+ | pid | y| +-+--+ | 1 | 2001 | | 2 | 2000 | | 3 | 2000 | +-+--+ 3 rows in set (0.00 sec) mysql> update ytest set y = "" where pid = 3; Query OK, 0 rows affected (0.00 sec) Rows matched: 1 Changed: 0 Warnings: 1 mysql> select * from ytest; +-+--+ | pid | y| +-+--+ | 1 | 2001 | | 2 | 2000 | | 3 | 2000 | +-+--+ 3 rows in set (0.00 sec) mysql> update ytest set y = '0' where pid =3 ; Query OK, 0 rows affected (0.00 sec) Rows matched: 1 Changed: 0 Warnings: 0 mysql> update ytest set y = '45678' where pid = 2; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 1 mysql> select * from ytest; +-+--+ | pid | y| +-+--+ | 1 | 2001 | | 2 | | | 3 | 2000 | +-+--+ 3 rows in set (0.00 sec) Note that I sometimes get warnings and sometimes don't. I haven't dug into them, though. % % Beckman % --- % Peter Beckman Internet Guy % [EMAIL PROTECTED] http://www.purplecow.com/ % --- HTH & HAND :-D -- David T-G * There is too much animal courage in (play) [EMAIL PROTECTED] * society and not sufficient moral courage. (work) [EMAIL PROTECTED] -- Mary Baker Eddy, "Science and Health" http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg! pgp0.pgp Description: PGP signature
Re: [PHP-DB] MySQL, PHP or ghost?
Read the MySQL manual. "0" value is interpreted as 2000. Your empty string is converted to an integer, thus 0. HTH Ignatius _ - Original Message - From: "Peter Beckman" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, August 27, 2003 3:39 AM Subject: [PHP-DB] MySQL, PHP or ghost? > Seems that either I don't understand mysql, or something. > > My table, with the non-important things removed... > > mysql> explain plate; > +-+---+--+-+-+-- --+ > | Field | Type | Null | Key | Default | Extra | > +-+---+--+-+-+-- --+ > | pid | mediumint(8) unsigned | | PRI | NULL| auto_increment | > | year| year(4) | YES | | NULL| | > [...] > > So my assumption is that if I insert with year="" it should use the > default. Or at least . > > mysql> update plate set year=NULL where pid=65; > Query OK, 1 row affected (0.00 sec) > Rows matched: 1 Changed: 1 Warnings: 0 > > mysql> select * from plate where pid=65; > +-+-+--+- > | pid | plate | year | > +-+-+--+- > | 65 | DVF0343 | NULL | > +-+-+--+- > > But if I do this: > > mysql> update plate set year="" where pid=65; > Query OK, 1 row affected (0.01 sec) > Rows matched: 1 Changed: 1 Warnings: 1 > > mysql> select * from plate where pid=65; > +-+-+--+- > | pid | plate | year | > +-+-+--+- > | 65 | DVF0343 | 2000 | > +-+-+--+- > > 2000? What? Why? Confused. PHP or Mysql fault? > > Beckman > -- - > Peter Beckman Internet Guy > [EMAIL PROTECTED] http://www.purplecow.com/ > -- - > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MySQL, PHP or ghost?
Seems that either I don't understand mysql, or something. My table, with the non-important things removed... mysql> explain plate; +-+---+--+-+-++ | Field | Type | Null | Key | Default | Extra | +-+---+--+-+-++ | pid | mediumint(8) unsigned | | PRI | NULL| auto_increment | | year| year(4) | YES | | NULL| | [...] So my assumption is that if I insert with year="" it should use the default. Or at least . mysql> update plate set year=NULL where pid=65; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from plate where pid=65; +-+-+--+- | pid | plate | year | +-+-+--+- | 65 | DVF0343 | NULL | +-+-+--+- But if I do this: mysql> update plate set year="" where pid=65; Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 1 mysql> select * from plate where pid=65; +-+-+--+- | pid | plate | year | +-+-+--+- | 65 | DVF0343 | 2000 | +-+-+--+- 2000? What? Why? Confused. PHP or Mysql fault? Beckman --- Peter Beckman Internet Guy [EMAIL PROTECTED] http://www.purplecow.com/ --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Mysql Query
Hi guys, I have been working in php/oracle for quite some time now but recently had to shift myself to mysql and I am struggling with a particular query here. Scenario is, certain researchers can submit their proposals and those proposal are stored in a table researcher. proposals are of 2 types lets say type 1 and type 2. Later they can view their own submited proposals which is working fine, but there is one new condition now.What my client wants is that these researchers can view all proposals of type 2 but only those proposals of type 1 should be displayed to a researcher whose submit date is greater than a certain date lets say '2003-08-01'. Now how do I create a single query which can return me such results. I know there is a way with join but cant find a solution, with oracle I would have used sub query but that cannot be done on mysql so I need your guys help thanks Table name: researcher Concerned fields pid <-- porposal id rid <-- researcher id ptype <--- proposal type submitd <-- submission date. I would use rid = 42 and for ptype = 1 submitd should be greater than '2003-08-01' and there is no restriction of date with ptype =2. Thanks again. if there is something not clear feel free to ask
RE: [PHP-DB] MYSQL 4.1 derived tables and PHP
Hi THX I added mysql_error() to get the error message. I got the message that the user did not have rights on table /tmp/dbla.bla I figured that I must give some more global read rights to this user (not just DB read rights). After that it worked. THX Jack -Original Message- From: CPT John W. Holmes [mailto:[EMAIL PROTECTED] Sent: Friday, August 22, 2003 4:11 PM To: Jack van Zanen Prive; [EMAIL PROTECTED] Subject: Re: [PHP-DB] MYSQL 4.1 derived tables and PHP From: "Jack van Zanen" <[EMAIL PROTECTED]> > I have installed MYSQL 4.1 with support for derived tables. If I query Mysql > with a query that has a subquery in the from clause it works fine. If > I now > load this query in PHP I get invalid resource error. If I change the select > for another select w/o the subquery it works fine (So my php script > must be > correct). > > Does PHP do syntax checking before sending the query to mysql? Any > other solution? I have tried PHP 4.3.2/4.3.3 & 5.0 What does mysql_error() say? ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MYSQL 4.1 derived tables and PHP
From: "Jack van Zanen" <[EMAIL PROTECTED]> > I have installed MYSQL 4.1 with support for derived tables. If I query Mysql > with a query that has a subquery in the from clause it works fine. If I now > load this query in PHP I get invalid resource error. If I change the select > for another select w/o the subquery it works fine (So my php script must be > correct). > > Does PHP do syntax checking before sending the query to mysql? > Any other solution? > I have tried PHP 4.3.2/4.3.3 & 5.0 What does mysql_error() say? ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MYSQL 4.1 derived tables and PHP
Hi List, I have installed MYSQL 4.1 with support for derived tables. If I query Mysql with a query that has a subquery in the from clause it works fine. If I now load this query in PHP I get invalid resource error. If I change the select for another select w/o the subquery it works fine (So my php script must be correct). Does PHP do syntax checking before sending the query to mysql? Any other solution? I have tried PHP 4.3.2/4.3.3 & 5.0 TIA Jack -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql date select statement
hav u tried using dashes to denote which portion is the year, month, or day ? e.g. instead of 20030101, you'd probably want to use 2003-01-01. Wendell Frohwein wrote: Hello all, I have this page where I search and add up commissions in a mysql database. I want to select commissions between a certain date range. This is what im currently using but it does not seem to work. $from="20030101"; $to="20031230"; $search=mysql_query("SELECT SUM(amount) FROM commissions WHERE date BETWEEN '$from' AND '$to'"); Thanks in advance for any help wendell -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql date select statement
Wendell Frohwein wrote: Hello all, I have this page where I search and add up commissions in a mysql database. I want to select commissions between a certain date range. This is what im currently using but it does not seem to work. $from="20030101"; $to="20031230"; $search=mysql_query("SELECT SUM(amount) FROM commissions WHERE date BETWEEN '$from' AND '$to'"); Always use mysql_error() with your queries to see the error. You do not have a GROUP BY clause in your query, so it's failing. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ PHP|Architect: A magazine for PHP Professionals – www.phparch.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] mysql date select statement
Hello all, I have this page where I search and add up commissions in a mysql database. I want to select commissions between a certain date range. This is what im currently using but it does not seem to work. $from="20030101"; $to="20031230"; $search=mysql_query("SELECT SUM(amount) FROM commissions WHERE date BETWEEN '$from' AND '$to'"); Thanks in advance for any help wendell
Re: [PHP-DB] MySQL Returns Error
I'm unsure of both suggestions, can someone go into more detail? "Richard Hutchins" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > So create a hidden input field on the page called cur_id and set its value > to the id of the record being displayed. If no record is currently being > displayed, set it to -1. > > When you get ready to handle the form data, check the $_POST['cur_id'] > variable. If it's set to -1, perform an INSERT. If it's set to anything > else, perform an UPDATE using the value of $_POST['cur_id'] in your WHERE > clause. > > I'm sure there are other ways to handle this. This is how I have handled it > in the past though. > > > -Original Message- > > From: Jeff [mailto:[EMAIL PROTECTED] > > Sent: Tuesday, August 05, 2003 3:52 PM > > To: [EMAIL PROTECTED] > > Subject: Re: [PHP-DB] MySQL Returns Error > > > > > > Oops, my mistake, it's not a blank entry - it re enters the > > last entry. > > > > I can hit F5 or click refresh 1000 times and it will enter > > the last entry > > 1000 times. > > > > > > "Jeff" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > I tried putting that in a few diffrent places, same result > > - is there > > > somewhere special I need to put that? > > > > > > "Matt Schroebel" <[EMAIL PROTECTED]> wrote in message > > > news:[EMAIL PROTECTED] > > > > > > > > > > -Original Message- > > > > From: Jeff [mailto:[EMAIL PROTECTED] > > > > Sent: Tuesday, August 05, 2003 3:15 PM > > > > To: [EMAIL PROTECTED] > > > > Subject: Re: [PHP-DB] MySQL Returns Error > > > > > > > > Every time I access or refresh the page, it adds one blank > > > > entry to the DB. > > > > > > > > Maybe I have the insert query in the wrong place? > > > > > > if ('POST' == $_SERVER['REQUEST_METHOD']) { > > > //someone submitted the form with method="post" > > > // so validate input, and if okay store it in db > > > } > > > > > > > > > > > > > > -- > > 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] MySQL Returns Error
Oops, my mistake, it's not a blank entry - it re enters the last entry. I can hit F5 or click refresh 1000 times and it will enter the last entry 1000 times. "Jeff" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I tried putting that in a few diffrent places, same result - is there > somewhere special I need to put that? > > "Matt Schroebel" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > > > -Original Message- > > From: Jeff [mailto:[EMAIL PROTECTED] > > Sent: Tuesday, August 05, 2003 3:15 PM > > To: [EMAIL PROTECTED] > > Subject: Re: [PHP-DB] MySQL Returns Error > > > > Every time I access or refresh the page, it adds one blank > > entry to the DB. > > > > Maybe I have the insert query in the wrong place? > > if ('POST' == $_SERVER['REQUEST_METHOD']) { > //someone submitted the form with method="post" > // so validate input, and if okay store it in db > } > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL Returns Error
I tried putting that in a few diffrent places, same result - is there somewhere special I need to put that? "Matt Schroebel" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > -Original Message- > From: Jeff [mailto:[EMAIL PROTECTED] > Sent: Tuesday, August 05, 2003 3:15 PM > To: [EMAIL PROTECTED] > Subject: Re: [PHP-DB] MySQL Returns Error > > Every time I access or refresh the page, it adds one blank > entry to the DB. > > Maybe I have the insert query in the wrong place? if ('POST' == $_SERVER['REQUEST_METHOD']) { //someone submitted the form with method="post" // so validate input, and if okay store it in db } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql problem importing data
You could use mysqlimport with --fields-terminated-by=";" or you could open it in something like Excel, parse it there (text to columns), and save it as a CSV or you could read it line by, line into PHP, explode each line on the ;, then insert the data into MySQL or you could write a script that does a string substitution of ; to , Lots ofother options, too, which I haven't thought of. --- Merlin <[EMAIL PROTECTED]> wrote: > Hi there, > > I have a data file with data seperated by semicolons. It is about > 8MB big. > Now I just want to import it into mysql. > I tryed several things. First I took phpmyadmin, which resulted in > a white > page without error msg. Then I tryed it by hand with load data. > This did not > work as well. No I installed myodbc and tryed to export it from MS > Access. > This completly crashes my database server with this message: > > /usr/local/mysql/bin/safe_mysqld: line 1: 1067 Segmentation fault > nice --5 nohup > /usr/local/mysql/libexec/mysqld --basedir=/usr/local/mysql > --datadir=/home/m > ysqladm/data --user=mysql --pid-file=/home/mysqladm/var/mysqld.pid > --skip-lo > cking -u mysqladm >>/home/mysqladm/data/SARATOGA.err 2>&1 > 030807 00:00:45 mysqld ended > > Has anybody an idea on how to import that data? Its nicely > seperated by ; > > Thanx for any help, > > Merlin > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > = Mark Weinstock [EMAIL PROTECTED] *** You can't demand something as a "right" unless you are willing to fight to death to defend everyone else's right to the same thing. *** __ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MySQL and PHP?
Hello I hope this is a rumour but I heard that MySQL is now fully GPL which it wasn't earlier. I think the part used to communicate with the mysql server was lgpl. Does this mean that when using php with mysql your php scripts have to be licensed under the gpl as well if released? If this is the case what other free sql databases are there that can be used with php? Thanks for reading. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] mysql connect error
Hi Check the database name is exactly the same case as you are using - not Soverign rather soverign for example. After that try the raw php functions for connecting to the database This will give the Mysql error messages which should give you more information HTH, if not comeback to me Peter -Original Message- From: John Byrne [mailto:[EMAIL PROTECTED] Sent: 12 August 2003 08:06 To: [EMAIL PROTECTED] Subject: [PHP-DB] mysql connect error Hi, I've just started playing with Linux/MySQL/PHP - I come from a Windows/ASP/PowerBuilder background. I have created a database in MySQL and now are trying to connect to it via PHP. I keep getting the same error, no matter what I specify in DSN. I always get: DB Error: no such database The following is the PHP code I am using: getMessage()); } $db->disconnect(); ?> This is straight out of the PHP documentation. Any ideas why I get the same error all the time. I am using RedHat 8.0, PHP 4.2.2, MySQL 3.2.53, Apache 2.0 thanks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL and PHP?
posgreSQL -Original Message- From: Richard [mailto:[EMAIL PROTECTED] Sent: Monday, August 11, 2003 1:49 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] MySQL and PHP? Hello I hope this is a rumour but I heard that MySQL is now fully GPL which it wasn't earlier. I think the part used to communicate with the mysql server was lgpl. Does this mean that when using php with mysql your php scripts have to be licensed under the gpl as well if released? If this is the case what other free sql databases are there that can be used with php? Thanks for reading. -- 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] MySQL Returns Error
if i understand your question. why not take a different approach. when the form is submitted do your updates/inserts and then forward the page with the header() function to another page, even if it is the same page, but with a different set of variables set on the page, the idea being to remove the $_POST/$_GET arrays containing your data so at the end of your insert header("Location: ".$_SERVER['PHP_SELF']."?inserted=true"); you can send them from whence they came with header("Location: ".$_SERVER['HTTP_REFERER']); hth jd "Jeff" <[EMAIL PROTECTED]To: [EMAIL PROTECTED] >cc: Subject: Re: [PHP-DB] MySQL Returns Error 08/05/2003 06:41 PM I'm unsure of both suggestions, can someone go into more detail? "Richard Hutchins" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > So create a hidden input field on the page called cur_id and set its value > to the id of the record being displayed. If no record is currently being > displayed, set it to -1. > > When you get ready to handle the form data, check the $_POST['cur_id'] > variable. If it's set to -1, perform an INSERT. If it's set to anything > else, perform an UPDATE using the value of $_POST['cur_id'] in your WHERE > clause. > > I'm sure there are other ways to handle this. This is how I have handled it > in the past though. > > > -Original Message- > > From: Jeff [mailto:[EMAIL PROTECTED] > > Sent: Tuesday, August 05, 2003 3:52 PM > > To: [EMAIL PROTECTED] > > Subject: Re: [PHP-DB] MySQL Returns Error > > > > > > Oops, my mistake, it's not a blank entry - it re enters the > > last entry. > > > > I can hit F5 or click refresh 1000 times and it will enter > > the last entry > > 1000 times. > > > > > > "Jeff" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > I tried putting that in a few diffrent places, same result > > - is there > > > somewhere special I need to put that? > > > > > > "Matt Schroebel" <[EMAIL PROTECTED]> wrote in message > > > news:[EMAIL PROTECTED] > > > > > > > > > > -Original Message- > > > > From: Jeff [mailto:[EMAIL PROTECTED] > > > > Sent: Tuesday, August 05, 2003 3:15 PM > > > > To: [EMAIL PROTECTED] > > > > Subject: Re: [PHP-DB] MySQL Returns Error > > > > > > > > Every time I access or refresh the page, it adds one blank > > > > entry to the DB. > > > > > > > > Maybe I have the insert query in the wrong place? > > > > > > if ('POST' == $_SERVER['REQUEST_METHOD']) { > > > //someone submitted the form with method="post" > > > // so validate input, and if okay store it in db > > > } > > > > > > > > > > > > > > -- > > 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] MySQL Returns Error
> -Original Message- > From: Jeff [mailto:[EMAIL PROTECTED] > Sent: Tuesday, August 05, 2003 3:15 PM > To: [EMAIL PROTECTED] > Subject: Re: [PHP-DB] MySQL Returns Error > > Every time I access or refresh the page, it adds one blank > entry to the DB. > > Maybe I have the insert query in the wrong place? if ('POST' == $_SERVER['REQUEST_METHOD']) { //someone submitted the form with method="post" // so validate input, and if okay store it in db } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql problem importing data
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] says... > Hello Mark, > > I have tryed it by splitting the file into pices and then insert it with the > help of phpmyadmin. This woked. > > however, I do have some more files to upload, and this seems to be not the > fastest way:-) > > I tryed this: > mysql> LOAD DATA INFILE 'Hotel_Description.txt'INTO TABLE > test.hotels_descriptionFIELDS TERMINATED BY '\t' LINES TERMINATED BY > '\n'; > ERROR 2013: Lost connection to MySQL server during query > mysql> 030806 02:08:37 mysqld ended > > As you can see, my db server creashed! Nothing special about this file. > > I am running MySQL 3.23.49 without problems so far. > > Merlin > > "Mark" <[EMAIL PROTECTED]> schrieb im Newsbeitrag > news:[EMAIL PROTECTED] > > You could use mysqlimport with --fields-terminated-by=";" > > > > or you could open it in something like Excel, parse it there (text to > > columns), and save it as a CSV > > > > or you could read it line by, line into PHP, explode each line on the > > ;, then insert the data into MySQL > > > > or you could write a script that does a string > > substitution of ; to , > > > > Lots ofother options, too, which I haven't thought of. > > > > --- Merlin <[EMAIL PROTECTED]> wrote: > > > Hi there, > > > > > > I have a data file with data seperated by semicolons. It is about > > > 8MB big. > > > Now I just want to import it into mysql. > > > I tryed several things. First I took phpmyadmin, which resulted in > > > a white > > > page without error msg. Then I tryed it by hand with load data. > > > This did not > > > work as well. No I installed myodbc and tryed to export it from MS > > > Access. > > > This completly crashes my database server with this message: > > > > > > /usr/local/mysql/bin/safe_mysqld: line 1: 1067 Segmentation fault > > > nice --5 nohup > > > /usr/local/mysql/libexec/mysqld --basedir=/usr/local/mysql > > > --datadir=/home/m > > > ysqladm/data --user=mysql --pid-file=/home/mysqladm/var/mysqld.pid > > > --skip-lo > > > cking -u mysqladm >>/home/mysqladm/data/SARATOGA.err 2>&1 > > > 030807 00:00:45 mysqld ended > > > > > > Has anybody an idea on how to import that data? Its nicely > > > seperated by ; > > > > > > Thanx for any help, > > > > > > Merlin I assume here that when you say the data is separated by semicolons, you mean that the fields are separated by semicolons. In that case you should be able to use LOAD DATA INFILE and tell it that the fields are terminated by semicolons, not tabs as in the example you show above. -- Quod subigo farinam $email =~ s/oz$/au/o; A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL Date insert
This is how I implemented a similar though not exactly the same problem: $tempdate = gmdate("d-m-Y"); $insertSQL = sprintf("INSERT INTO gennews (newsdate, newsheadline, country, newsfull) VALUES ($tempdate, %s, %s, %s); So, you only have to change the format of the gmdate what you want. Bunmi Richard Hutchins wrote: Don't know about your date format, but you have named your table column DATE which is a reserved keyword in MySQL. Try naming that something different and see if you still get the error. -Original Message- From: Andrew D. Luebke [mailto:[EMAIL PROTECTED] Sent: Monday, July 28, 2003 2:17 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] MySQL Date insert Hello, I have the following PHP code: $date = date("Y-m-d H:i:s"); $result = mysql_query("INSERT INTO Boats (Make, Model, Serial, Stock, Extension, Cust_Name, Store, Date) VALUES ('$make', '$model', '$serial', '$stock', '$extension', '$name', '$store', '$date'") or die("Invalid query: " . mysql_error() . ""); The problem is with the Date column. It is of type DATETIME. I get an error on the second line of the insert statement. I assume I'm not putting formatting the date-time variable correctly but I've tried everything I can think of, so any help is very much appreciated. Thanks. Andrew. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL Returns Error
So create a hidden input field on the page called cur_id and set its value to the id of the record being displayed. If no record is currently being displayed, set it to -1. When you get ready to handle the form data, check the $_POST['cur_id'] variable. If it's set to -1, perform an INSERT. If it's set to anything else, perform an UPDATE using the value of $_POST['cur_id'] in your WHERE clause. I'm sure there are other ways to handle this. This is how I have handled it in the past though. > -Original Message- > From: Jeff [mailto:[EMAIL PROTECTED] > Sent: Tuesday, August 05, 2003 3:52 PM > To: [EMAIL PROTECTED] > Subject: Re: [PHP-DB] MySQL Returns Error > > > Oops, my mistake, it's not a blank entry - it re enters the > last entry. > > I can hit F5 or click refresh 1000 times and it will enter > the last entry > 1000 times. > > > "Jeff" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > I tried putting that in a few diffrent places, same result > - is there > > somewhere special I need to put that? > > > > "Matt Schroebel" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > > > > > -Original Message- > > > From: Jeff [mailto:[EMAIL PROTECTED] > > > Sent: Tuesday, August 05, 2003 3:15 PM > > > To: [EMAIL PROTECTED] > > > Subject: Re: [PHP-DB] MySQL Returns Error > > > > > > Every time I access or refresh the page, it adds one blank > > > entry to the DB. > > > > > > Maybe I have the insert query in the wrong place? > > > > if ('POST' == $_SERVER['REQUEST_METHOD']) { > > //someone submitted the form with method="post" > > // so validate input, and if okay store it in db > > } > > > > > > > > -- > 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] MySQL Returns Error
On Wednesday 06 August 2003 01:14, Jeff wrote: > Well I did what you said, and now I get "Parse error: parse error, > unexpected T_ECHO in C:\FoxServ\www\encana_db.php on line 44" Try: $result = mysql_query($query, $link_id) OR die(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 -- /* Byte your tongue. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL Returns Error
> -Original Message- > From: Jeff [mailto:[EMAIL PROTECTED] > Sent: Tuesday, August 05, 2003 3:52 PM > To: [EMAIL PROTECTED] > Subject: Re: [PHP-DB] MySQL Returns Error > > > Oops, my mistake, it's not a blank entry - it re enters the > last entry. > > I can hit F5 or click refresh 1000 times and it will enter > the last entry > 1000 times. The simplest thing to do is do a header('Location: http://your.site.com/someOtherPage.php') after the insert. That way the page displayed isn't the one someone will hit refresh on. Otherwise, perhaps you should do a select to see if the value is already in the db, and if so, don't insert it again, but perhaps update it, or ignore it. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] mysql connect error
Hi, I've just started playing with Linux/MySQL/PHP - I come from a Windows/ASP/PowerBuilder background. I have created a database in MySQL and now are trying to connect to it via PHP. I keep getting the same error, no matter what I specify in DSN. I always get: DB Error: no such database The following is the PHP code I am using: getMessage()); } $db->disconnect(); ?> This is straight out of the PHP documentation. Any ideas why I get the same error all the time. I am using RedHat 8.0, PHP 4.2.2, MySQL 3.2.53, Apache 2.0 thanks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] mysql problem importing data
Hi there, I have a data file with data seperated by semicolons. It is about 8MB big. Now I just want to import it into mysql. I tryed several things. First I took phpmyadmin, which resulted in a white page without error msg. Then I tryed it by hand with load data. This did not work as well. No I installed myodbc and tryed to export it from MS Access. This completly crashes my database server with this message: /usr/local/mysql/bin/safe_mysqld: line 1: 1067 Segmentation fault nice --5 nohup /usr/local/mysql/libexec/mysqld --basedir=/usr/local/mysql --datadir=/home/m ysqladm/data --user=mysql --pid-file=/home/mysqladm/var/mysqld.pid --skip-lo cking -u mysqladm >>/home/mysqladm/data/SARATOGA.err 2>&1 030807 00:00:45 mysqld ended Has anybody an idea on how to import that data? Its nicely seperated by ; Thanx for any help, Merlin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL Returns Error
> -Original Message- > From: Jeff [mailto:[EMAIL PROTECTED] > Sent: Tuesday, August 05, 2003 12:59 PM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] MySQL Returns Error > > Been working on this code all weekend, and I did take > everyone's advice, but > I'm still getting the same error. "Error retrieving records. > From line > "$result = mysql_query($query, $link_id) OR DIE("Error retrieving > records."); " of my code. When I first put the insert query > in, it allowed > me to add one record, then started returning the error, and > hasn't let me > enter another record since. Change that line to: $result = mysql_query($query, $link_id) OR DIE(echo mysql_error()); Make sure you either have magic_quotes_gpc on or (better) have magic_quotes_gpc off and addslashes() to each of the values you're inserting into the db. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL Date insert
Budelak wrote: This is how I implemented a similar though not exactly the same problem: $tempdate = gmdate("d-m-Y"); $insertSQL = sprintf("INSERT INTO gennews (newsdate, newsheadline, country, newsfull) VALUES ($tempdate, %s, %s, %s); So, you only have to change the format of the gmdate what you want. d-m-Y is not the MySQL format for a date, though, so that means you're saving the date in a VARCHAR or CHAR column. You lose the benifits of all the date and time functions built into MySQL when you do that. Not a good method... either store the dates as Unix timestamps or MySQL timestamps. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ PHP|Architect: A magazine for PHP Professionals – www.phparch.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql problem importing data
Hello Mark, I have tryed it by splitting the file into pices and then insert it with the help of phpmyadmin. This woked. however, I do have some more files to upload, and this seems to be not the fastest way:-) I tryed this: mysql> LOAD DATA INFILE 'Hotel_Description.txt'INTO TABLE test.hotels_descriptionFIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n'; ERROR 2013: Lost connection to MySQL server during query mysql> 030806 02:08:37 mysqld ended As you can see, my db server creashed! Nothing special about this file. I am running MySQL 3.23.49 without problems so far. Merlin "Mark" <[EMAIL PROTECTED]> schrieb im Newsbeitrag news:[EMAIL PROTECTED] > You could use mysqlimport with --fields-terminated-by=";" > > or you could open it in something like Excel, parse it there (text to > columns), and save it as a CSV > > or you could read it line by, line into PHP, explode each line on the > ;, then insert the data into MySQL > > or you could write a script that does a string > substitution of ; to , > > Lots ofother options, too, which I haven't thought of. > > --- Merlin <[EMAIL PROTECTED]> wrote: > > Hi there, > > > > I have a data file with data seperated by semicolons. It is about > > 8MB big. > > Now I just want to import it into mysql. > > I tryed several things. First I took phpmyadmin, which resulted in > > a white > > page without error msg. Then I tryed it by hand with load data. > > This did not > > work as well. No I installed myodbc and tryed to export it from MS > > Access. > > This completly crashes my database server with this message: > > > > /usr/local/mysql/bin/safe_mysqld: line 1: 1067 Segmentation fault > > nice --5 nohup > > /usr/local/mysql/libexec/mysqld --basedir=/usr/local/mysql > > --datadir=/home/m > > ysqladm/data --user=mysql --pid-file=/home/mysqladm/var/mysqld.pid > > --skip-lo > > cking -u mysqladm >>/home/mysqladm/data/SARATOGA.err 2>&1 > > 030807 00:00:45 mysqld ended > > > > Has anybody an idea on how to import that data? Its nicely > > seperated by ; > > > > Thanx for any help, > > > > Merlin > > > > > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > = > Mark Weinstock > [EMAIL PROTECTED] > *** > You can't demand something as a "right" unless you are willing to fight to death to defend everyone else's right to the same thing. > *** > > __ > Do you Yahoo!? > Yahoo! SiteBuilder - Free, easy-to-use web site design software > http://sitebuilder.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL Returns Error
Well I did what you said, and now I get "Parse error: parse error, unexpected T_ECHO in C:\FoxServ\www\encana_db.php on line 44" And magic_quotes_gpc was already ON. "Matt Schroebel" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > -Original Message- > From: Jeff [mailto:[EMAIL PROTECTED] > Sent: Tuesday, August 05, 2003 12:59 PM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] MySQL Returns Error > > Been working on this code all weekend, and I did take > everyone's advice, but > I'm still getting the same error. "Error retrieving records. > From line > "$result = mysql_query($query, $link_id) OR DIE("Error retrieving > records."); " of my code. When I first put the insert query > in, it allowed > me to add one record, then started returning the error, and > hasn't let me > enter another record since. Change that line to: $result = mysql_query($query, $link_id) OR DIE(echo mysql_error()); Make sure you either have magic_quotes_gpc on or (better) have magic_quotes_gpc off and addslashes() to each of the values you're inserting into the db. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL Returns Error
Awesome, that you ALL for your help - the error is gone and I can post to the DB now, and it works! But... *grin* Every time I access or refresh the page, it adds one blank entry to the DB. Maybe I have the insert query in the wrong place? "Matt Schroebel" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > -Original Message- > From: Jeff [mailto:[EMAIL PROTECTED] > Sent: Tuesday, August 05, 2003 12:59 PM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] MySQL Returns Error > > Been working on this code all weekend, and I did take > everyone's advice, but > I'm still getting the same error. "Error retrieving records. > From line > "$result = mysql_query($query, $link_id) OR DIE("Error retrieving > records."); " of my code. When I first put the insert query > in, it allowed > me to add one record, then started returning the error, and > hasn't let me > enter another record since. Change that line to: $result = mysql_query($query, $link_id) OR DIE(echo mysql_error()); Make sure you either have magic_quotes_gpc on or (better) have magic_quotes_gpc off and addslashes() to each of the values you're inserting into the db. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL Returns Error
Ok, that worked, Now the error I'm getting is "Duplicate entry ' ' for key 1" Is this a SQL table error? Here's my Table as entered: CREATE TABLE gradients ( gradient MEDIUMINT(10) DEFAULT '0' NOT NULL AUTO_INCREMENT, kwo VARCHAR(10) NOT NULL, lsd VARCHAR(10) NOT NULL, date DATE DEFAULT '-00-00' NOT NULL, well VARCHAR(50) NOT NULL, field VARCHAR(25) NOT NULL, uni VARCHAR(30) NOT NULL, license VARCHAR(10) BINARY NOT NULL, formation VARCHAR(20) NOT NULL, perfs VARCHAR(20) NOT NULL, event VARCHAR(1) NOT NULL, fluid VARCHAR(2) NOT NULL, mode VARCHAR(2) NOT NULL, type VARCHAR(2) NOT NULL, vhd VARCHAR(10) NOT NULL, file VARCHAR(15) NOT NULL, kb VARCHAR(6) NOT NULL, grd VARCHAR(10) NOT NULL, open VARCHAR(1) NOT NULL, sour VARCHAR(1) NOT NULL, tube VARCHAR(10) NOT NULL, landed VARCHAR(6) NOT NULL, casing VARCHAR(6) NOT NULL, landed2 VARCHAR(6) NOT NULL, shut_date VARCHAR(10) NOT NULL, shut_time DATE DEFAULT '-00-00' NOT NULL, pres VARCHAR(15) NOT NULL, tag VARCHAR(15) NOT NULL, PRIMARY KEY (lsd), UNIQUE gradient (gradient) ); "Jason Wong" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Wednesday 06 August 2003 01:14, Jeff wrote: > > Well I did what you said, and now I get "Parse error: parse error, > > unexpected T_ECHO in C:\FoxServ\www\encana_db.php on line 44" > > Try: > > $result = mysql_query($query, $link_id) OR die(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 > -- > /* > Byte your tongue. > */ > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL Returns Error
Change the gradient definition to: gradient MEDIUMINT(10) NOT NULL AUTO_INCREMENT, > -Original Message- > From: Jeff [mailto:[EMAIL PROTECTED] > Sent: Tuesday, August 05, 2003 1:44 PM > To: [EMAIL PROTECTED] > Subject: Re: [PHP-DB] MySQL Returns Error > > > Ok, that worked, > > Now the error I'm getting is "Duplicate entry ' ' for key 1" > > Is this a SQL table error? > > Here's my Table as entered: > > CREATE TABLE gradients ( > gradient MEDIUMINT(10) DEFAULT '0' NOT NULL AUTO_INCREMENT, > . > tag VARCHAR(15) NOT NULL, > PRIMARY KEY (lsd), > UNIQUE gradient (gradient) > ); -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MySQL Returns Error
Hi... again. :P Been working on this code all weekend, and I did take everyone's advice, but I'm still getting the same error. "Error retrieving records. From line "$result = mysql_query($query, $link_id) OR DIE("Error retrieving records."); " of my code. When I first put the insert query in, it allowed me to add one record, then started returning the error, and hasn't let me enter another record since. Here is the entire code. $value) ${$var}=$value; ?> DB Home | Display All | Search Total Entries: http://dataguy/logo_small.jpg> Encana Gradient Data Base KWL WO#: LSD: Date Completed: Well Name: Fieled/Pool: Unique: License #: Formation: Perfs: Event No.: Well Fluid Status: Well Status Mode: Well Status Type: Type V/D/H: File Name: KB: GRD: Open Hole: Sour:Tubing Size: Landed @:Casing Size: Landed @: Shut In Date: Shut In Time: Pres TUB/CAS KPAg: Tag PBTD: -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL Returns Error
UNIQUE gradient (gradient) This is causing your issue. You have stated that new records cannot match an already established record with the same name under gradient. HTH Aaron -Original Message- From: Jeff [mailto:[EMAIL PROTECTED] Sent: August 5, 2003 1:44 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] MySQL Returns Error Ok, that worked, Now the error I'm getting is "Duplicate entry ' ' for key 1" Is this a SQL table error? Here's my Table as entered: CREATE TABLE gradients ( gradient MEDIUMINT(10) DEFAULT '0' NOT NULL AUTO_INCREMENT, kwo VARCHAR(10) NOT NULL, lsd VARCHAR(10) NOT NULL, date DATE DEFAULT '-00-00' NOT NULL, well VARCHAR(50) NOT NULL, field VARCHAR(25) NOT NULL, uni VARCHAR(30) NOT NULL, license VARCHAR(10) BINARY NOT NULL, formation VARCHAR(20) NOT NULL, perfs VARCHAR(20) NOT NULL, event VARCHAR(1) NOT NULL, fluid VARCHAR(2) NOT NULL, mode VARCHAR(2) NOT NULL, type VARCHAR(2) NOT NULL, vhd VARCHAR(10) NOT NULL, file VARCHAR(15) NOT NULL, kb VARCHAR(6) NOT NULL, grd VARCHAR(10) NOT NULL, open VARCHAR(1) NOT NULL, sour VARCHAR(1) NOT NULL, tube VARCHAR(10) NOT NULL, landed VARCHAR(6) NOT NULL, casing VARCHAR(6) NOT NULL, landed2 VARCHAR(6) NOT NULL, shut_date VARCHAR(10) NOT NULL, shut_time DATE DEFAULT '-00-00' NOT NULL, pres VARCHAR(15) NOT NULL, tag VARCHAR(15) NOT NULL, PRIMARY KEY (lsd), UNIQUE gradient (gradient) ); "Jason Wong" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Wednesday 06 August 2003 01:14, Jeff wrote: > > Well I did what you said, and now I get "Parse error: parse error, > > unexpected T_ECHO in C:\FoxServ\www\encana_db.php on line 44" > > Try: > > $result = mysql_query($query, $link_id) OR die(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 > -- > /* > Byte your tongue. > */ > -- 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] MySQL
GAH! I don't userstand why this woudl work onyl once, then return a Error retrieving records.I've even recreated the sql DB, same result. "Jeff" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Well, it worked for ONE submission I was so excited. :) > > Then I went back to enter another test, and when I went back to the page, it > displayed everything up to that line again, but JUST output, " Error > retrieving records. " > > ??? Why woudl it work just once? > > "Mel Hodges" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Myfault.. you should be using link_id instead of dbHandletry this: > > > > $result = mysql_query($strSQL, $link_id) OR DIE("Error retrieving > records."); > > > > > > > > > > > > > > Quoting Jeff <[EMAIL PROTECTED]>: > > > > > K, that got my a bit further, now it shows half the page but stops at > the > > > line: > > > > > > $result = mysql_query($strSQL, $dbHandle) OR DIE("Error retrieving > > > records."); > > > > > > With error: > > > > > > Warning: mysql_query(): supplied argument is not a valid MySQL-Link > resource > > > in C:\FoxServ\www\encana_db.php on line 40 > > > Error retrieving records. > > > > > > BTW, thank you everyone for your help. > > > > > > > > > "Mel Hodges" <[EMAIL PROTECTED]> wrote in message > > > news:[EMAIL PROTECTED] > > > > Try this: > > > > > > > > $strSQL = "INSERT INTO gradients (kwo, lsd, date, well, field, uni, > > > license, > > > > formation) VALUES > > > > ('$kwo', '$lsd', '$date', '$well', '$field', '$uni', '$license', > > > '$formation')"; > > > > $result = mysql_query($strSQL, $dbHandle) OR DIE("Error retrieving > > > records."); > > > > > > > > > > > > > > > > > > > > > > > > Quoting Jeff <[EMAIL PROTECTED]>: > > > > > > > > > Yes I'm new at this - sorry for sounding like an idiot. I'm a > network > > > guy, > > > > > not a coder by any means - just learning. (Company "project") > > > > > > > > > > > First of all, get rid of all those extraneous open and close ( > > > > > > ?> > > > > > > > > > Done - it isn't the editor, I put them there - a lot of diffrent > > > testing, > > > > > and havn't had a changce to clean it up yet. > > > > > > > > > > >(or is this code cobbled from > > > > > >other places?). > > > > > > > > > > No, that's plagerisum. :P Doing this all form a book I purchased > which > > > > > dosn't cover MySQL as much as I had hoped. Thats what I get for > buying > > > it > > > > > online. :P > > > > > > > > > > >Second, the line in question is not valid PHP code. > > > > > > > > > > I figured as much, and did as you said, but it's still returning an > > > error. > > > > > > > > > > >It's SQL. Put it in quotes, assign it to a variable, and call it > > > > > >through a mysql_query() function. > > > > > > > > > > Error: Parse error: parse error, unexpected T_STRING in > > > > > C:\FoxServ\www\encana_db.php on line 36 > > > > > > > > > > My new code: > > > > > > > > > $PHP_SELF = mysql_query(INSERT INTO gradients (kwo, lsd, date, well, > > > field, > > > > > uni, license, formation) VALUES ('$kwo', '$lsd', '$date', '$well', > > > '$field', > > > > > '$uni', '$license', '$formation') ) > > > > > ?> > > > > > > > > > > > --- Jeff <[EMAIL PROTECTED]> wrote: > > > > > > > Sorry, I just realized that's an older copy of the code, here is > > > > > > > the updated stuff - (It's just one more line, the line that's > > > > > > > giving me greaf. :P ) > > > > > > > > > > > > > > > > > > > >$link_id = mysql_connect("localhost","admin","***") > > > > > > > or die("Unable to connect to SQL server"); > > > > > > > mysql_select_db("database",$link_id) > > > > > > > or die("Unable to select database"); > > > > > > > ?> > > > > > > > > > > > > > > > > > > > > > > > > > > > global $PHP_SELF > > > > > > > > > > > > > >?> > > > > > > > > > > > > > > > > > > > > // echo $results; > > > > > > >?> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > DB > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Home | Display > All > > > > > > > | Search > > > > > > > > > > > > > > Total Entries: > > > > > > > > > > > > > $query = "SELECT COUNT(*) FROM gradients"; > > > > > > > $num_count = mysql_query($query) or die("Select Failed!"); > > > > > > > $count = mysql_fetch_array($num_count); > > > > > > > > > > > > > > ?> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > http://dataguy/logo_small.jpg> > > > > > > > > > > > > > > Title for page > > > > > > > > > > > > > > > > > > > > INSERT INTO gradients (kwo, lsd, date, well, field, uni, > license, > > > > > > > formation) VALUES ('$kwo', '$lsd', '$date', '$well', '$field', > > > > > > > '$uni', '$license', '$formation') > > > > > > > ?> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > KWL WO#: > > > > > > >
Re: [PHP-DB] MySQL
Well, it worked for ONE submission I was so excited. :) Then I went back to enter another test, and when I went back to the page, it displayed everything up to that line again, but JUST output, " Error retrieving records. " ??? Why woudl it work just once? "Mel Hodges" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Myfault.. you should be using link_id instead of dbHandletry this: > > $result = mysql_query($strSQL, $link_id) OR DIE("Error retrieving records."); > > > > > > > Quoting Jeff <[EMAIL PROTECTED]>: > > > K, that got my a bit further, now it shows half the page but stops at the > > line: > > > > $result = mysql_query($strSQL, $dbHandle) OR DIE("Error retrieving > > records."); > > > > With error: > > > > Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource > > in C:\FoxServ\www\encana_db.php on line 40 > > Error retrieving records. > > > > BTW, thank you everyone for your help. > > > > > > "Mel Hodges" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > Try this: > > > > > > $strSQL = "INSERT INTO gradients (kwo, lsd, date, well, field, uni, > > license, > > > formation) VALUES > > > ('$kwo', '$lsd', '$date', '$well', '$field', '$uni', '$license', > > '$formation')"; > > > $result = mysql_query($strSQL, $dbHandle) OR DIE("Error retrieving > > records."); > > > > > > > > > > > > > > > > > > Quoting Jeff <[EMAIL PROTECTED]>: > > > > > > > Yes I'm new at this - sorry for sounding like an idiot. I'm a network > > guy, > > > > not a coder by any means - just learning. (Company "project") > > > > > > > > > First of all, get rid of all those extraneous open and close ( > > > > > ?> > > > > > > > Done - it isn't the editor, I put them there - a lot of diffrent > > testing, > > > > and havn't had a changce to clean it up yet. > > > > > > > > >(or is this code cobbled from > > > > >other places?). > > > > > > > > No, that's plagerisum. :P Doing this all form a book I purchased which > > > > dosn't cover MySQL as much as I had hoped. Thats what I get for buying > > it > > > > online. :P > > > > > > > > >Second, the line in question is not valid PHP code. > > > > > > > > I figured as much, and did as you said, but it's still returning an > > error. > > > > > > > > >It's SQL. Put it in quotes, assign it to a variable, and call it > > > > >through a mysql_query() function. > > > > > > > > Error: Parse error: parse error, unexpected T_STRING in > > > > C:\FoxServ\www\encana_db.php on line 36 > > > > > > > > My new code: > > > > > > > $PHP_SELF = mysql_query(INSERT INTO gradients (kwo, lsd, date, well, > > field, > > > > uni, license, formation) VALUES ('$kwo', '$lsd', '$date', '$well', > > '$field', > > > > '$uni', '$license', '$formation') ) > > > > ?> > > > > > > > > > --- Jeff <[EMAIL PROTECTED]> wrote: > > > > > > Sorry, I just realized that's an older copy of the code, here is > > > > > > the updated stuff - (It's just one more line, the line that's > > > > > > giving me greaf. :P ) > > > > > > > > > > > > > > > > >$link_id = mysql_connect("localhost","admin","***") > > > > > > or die("Unable to connect to SQL server"); > > > > > > mysql_select_db("database",$link_id) > > > > > > or die("Unable to select database"); > > > > > > ?> > > > > > > > > > > > > > > > > > > > > > > > global $PHP_SELF > > > > > > > > > > > >?> > > > > > > > > > > > > > > > > > // echo $results; > > > > > >?> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > DB > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Home | Display All > > > > > > | Search > > > > > > > > > > > > Total Entries: > > > > > > > > > > > $query = "SELECT COUNT(*) FROM gradients"; > > > > > > $num_count = mysql_query($query) or die("Select Failed!"); > > > > > > $count = mysql_fetch_array($num_count); > > > > > > > > > > > > ?> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > http://dataguy/logo_small.jpg> > > > > > > > > > > > > Title for page > > > > > > > > > > > > > > > > > INSERT INTO gradients (kwo, lsd, date, well, field, uni, license, > > > > > > formation) VALUES ('$kwo', '$lsd', '$date', '$well', '$field', > > > > > > '$uni', '$license', '$formation') > > > > > > ?> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > KWL WO#: > > > > > > LSD: > > > > > > Date Completed: > > > > > > Well Name: > > > > > > Fieled/Pool: > > > > > > Unique: > > > > > > License #: > > > > > > Formation: > > > > > > Perfs: > > > > > > Event No.: > > > > > > Well Fluid Status: > > > > > > Well > > > > > > Status Mode: > > > > > >Well Status Type: > > > > > > Type V/D/H: > > > > > > File Name: > > > > > > KB: > > > > > > GRD: > > > > > > Open Hole: > > > > > >Sour: > > > > > > Tu
Re: [PHP-DB] MySQL
Oh, and another thing, in this book I have, they say to give the forum action . Yet it dosn't give a value to $PHP_SELF. IS this correct? "Jeff" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > K, that got my a bit further, now it shows half the page but stops at the > line: > > $result = mysql_query($strSQL, $dbHandle) OR DIE("Error retrieving > records."); > > With error: > > Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource > in C:\FoxServ\www\encana_db.php on line 40 > Error retrieving records. > > BTW, thank you everyone for your help. > > > "Mel Hodges" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Try this: > > > > $strSQL = "INSERT INTO gradients (kwo, lsd, date, well, field, uni, > license, > > formation) VALUES > > ('$kwo', '$lsd', '$date', '$well', '$field', '$uni', '$license', > '$formation')"; > > $result = mysql_query($strSQL, $dbHandle) OR DIE("Error retrieving > records."); > > > > > > > > > > > > Quoting Jeff <[EMAIL PROTECTED]>: > > > > > Yes I'm new at this - sorry for sounding like an idiot. I'm a network > guy, > > > not a coder by any means - just learning. (Company "project") > > > > > > > First of all, get rid of all those extraneous open and close ( > > > > ?> > > > > > Done - it isn't the editor, I put them there - a lot of diffrent > testing, > > > and havn't had a changce to clean it up yet. > > > > > > >(or is this code cobbled from > > > >other places?). > > > > > > No, that's plagerisum. :P Doing this all form a book I purchased which > > > dosn't cover MySQL as much as I had hoped. Thats what I get for buying > it > > > online. :P > > > > > > >Second, the line in question is not valid PHP code. > > > > > > I figured as much, and did as you said, but it's still returning an > error. > > > > > > >It's SQL. Put it in quotes, assign it to a variable, and call it > > > >through a mysql_query() function. > > > > > > Error: Parse error: parse error, unexpected T_STRING in > > > C:\FoxServ\www\encana_db.php on line 36 > > > > > > My new code: > > > > > $PHP_SELF = mysql_query(INSERT INTO gradients (kwo, lsd, date, well, > field, > > > uni, license, formation) VALUES ('$kwo', '$lsd', '$date', '$well', > '$field', > > > '$uni', '$license', '$formation') ) > > > ?> > > > > > > > --- Jeff <[EMAIL PROTECTED]> wrote: > > > > > Sorry, I just realized that's an older copy of the code, here is > > > > > the updated stuff - (It's just one more line, the line that's > > > > > giving me greaf. :P ) > > > > > > > > > > > > > >$link_id = mysql_connect("localhost","admin","***") > > > > > or die("Unable to connect to SQL server"); > > > > > mysql_select_db("database",$link_id) > > > > > or die("Unable to select database"); > > > > > ?> > > > > > > > > > > > > > > > > > > > global $PHP_SELF > > > > > > > > > >?> > > > > > > > > > > > > > > // echo $results; > > > > >?> > > > > > > > > > > > > > > > > > > > > > > > > > DB > > > > > > > > > > > > > > > > > > > > > > > > > Home | Display All > > > > > | Search > > > > > > > > > > Total Entries: > > > > > > > > > $query = "SELECT COUNT(*) FROM gradients"; > > > > > $num_count = mysql_query($query) or die("Select Failed!"); > > > > > $count = mysql_fetch_array($num_count); > > > > > > > > > > ?> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > http://dataguy/logo_small.jpg> > > > > > > > > > > Title for page > > > > > > > > > > > > > > INSERT INTO gradients (kwo, lsd, date, well, field, uni, license, > > > > > formation) VALUES ('$kwo', '$lsd', '$date', '$well', '$field', > > > > > '$uni', '$license', '$formation') > > > > > ?> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > KWL WO#: > > > > > LSD: > > > > > Date Completed: > > > > > Well Name: > > > > > Fieled/Pool: > > > > > Unique: > > > > > License #: > > > > > Formation: > > > > > Perfs: > > > > > Event No.: > > > > > Well Fluid Status: > > > > > Well > > > > > Status Mode: > > > > >Well Status Type: > > > > > Type V/D/H: > > > > > File Name: > > > > > KB: > > > > > GRD: > > > > > Open Hole: > > > > >Sour: > > > > > Tubing Size: > > > > >Landed @: > > > > > Casing Size: > > > > >Landed @: > > > > > Shut In Date: > > > > >Shut In Time: > > > > > Pres > > > > > TUB/CAS KPAg: > > > > >Tag PBTD: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > "Jason Wong" <[EMAIL PROTECTED]> wrote in message > > > > > news:[EMAIL PROTECTED] > > > > > > On Saturday 02 August 2003 01:46, Jeff wrote: > > > > > > > > > > > > > I tried doing this through the news server, but something
Re: [PHP-DB] MySQL
Myfault.. you should be using link_id instead of dbHandletry this: $result = mysql_query($strSQL, $link_id) OR DIE("Error retrieving records."); Quoting Jeff <[EMAIL PROTECTED]>: > K, that got my a bit further, now it shows half the page but stops at the > line: > > $result = mysql_query($strSQL, $dbHandle) OR DIE("Error retrieving > records."); > > With error: > > Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource > in C:\FoxServ\www\encana_db.php on line 40 > Error retrieving records. > > BTW, thank you everyone for your help. > > > "Mel Hodges" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Try this: > > > > $strSQL = "INSERT INTO gradients (kwo, lsd, date, well, field, uni, > license, > > formation) VALUES > > ('$kwo', '$lsd', '$date', '$well', '$field', '$uni', '$license', > '$formation')"; > > $result = mysql_query($strSQL, $dbHandle) OR DIE("Error retrieving > records."); > > > > > > > > > > > > Quoting Jeff <[EMAIL PROTECTED]>: > > > > > Yes I'm new at this - sorry for sounding like an idiot. I'm a network > guy, > > > not a coder by any means - just learning. (Company "project") > > > > > > > First of all, get rid of all those extraneous open and close ( > > > > ?> > > > > > Done - it isn't the editor, I put them there - a lot of diffrent > testing, > > > and havn't had a changce to clean it up yet. > > > > > > >(or is this code cobbled from > > > >other places?). > > > > > > No, that's plagerisum. :P Doing this all form a book I purchased which > > > dosn't cover MySQL as much as I had hoped. Thats what I get for buying > it > > > online. :P > > > > > > >Second, the line in question is not valid PHP code. > > > > > > I figured as much, and did as you said, but it's still returning an > error. > > > > > > >It's SQL. Put it in quotes, assign it to a variable, and call it > > > >through a mysql_query() function. > > > > > > Error: Parse error: parse error, unexpected T_STRING in > > > C:\FoxServ\www\encana_db.php on line 36 > > > > > > My new code: > > > > > $PHP_SELF = mysql_query(INSERT INTO gradients (kwo, lsd, date, well, > field, > > > uni, license, formation) VALUES ('$kwo', '$lsd', '$date', '$well', > '$field', > > > '$uni', '$license', '$formation') ) > > > ?> > > > > > > > --- Jeff <[EMAIL PROTECTED]> wrote: > > > > > Sorry, I just realized that's an older copy of the code, here is > > > > > the updated stuff - (It's just one more line, the line that's > > > > > giving me greaf. :P ) > > > > > > > > > > > > > >$link_id = mysql_connect("localhost","admin","***") > > > > > or die("Unable to connect to SQL server"); > > > > > mysql_select_db("database",$link_id) > > > > > or die("Unable to select database"); > > > > > ?> > > > > > > > > > > > > > > > > > > > global $PHP_SELF > > > > > > > > > >?> > > > > > > > > > > > > > > // echo $results; > > > > >?> > > > > > > > > > > > > > > > > > > > > > > > > > DB > > > > > > > > > > > > > > > > > > > > > > > > > Home | Display All > > > > > | Search > > > > > > > > > > Total Entries: > > > > > > > > > $query = "SELECT COUNT(*) FROM gradients"; > > > > > $num_count = mysql_query($query) or die("Select Failed!"); > > > > > $count = mysql_fetch_array($num_count); > > > > > > > > > > ?> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > http://dataguy/logo_small.jpg> > > > > > > > > > > Title for page > > > > > > > > > > > > > > INSERT INTO gradients (kwo, lsd, date, well, field, uni, license, > > > > > formation) VALUES ('$kwo', '$lsd', '$date', '$well', '$field', > > > > > '$uni', '$license', '$formation') > > > > > ?> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > KWL WO#: > > > > > LSD: > > > > > Date Completed: > > > > > Well Name: > > > > > Fieled/Pool: > > > > > Unique: > > > > > License #: > > > > > Formation: > > > > > Perfs: > > > > > Event No.: > > > > > Well Fluid Status: > > > > > Well > > > > > Status Mode: > > > > >Well Status Type: > > > > > Type V/D/H: > > > > > File Name: > > > > > KB: > > > > > GRD: > > > > > Open Hole: > > > > >Sour: > > > > > Tubing Size: > > > > >Landed @: > > > > > Casing Size: > > > > >Landed @: > > > > > Shut In Date: > > > > >Shut In Time: > > > > > Pres > > > > > TUB/CAS KPAg: > > > > >Tag PBTD: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > "Jason Wong" <[EMAIL PROTECTED]> wrote in message > > > > > news:[EMAIL PROTECTED] > > > > > > On Saturday 02 August 2003 01:46, Jeff wrote: > > > > > > > > > > > > > I tried doing this through the news server, but something > > > > > messe
Re: [PHP-DB] MySQL
K, that got my a bit further, now it shows half the page but stops at the line: $result = mysql_query($strSQL, $dbHandle) OR DIE("Error retrieving records."); With error: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\FoxServ\www\encana_db.php on line 40 Error retrieving records. BTW, thank you everyone for your help. "Mel Hodges" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Try this: > > $strSQL = "INSERT INTO gradients (kwo, lsd, date, well, field, uni, license, > formation) VALUES > ('$kwo', '$lsd', '$date', '$well', '$field', '$uni', '$license', '$formation')"; > $result = mysql_query($strSQL, $dbHandle) OR DIE("Error retrieving records."); > > > > > > Quoting Jeff <[EMAIL PROTECTED]>: > > > Yes I'm new at this - sorry for sounding like an idiot. I'm a network guy, > > not a coder by any means - just learning. (Company "project") > > > > > First of all, get rid of all those extraneous open and close ( > > > ?> > > > Done - it isn't the editor, I put them there - a lot of diffrent testing, > > and havn't had a changce to clean it up yet. > > > > >(or is this code cobbled from > > >other places?). > > > > No, that's plagerisum. :P Doing this all form a book I purchased which > > dosn't cover MySQL as much as I had hoped. Thats what I get for buying it > > online. :P > > > > >Second, the line in question is not valid PHP code. > > > > I figured as much, and did as you said, but it's still returning an error. > > > > >It's SQL. Put it in quotes, assign it to a variable, and call it > > >through a mysql_query() function. > > > > Error: Parse error: parse error, unexpected T_STRING in > > C:\FoxServ\www\encana_db.php on line 36 > > > > My new code: > > > $PHP_SELF = mysql_query(INSERT INTO gradients (kwo, lsd, date, well, field, > > uni, license, formation) VALUES ('$kwo', '$lsd', '$date', '$well', '$field', > > '$uni', '$license', '$formation') ) > > ?> > > > > > --- Jeff <[EMAIL PROTECTED]> wrote: > > > > Sorry, I just realized that's an older copy of the code, here is > > > > the updated stuff - (It's just one more line, the line that's > > > > giving me greaf. :P ) > > > > > > > > > > >$link_id = mysql_connect("localhost","admin","***") > > > > or die("Unable to connect to SQL server"); > > > > mysql_select_db("database",$link_id) > > > > or die("Unable to select database"); > > > > ?> > > > > > > > > > > > > > > > global $PHP_SELF > > > > > > > >?> > > > > > > > > > > > // echo $results; > > > >?> > > > > > > > > > > > > > > > > > > > > DB > > > > > > > > > > > > > > > > > > > > Home | Display All > > > > | Search > > > > > > > > Total Entries: > > > > > > > $query = "SELECT COUNT(*) FROM gradients"; > > > > $num_count = mysql_query($query) or die("Select Failed!"); > > > > $count = mysql_fetch_array($num_count); > > > > > > > > ?> > > > > > > > > > > > > > > > > > > > > > > > > http://dataguy/logo_small.jpg> > > > > > > > > Title for page > > > > > > > > > > > INSERT INTO gradients (kwo, lsd, date, well, field, uni, license, > > > > formation) VALUES ('$kwo', '$lsd', '$date', '$well', '$field', > > > > '$uni', '$license', '$formation') > > > > ?> > > > > > > > > > > > > > > > > > > > > > > > > > > > > KWL WO#: > > > > LSD: > > > > Date Completed: > > > > Well Name: > > > > Fieled/Pool: > > > > Unique: > > > > License #: > > > > Formation: > > > > Perfs: > > > > Event No.: > > > > Well Fluid Status: > > > > Well > > > > Status Mode: > > > >Well Status Type: > > > > Type V/D/H: > > > > File Name: > > > > KB: > > > > GRD: > > > > Open Hole: > > > >Sour: > > > > Tubing Size: > > > >Landed @: > > > > Casing Size: > > > >Landed @: > > > > Shut In Date: > > > >Shut In Time: > > > > Pres > > > > TUB/CAS KPAg: > > > >Tag PBTD: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > "Jason Wong" <[EMAIL PROTECTED]> wrote in message > > > > news:[EMAIL PROTECTED] > > > > > On Saturday 02 August 2003 01:46, Jeff wrote: > > > > > > > > > > > I tried doing this through the news server, but something > > > > messed up. > > > > > > > > > > > > I just need to know how to make an HTML form write to a MySQL > > > > DB. > > > > > > This is what I have so far. > > > > > > > > > > [snip] > > > > > > > > > > And does it work? If it works then congratulations. If it doesn't > > > > work, *how* > > > > > doesn't it work. > > > > > > > > > > If you're new to all this, you might want to start by reading > > > > some of the > > > > > numerous tutorials available (google for them) and follow through > > > > a few of > > > > > them. > > > > > > > > > > -- > > > > > Jason
Re: [PHP-DB] MySQL
Try this: $strSQL = "INSERT INTO gradients (kwo, lsd, date, well, field, uni, license, formation) VALUES ('$kwo', '$lsd', '$date', '$well', '$field', '$uni', '$license', '$formation')"; $result = mysql_query($strSQL, $dbHandle) OR DIE("Error retrieving records."); Quoting Jeff <[EMAIL PROTECTED]>: > Yes I'm new at this - sorry for sounding like an idiot. I'm a network guy, > not a coder by any means - just learning. (Company "project") > > > First of all, get rid of all those extraneous open and close ( > > ?> > Done - it isn't the editor, I put them there - a lot of diffrent testing, > and havn't had a changce to clean it up yet. > > >(or is this code cobbled from > >other places?). > > No, that's plagerisum. :P Doing this all form a book I purchased which > dosn't cover MySQL as much as I had hoped. Thats what I get for buying it > online. :P > > >Second, the line in question is not valid PHP code. > > I figured as much, and did as you said, but it's still returning an error. > > >It's SQL. Put it in quotes, assign it to a variable, and call it > >through a mysql_query() function. > > Error: Parse error: parse error, unexpected T_STRING in > C:\FoxServ\www\encana_db.php on line 36 > > My new code: > $PHP_SELF = mysql_query(INSERT INTO gradients (kwo, lsd, date, well, field, > uni, license, formation) VALUES ('$kwo', '$lsd', '$date', '$well', '$field', > '$uni', '$license', '$formation') ) > ?> > > > --- Jeff <[EMAIL PROTECTED]> wrote: > > > Sorry, I just realized that's an older copy of the code, here is > > > the updated stuff - (It's just one more line, the line that's > > > giving me greaf. :P ) > > > > > > > >$link_id = mysql_connect("localhost","admin","***") > > > or die("Unable to connect to SQL server"); > > > mysql_select_db("database",$link_id) > > > or die("Unable to select database"); > > > ?> > > > > > > > > > > > global $PHP_SELF > > > > > >?> > > > > > > > > // echo $results; > > >?> > > > > > > > > > > > > > > > DB > > > > > > > > > > > > > > > Home | Display All > > > | Search > > > > > > Total Entries: > > > > > $query = "SELECT COUNT(*) FROM gradients"; > > > $num_count = mysql_query($query) or die("Select Failed!"); > > > $count = mysql_fetch_array($num_count); > > > > > > ?> > > > > > > > > > > > > > > > > > > http://dataguy/logo_small.jpg> > > > > > > Title for page > > > > > > > > INSERT INTO gradients (kwo, lsd, date, well, field, uni, license, > > > formation) VALUES ('$kwo', '$lsd', '$date', '$well', '$field', > > > '$uni', '$license', '$formation') > > > ?> > > > > > > > > > > > > > > > > > > > > > KWL WO#: > > > LSD: > > > Date Completed: > > > Well Name: > > > Fieled/Pool: > > > Unique: > > > License #: > > > Formation: > > > Perfs: > > > Event No.: > > > Well Fluid Status: > > > Well > > > Status Mode: > > >Well Status Type: > > > Type V/D/H: > > > File Name: > > > KB: > > > GRD: > > > Open Hole: > > >Sour: > > > Tubing Size: > > >Landed @: > > > Casing Size: > > >Landed @: > > > Shut In Date: > > >Shut In Time: > > > Pres > > > TUB/CAS KPAg: > > >Tag PBTD: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > "Jason Wong" <[EMAIL PROTECTED]> wrote in message > > > news:[EMAIL PROTECTED] > > > > On Saturday 02 August 2003 01:46, Jeff wrote: > > > > > > > > > I tried doing this through the news server, but something > > > messed up. > > > > > > > > > > I just need to know how to make an HTML form write to a MySQL > > > DB. > > > > > This is what I have so far. > > > > > > > > [snip] > > > > > > > > And does it work? If it works then congratulations. If it doesn't > > > work, *how* > > > > doesn't it work. > > > > > > > > If you're new to all this, you might want to start by reading > > > some of the > > > > numerous tutorials available (google for them) and follow through > > > a few of > > > > them. > > > > > > > > -- > > > > 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 > > > > -- > > > > /* > > > > Sometimes a man will tell his bartender things he'll never tell > > > his doctor. > > > > -- Dr. Phillip Boyce, "The Menagerie" ("The Cage"), > > > >stardate unknown. > > > > */ > > > > > > > > > > = > > Mark Weinstock > > [EMAIL PROTECTED] > > *** > > You can't demand something as a "right" unless you are willing to figh
Re: [PHP-DB] MySQL
Yes I'm new at this - sorry for sounding like an idiot. I'm a network guy, not a coder by any means - just learning. (Company "project") > First of all, get rid of all those extraneous open and close ( > ?>(or is this code cobbled from >other places?). No, that's plagerisum. :P Doing this all form a book I purchased which dosn't cover MySQL as much as I had hoped. Thats what I get for buying it online. :P >Second, the line in question is not valid PHP code. I figured as much, and did as you said, but it's still returning an error. >It's SQL. Put it in quotes, assign it to a variable, and call it >through a mysql_query() function. Error: Parse error: parse error, unexpected T_STRING in C:\FoxServ\www\encana_db.php on line 36 My new code: > --- Jeff <[EMAIL PROTECTED]> wrote: > > Sorry, I just realized that's an older copy of the code, here is > > the updated stuff - (It's just one more line, the line that's > > giving me greaf. :P ) > > > > >$link_id = mysql_connect("localhost","admin","***") > > or die("Unable to connect to SQL server"); > > mysql_select_db("database",$link_id) > > or die("Unable to select database"); > > ?> > > > > > > > global $PHP_SELF > > > >?> > > > > > // echo $results; > >?> > > > > > > > > > > DB > > > > > > > > > > Home | Display All > > | Search > > > > Total Entries: > > > $query = "SELECT COUNT(*) FROM gradients"; > > $num_count = mysql_query($query) or die("Select Failed!"); > > $count = mysql_fetch_array($num_count); > > > > ?> > > > > > > > > > > > > http://dataguy/logo_small.jpg> > > > > Title for page > > > > > INSERT INTO gradients (kwo, lsd, date, well, field, uni, license, > > formation) VALUES ('$kwo', '$lsd', '$date', '$well', '$field', > > '$uni', '$license', '$formation') > > ?> > > > > > > > > > > > > > > KWL WO#: > > LSD: > > Date Completed: > > Well Name: > > Fieled/Pool: > > Unique: > > License #: > > Formation: > > Perfs: > > Event No.: > > Well Fluid Status: > > Well > > Status Mode: > >Well Status Type: > > Type V/D/H: > > File Name: > > KB: > > GRD: > > Open Hole: > >Sour: > > Tubing Size: > >Landed @: > > Casing Size: > >Landed @: > > Shut In Date: > >Shut In Time: > > Pres > > TUB/CAS KPAg: > >Tag PBTD: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > "Jason Wong" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > On Saturday 02 August 2003 01:46, Jeff wrote: > > > > > > > I tried doing this through the news server, but something > > messed up. > > > > > > > > I just need to know how to make an HTML form write to a MySQL > > DB. > > > > This is what I have so far. > > > > > > [snip] > > > > > > And does it work? If it works then congratulations. If it doesn't > > work, *how* > > > doesn't it work. > > > > > > If you're new to all this, you might want to start by reading > > some of the > > > numerous tutorials available (google for them) and follow through > > a few of > > > them. > > > > > > -- > > > 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 > > > -- > > > /* > > > Sometimes a man will tell his bartender things he'll never tell > > his doctor. > > > -- Dr. Phillip Boyce, "The Menagerie" ("The Cage"), > > >stardate unknown. > > > */ > > > > > > = > Mark Weinstock > [EMAIL PROTECTED] > *** > You can't demand something as a "right" unless you are willing to fight to death to defend everyone else's right to the same thing. > *** > > __ > Do you Yahoo!? > Yahoo! SiteBuilder - Free, easy-to-use web site design software > http://sitebuilder.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL
First of all, get rid of all those extraneous open and close ( ?> wrote: > Sorry, I just realized that's an older copy of the code, here is > the updated stuff - (It's just one more line, the line that's > giving me greaf. :P ) > > $link_id = mysql_connect("localhost","admin","***") > or die("Unable to connect to SQL server"); > mysql_select_db("database",$link_id) > or die("Unable to select database"); > ?> > > > global $PHP_SELF > >?> > > // echo $results; >?> > > > > > DB > > > > > Home | Display All > | Search > > Total Entries: > $query = "SELECT COUNT(*) FROM gradients"; > $num_count = mysql_query($query) or die("Select Failed!"); > $count = mysql_fetch_array($num_count); > > ?> > > > > > > http://dataguy/logo_small.jpg> > > Title for page > > INSERT INTO gradients (kwo, lsd, date, well, field, uni, license, > formation) VALUES ('$kwo', '$lsd', '$date', '$well', '$field', > '$uni', '$license', '$formation') > ?> > > > > > > > KWL WO#: > LSD: > Date Completed: > Well Name: > Fieled/Pool: > Unique: > License #: > Formation: > Perfs: > Event No.: > Well Fluid Status: > Well > Status Mode: >Well Status Type: > Type V/D/H: > File Name: > KB: > GRD: > Open Hole: >Sour: > Tubing Size: >Landed @: > Casing Size: >Landed @: > Shut In Date: >Shut In Time: > Pres > TUB/CAS KPAg: >Tag PBTD: > > > > > > > > > > > > > > > > > "Jason Wong" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > On Saturday 02 August 2003 01:46, Jeff wrote: > > > > > I tried doing this through the news server, but something > messed up. > > > > > > I just need to know how to make an HTML form write to a MySQL > DB. > > > This is what I have so far. > > > > [snip] > > > > And does it work? If it works then congratulations. If it doesn't > work, *how* > > doesn't it work. > > > > If you're new to all this, you might want to start by reading > some of the > > numerous tutorials available (google for them) and follow through > a few of > > them. > > > > -- > > 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 > > -- > > /* > > Sometimes a man will tell his bartender things he'll never tell > his doctor. > > -- Dr. Phillip Boyce, "The Menagerie" ("The Cage"), > >stardate unknown. > > */ > > = Mark Weinstock [EMAIL PROTECTED] *** You can't demand something as a "right" unless you are willing to fight to death to defend everyone else's right to the same thing. *** __ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL
Sorry, I just realized that's an older copy of the code, here is the updated stuff - (It's just one more line, the line that's giving me greaf. :P ) DB Home | Display All | Search Total Entries: http://dataguy/logo_small.jpg> Title for page KWL WO#: LSD: Date Completed: Well Name: Fieled/Pool: Unique: License #: Formation: Perfs: Event No.: Well Fluid Status: Well Status Mode: Well Status Type: Type V/D/H: File Name: KB: GRD: Open Hole: Sour: Tubing Size: Landed @: Casing Size: Landed @: Shut In Date: Shut In Time: Pres TUB/CAS KPAg: Tag PBTD: "Jason Wong" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Saturday 02 August 2003 01:46, Jeff wrote: > > > I tried doing this through the news server, but something messed up. > > > > I just need to know how to make an HTML form write to a MySQL DB. > > This is what I have so far. > > [snip] > > And does it work? If it works then congratulations. If it doesn't work, *how* > doesn't it work. > > If you're new to all this, you might want to start by reading some of the > numerous tutorials available (google for them) and follow through a few of > them. > > -- > 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 > -- > /* > Sometimes a man will tell his bartender things he'll never tell his doctor. > -- Dr. Phillip Boyce, "The Menagerie" ("The Cage"), >stardate unknown. > */ >
RE: [PHP-DB] MySQL
No it dosn't work. I don't know *how* it dosn't work. That's why I'm asking for a hand. When I run the page it returns a " Parse error: parse error, unexpected T_STRING in C:\FoxServ\www\encana_db.php on line 48 " Which is: INSERT INTO gradients (kwo, lsd, date, well, field, uni, license, formation) VALUES ('$kwo', '$lsd', '$date', '$well', '$field', '$uni', '$license', '$formation') -Original Message----- From: Jason Wong [mailto:[EMAIL PROTECTED] Sent: August 1, 2003 12:15 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] MySQL On Saturday 02 August 2003 01:46, Jeff wrote: > I tried doing this through the news server, but something messed up. > > I just need to know how to make an HTML form write to a MySQL DB. This > is what I have so far. [snip] And does it work? If it works then congratulations. If it doesn't work, *how* doesn't it work. If you're new to all this, you might want to start by reading some of the numerous tutorials available (google for them) and follow through a few of them. -- 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 -- /* Sometimes a man will tell his bartender things he'll never tell his doctor. -- Dr. Phillip Boyce, "The Menagerie" ("The Cage"), stardate unknown. */ -- 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] MySQL
On Saturday 02 August 2003 01:46, Jeff wrote: > I tried doing this through the news server, but something messed up. > > I just need to know how to make an HTML form write to a MySQL DB. > This is what I have so far. [snip] And does it work? If it works then congratulations. If it doesn't work, *how* doesn't it work. If you're new to all this, you might want to start by reading some of the numerous tutorials available (google for them) and follow through a few of them. -- 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 -- /* Sometimes a man will tell his bartender things he'll never tell his doctor. -- Dr. Phillip Boyce, "The Menagerie" ("The Cage"), stardate unknown. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MySQL
Hi! I tried doing this through the news server, but something messed up. I just need to know how to make an HTML form write to a MySQL DB. This is what I have so far. DB Home | Display All | Search Total Entries: http://dataguy/logo_small.jpg> Title for page KWL WO#: LSD: Date Completed: Well Name: Fieled/Pool: Unique: License #: Formation: Perfs: Event No.: Well Fluid Status: Well Status Mode: Well Status Type: Type V/D/H: File Name: KB: GRD: Open Hole: Sour: Tubing Size: Landed @: Casing Size: Landed @: Shut In Date: Shut In Time: Pres TUB/CAS KPAg: Tag PBTD:
Re: [PHP-DB] MySQL
I assume that would be placed before the: ... Also, is the form action still From: Larry E. Ullman <[EMAIL PROTECTED]> To: "Crash" <[EMAIL PROTECTED]> CC: [EMAIL PROTECTED] Subject: Re: [PHP-DB] MySQL Date: Fri, 1 Aug 2003 12:16:17 -0400 I just need to know how to enter the data submitted by an html form into a MySQL DB. I have already created the form, and the variables in that form - just need to know the query use to insert that data. The query will be something like INSERT INTO tablename (column1, column2, column3, ...) VALUES ('$var1', '$var2', '$var3', ...) But you'll need to connect to MySQL first, then select the database. Check out the PHP and MySQL manuals for more information. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL
I just need to know how to enter the data submitted by an html form into a MySQL DB. I have already created the form, and the variables in that form - just need to know the query use to insert that data. The query will be something like INSERT INTO tablename (column1, column2, column3, ...) VALUES ('$var1', '$var2', '$var3', ...) But you'll need to connect to MySQL first, then select the database. Check out the PHP and MySQL manuals for more information. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MySQL
Hi! I just need to know how to enter the data submitted by an html form into a MySQL DB. I have already created the form, and the variables in that form - just need to know the query use to insert that data. Thanks - Crash -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mySQL help on win xp
I am running PHP with Abyss Webserver on Windows XP Home, and MySQL works OK. If I am not using the mysql console, I use PHPMyAdmin as a friendlier front end for MySQL. Rob "Larry R. Sieting" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > At 07:44 PM 7/31/2003 +0100, John Ryan wrote: > >i installed php and apache fine on my pc, but mysql is giving problems. in > >winmysqladmin, you cant create a adb on the databases tab. all that lets you > >do is flush threads, flush processes, etc. so i had to create my database > >through the mysql command line. > > Personally, I am running Win XP with Apache 1.3.27 and Php 4.3.2 and MySql > 4.0.13. > > I couldn't get WinMySqlAdmin to work either. > > I got rid of the winMySQLAdmin.. found it worthless... cant do half of what > is says it is supposed to.. and I checked out SQLyog. I will be buying it > when I can (as a front end maintenance app) But that is my opninion. > > > >also, phpMyAdmin doesnt work, it returns an auth error. but i know for > >definite the username and password. > > Can't help here... haven't used/played with it enough yet. > > > >whats going on?? is it something to do with win xp and users or win xps > >firewall??? > > > > Larry R. Sieting > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mySQL help on win xp
At 07:44 PM 7/31/2003 +0100, John Ryan wrote: i installed php and apache fine on my pc, but mysql is giving problems. in winmysqladmin, you cant create a adb on the databases tab. all that lets you do is flush threads, flush processes, etc. so i had to create my database through the mysql command line. Personally, I am running Win XP with Apache 1.3.27 and Php 4.3.2 and MySql 4.0.13. I couldn't get WinMySqlAdmin to work either. I got rid of the winMySQLAdmin.. found it worthless... cant do half of what is says it is supposed to.. and I checked out SQLyog. I will be buying it when I can (as a front end maintenance app) But that is my opninion. also, phpMyAdmin doesnt work, it returns an auth error. but i know for definite the username and password. Can't help here... haven't used/played with it enough yet. whats going on?? is it something to do with win xp and users or win xps firewall??? Larry R. Sieting -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] mySQL help on win xp
i installed php and apache fine on my pc, but mysql is giving problems. in winmysqladmin, you cant create a adb on the databases tab. all that lets you do is flush threads, flush processes, etc. so i had to create my database through the mysql command line. also, phpMyAdmin doesnt work, it returns an auth error. but i know for definite the username and password. whats going on?? is it something to do with win xp and users or win xps firewall??? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL Date insert
John, thanks, now I feel stupid, it's always the silly little things that get you. You were right, when I added the date to the existing insert I forgot to put the ending parentheses back in. Thanks for the help. Andrew. At 11:26 AM 7/28/2003, CPT John W. Holmes wrote: From: "Andrew D. Luebke" <[EMAIL PROTECTED]> > $date = date("Y-m-d H:i:s"); > $result = mysql_query("INSERT INTO Boats (Make, Model, Serial, > Stock, Extension, Cust_Name, Store, Date) VALUES > ('$make', '$model', '$serial', '$stock', '$extension', > '$name', '$store', '$date'") > or die("Invalid query: " . mysql_error() . ""); > > The problem is with the Date column. It is of type DATETIME. I get an > error on the second line of the insert statement. I assume I'm not putting > formatting the date-time variable correctly but I've tried everything I can > think of, so any help is very much appreciated. Thanks. Like someone else said, using Date as a column name probably isn't very smart. Your problem is caused by not having a closing parenthesis in your query, though. '$date')") ---John Holmes... -- 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] MySQL Date insert
From: "NIPP, SCOTT V (SBCSI)" <[EMAIL PROTECTED]> > I actually think I know part of this answer... I don't think you > need to define a variable to insert into your "date" field. Inserting an > empty value into this filed will populate the field in the database with the > current time, which it appears from your code is what you are trying to do > here. Try changing the field name and give that a shot. I think I am > actually right here though. Well, kind of. :) This will only happen if the column is a TIMESTAMP column. It does not work that way for DATE, TIME, or DATETIME columns. But... we're getting off-topic. :) ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL Date insert
Andrew, try this: $date = date('Y m d H i s'); A similar syntax (with single quotes rather than double, and without intervening dashes) has worked for me in some MySQL-related PHP code I've just written. My code looked like this: $title2 = "\n".date('l F d Y')."\n"; Michele Petrovsky - Original Message - From: "Andrew D. Luebke" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, July 28, 2003 2:16 PM Subject: [PHP-DB] MySQL Date insert > Hello, > I have the following PHP code: > > $date = date("Y-m-d H:i:s"); > $result = mysql_query("INSERT INTO Boats (Make, Model, Serial, > Stock, Extension, Cust_Name, Store, Date) VALUES > ('$make', '$model', '$serial', '$stock', '$extension', > '$name', '$store', '$date'") > or die("Invalid query: " . mysql_error() . ""); > > The problem is with the Date column. It is of type DATETIME. I get an > error on the second line of the insert statement. I assume I'm not putting > formatting the date-time variable correctly but I've tried everything I can > think of, so any help is very much appreciated. Thanks. > > Andrew. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL Date insert
i have a feeling oyu're not getting a mysql error but a PHP error??? you have an odd number of parentheses and mysql_error will not have an closing paren. if that is the case, try this mysql_query("INSERT INTO Boats (Make, Model, Serial,Stock, Extension, Cust_Name, Store, Date) VALUES ('$make', '$model', '$serial', '$stock', '$extension','$name', '$store', '$date')") or die("Invalid query: " . mysql_error() . ""); "Andrew D. Luebke" <[EMAIL PROTECTED]To: [EMAIL PROTECTED] hetres.com> cc: Subject: [PHP-DB] MySQL Date insert 07/28/2003 02:16 PM Hello, I have the following PHP code: $date = date("Y-m-d H:i:s"); $result = mysql_query("INSERT INTO Boats (Make, Model, Serial, Stock, Extension, Cust_Name, Store, Date) VALUES ('$make', '$model', '$serial', '$stock', '$extension', '$name', '$store', '$date'") or die("Invalid query: " . mysql_error() . ""); The problem is with the Date column. It is of type DATETIME. I get an error on the second line of the insert statement. I assume I'm not putting formatting the date-time variable correctly but I've tried everything I can think of, so any help is very much appreciated. Thanks. Andrew. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL Date insert
I actually think I know part of this answer... I don't think you need to define a variable to insert into your "date" field. Inserting an empty value into this filed will populate the field in the database with the current time, which it appears from your code is what you are trying to do here. Try changing the field name and give that a shot. I think I am actually right here though. Scott -Original Message- From: Hutchins, Richard [mailto:[EMAIL PROTECTED] Sent: Monday, July 28, 2003 1:19 PM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] MySQL Date insert Don't know about your date format, but you have named your table column DATE which is a reserved keyword in MySQL. Try naming that something different and see if you still get the error. > -Original Message- > From: Andrew D. Luebke [mailto:[EMAIL PROTECTED] > Sent: Monday, July 28, 2003 2:17 PM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] MySQL Date insert > > > Hello, > I have the following PHP code: > > $date = date("Y-m-d H:i:s"); > $result = mysql_query("INSERT INTO Boats (Make, > Model, Serial, > Stock, Extension, Cust_Name, Store, Date) VALUES > ('$make', '$model', '$serial', '$stock', > '$extension', > '$name', '$store', '$date'") > or die("Invalid query: " . mysql_error() . > ""); > > The problem is with the Date column. It is of type DATETIME. > I get an > error on the second line of the insert statement. I assume > I'm not putting > formatting the date-time variable correctly but I've tried > everything I can > think of, so any help is very much appreciated. Thanks. > > Andrew. > -- 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] MySQL Date insert
From: "Andrew D. Luebke" <[EMAIL PROTECTED]> > $date = date("Y-m-d H:i:s"); > $result = mysql_query("INSERT INTO Boats (Make, Model, Serial, > Stock, Extension, Cust_Name, Store, Date) VALUES > ('$make', '$model', '$serial', '$stock', '$extension', > '$name', '$store', '$date'") > or die("Invalid query: " . mysql_error() . ""); > > The problem is with the Date column. It is of type DATETIME. I get an > error on the second line of the insert statement. I assume I'm not putting > formatting the date-time variable correctly but I've tried everything I can > think of, so any help is very much appreciated. Thanks. Like someone else said, using Date as a column name probably isn't very smart. Your problem is caused by not having a closing parenthesis in your query, though. '$date')") ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL Date insert
Nope, changed the insert to: $result = mysql_query("INSERT INTO Boats (Make, Model, Serial, Stock, Extension, Cust_Name, Store, Insert_Date) VALUES ('$make', '$model', '$serial', '$stock', '$extension', '$name', '$store', '$date'") or die("Invalid query: " . mysql_error() . ""); with corresponding alter of the table of course, same error. Andrew. At 11:19 AM 7/28/2003, Hutchins, Richard wrote: Don't know about your date format, but you have named your table column DATE which is a reserved keyword in MySQL. Try naming that something different and see if you still get the error. > -Original Message- > From: Andrew D. Luebke [mailto:[EMAIL PROTECTED] > Sent: Monday, July 28, 2003 2:17 PM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] MySQL Date insert > > > Hello, > I have the following PHP code: > > $date = date("Y-m-d H:i:s"); > $result = mysql_query("INSERT INTO Boats (Make, > Model, Serial, > Stock, Extension, Cust_Name, Store, Date) VALUES > ('$make', '$model', '$serial', '$stock', > '$extension', > '$name', '$store', '$date'") > or die("Invalid query: " . mysql_error() . > ""); > > The problem is with the Date column. It is of type DATETIME. > I get an > error on the second line of the insert statement. I assume > I'm not putting > formatting the date-time variable correctly but I've tried > everything I can > think of, so any help is very much appreciated. Thanks. > > Andrew. > -- 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] MySQL Date insert
Don't know about your date format, but you have named your table column DATE which is a reserved keyword in MySQL. Try naming that something different and see if you still get the error. > -Original Message- > From: Andrew D. Luebke [mailto:[EMAIL PROTECTED] > Sent: Monday, July 28, 2003 2:17 PM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] MySQL Date insert > > > Hello, > I have the following PHP code: > > $date = date("Y-m-d H:i:s"); > $result = mysql_query("INSERT INTO Boats (Make, > Model, Serial, > Stock, Extension, Cust_Name, Store, Date) VALUES > ('$make', '$model', '$serial', '$stock', > '$extension', > '$name', '$store', '$date'") > or die("Invalid query: " . mysql_error() . > ""); > > The problem is with the Date column. It is of type DATETIME. > I get an > error on the second line of the insert statement. I assume > I'm not putting > formatting the date-time variable correctly but I've tried > everything I can > think of, so any help is very much appreciated. Thanks. > > Andrew. > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MySQL Date insert
Hello, I have the following PHP code: $date = date("Y-m-d H:i:s"); $result = mysql_query("INSERT INTO Boats (Make, Model, Serial, Stock, Extension, Cust_Name, Store, Date) VALUES ('$make', '$model', '$serial', '$stock', '$extension', '$name', '$store', '$date'") or die("Invalid query: " . mysql_error() . ""); The problem is with the Date column. It is of type DATETIME. I get an error on the second line of the insert statement. I assume I'm not putting formatting the date-time variable correctly but I've tried everything I can think of, so any help is very much appreciated. Thanks. Andrew.
Re: [PHP-DB] MySQL Session
Here's how I do it using functional PHP programming (you may prefer using OO PHP which I don't bother with) : I include a generic functions file in each page. You could take it further, opening and closing the database connection for every query, but this way is more efficient if more than open query is run against the database on each page. create "functions.php" which contains the following: - Could not select database."); } function do_query($query) { global $result; $result = mysql_query($query) or die("Query failed." ."MySQL said ".mysql_error()."" ."query=".$query.""); } function close_db() { global $result; global $link; /* Free resultset */ mysql_free_result($result); /* Closing connection */ mysql_close($link); } ?> Then use "functions.php" in each web page you code - - Original Message - From: "Morten Twellmann" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, July 27, 2003 1:01 PM Subject: [PHP-DB] MySQL Session > I have just recently entered the world of PHP and MySQL. I'm used to code in > ASP with Access databases and since I am not very familiar with PHP, I have > run into a problem, which is probably quite easy to solve: > > Connecting to the database requires a couple lines of code, which I would > rather not have to write on every single page, which needs the database > connection. > ($link = mysql_connect("host", "username", "password") >or die("Could not connect : " . mysql_error()); > mysql_select_db("dbname") or die("Could not select database.");) > > In ASP this is easy to solve, since I would just create a "global.asa" and > on the Application_OnStart procedure, I would create the global database > connection and then reference to that variable on each of the individual > pages. > > Now, in PHP I do not seem to be able to create a "global.asa" or anything > similar. It does not even seem to have an "Application" object, which I can > refer to on any page. > > Can anyone tell me how I can connect to the MySQL database from some kind of > a global page, being activated no matter which page the user starts on and > where I only need to write the different SQL statements in the individual > pages. > (In ASP I could do the following on the individual page: > Set RS = Application("conn").Execute("SELECT * FROM database") > > Thank you. > > Morten > > > > -- > 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] MySQL Session
Hi welcome to php :) in general you can use an include at the beginning of each page -Original Message- From: Morten Twellmann [mailto:[EMAIL PROTECTED] Sent: 27 July 2003 13:01 To: [EMAIL PROTECTED] Subject: [PHP-DB] MySQL Session I have just recently entered the world of PHP and MySQL. I'm used to code in ASP with Access databases and since I am not very familiar with PHP, I have run into a problem, which is probably quite easy to solve: Connecting to the database requires a couple lines of code, which I would rather not have to write on every single page, which needs the database connection. ($link = mysql_connect("host", "username", "password") or die("Could not connect : " . mysql_error()); mysql_select_db("dbname") or die("Could not select database.");) In ASP this is easy to solve, since I would just create a "global.asa" and on the Application_OnStart procedure, I would create the global database connection and then reference to that variable on each of the individual pages. Now, in PHP I do not seem to be able to create a "global.asa" or anything similar. It does not even seem to have an "Application" object, which I can refer to on any page. Can anyone tell me how I can connect to the MySQL database from some kind of a global page, being activated no matter which page the user starts on and where I only need to write the different SQL statements in the individual pages. (In ASP I could do the following on the individual page: Set RS = Application("conn").Execute("SELECT * FROM database") Thank you. Morten -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MySQL Session
I have just recently entered the world of PHP and MySQL. I'm used to code in ASP with Access databases and since I am not very familiar with PHP, I have run into a problem, which is probably quite easy to solve: Connecting to the database requires a couple lines of code, which I would rather not have to write on every single page, which needs the database connection. ($link = mysql_connect("host", "username", "password") or die("Could not connect : " . mysql_error()); mysql_select_db("dbname") or die("Could not select database.");) In ASP this is easy to solve, since I would just create a "global.asa" and on the Application_OnStart procedure, I would create the global database connection and then reference to that variable on each of the individual pages. Now, in PHP I do not seem to be able to create a "global.asa" or anything similar. It does not even seem to have an "Application" object, which I can refer to on any page. Can anyone tell me how I can connect to the MySQL database from some kind of a global page, being activated no matter which page the user starts on and where I only need to write the different SQL statements in the individual pages. (In ASP I could do the following on the individual page: Set RS = Application("conn").Execute("SELECT * FROM database") Thank you. Morten -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MYSQL and PHP cast() function...
I have tried the column as a varchar and timestamp but it does not work. with the Timestamp setup and DATE_FORMAT() I get 00-00- at the moment and I know that there are dates in there. The reason for this is the import changes all the field to 00 which is the TimeStamp default. I have also renamed the column to ReleaseDate in case there was a problem using a reserved word and there was still no fix. - Original Message - From: "CPT John W. Holmes" <[EMAIL PROTECTED]> To: "Morgan Bardon" <[EMAIL PROTECTED]>; "Moreno Riccardi" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Friday, July 25, 2003 4:44 PM Subject: Re: [PHP-DB] MYSQL and PHP cast() function... > > Thanks for that, but I get a NULL entry in the field then for all the > dates. > > What column type is the DATE column? Also, since DATE is a reserved word in > MySQL, naming a column DATE probably wasn't a good idea. If you know you > always want the first 11 characters, you can always do LEFT(Date,11) to > retrieve them. DATE_FORMAT() will only work if your column is a date or time > column, i.e. DATE, DATETIME, or TIMESTAMP. > > ---John Holmes... > > > - Original Message - > > From: "Moreno Riccardi" <[EMAIL PROTECTED]> > > To: "Morgan Bardon" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> > > Sent: Friday, July 25, 2003 4:34 PM > > Subject: R: [PHP-DB] MYSQL and PHP cast() function... > > > > > > > Try > > > $query2 = "select Title, date_format(Date,'%d-%m-%Y) as Date, Artist, > > > Country, > > > RecordCompany, CatalogueNumber, Composer FROM recording where title > regexp > > > '$keyword'"; > > > > > > Hi, > > > Moreno > > > -Messaggio originale- > > > Da: Morgan Bardon [mailto:[EMAIL PROTECTED] > > > Inviato: venerdì 25 luglio 2003 17.17 > > > A: [EMAIL PROTECTED] > > > Oggetto: [PHP-DB] MYSQL and PHP cast() function... > > > > > > > > > Hi there, > > > > > > I have been trying to get a solution to this select query from all over > > the > > > web and have found no answer so I was hoping someone here could help > out. > > > The date field of the database is imported from a text file with the > date > > > format 'dd-mm- hh:mm:ss' and I only want to display the first 11 > > > characters of the field. > > > > > > The select statment is am using is > > > $query2 = "select Title, cast(Date as varchar(11)) Date, Artist, > Country, > > > RecordCompany, CatalogueNumber, Composer FROM recording where title > regexp > > > '$keyword'"; > > > > > > However when I try to use this I get an error about the cast function as > > > follows: > > > > > > You have an error in your SQL syntax near '(Date as varchar(11)) Date, > > > Artist, Country, RecordCompany, CatalogueNumber, Com' at line 1 > > > > > > Can anyone help me with the cast() function. I have gotten this to work > on > > > an internal MSSQL server but not on the MySQL server. > > > > > > thanks > > > > > > Morgan Bardon > > > > > > > > > > > > > > > > > > -- > > > 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
[PHP-DB] R: [PHP-DB] MYSQL and PHP cast() function...
There's a mistake try this: $query2 = "select Title, date_format(Date,'%d-%m-%Y') as fDate, Artist, Country, RecordCompany, CatalogueNumber, Composer FROM recording where title regexp '$keyword'"; -Messaggio originale- Da: Morgan Bardon [mailto:[EMAIL PROTECTED] Inviato: venerdì 25 luglio 2003 17.39 A: Moreno Riccardi; [EMAIL PROTECTED] Oggetto: Re: [PHP-DB] MYSQL and PHP cast() function... Thanks for that, but I get a NULL entry in the field then for all the dates. - Original Message - From: "Moreno Riccardi" <[EMAIL PROTECTED]> To: "Morgan Bardon" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Friday, July 25, 2003 4:34 PM Subject: R: [PHP-DB] MYSQL and PHP cast() function... > Try > $query2 = "select Title, date_format(Date,'%d-%m-%Y) as Date, Artist, > Country, > RecordCompany, CatalogueNumber, Composer FROM recording where title regexp > '$keyword'"; > > Hi, > Moreno > -Messaggio originale----- > Da: Morgan Bardon [mailto:[EMAIL PROTECTED] > Inviato: venerdì 25 luglio 2003 17.17 > A: [EMAIL PROTECTED] > Oggetto: [PHP-DB] MYSQL and PHP cast() function... > > > Hi there, > > I have been trying to get a solution to this select query from all over the > web and have found no answer so I was hoping someone here could help out. > The date field of the database is imported from a text file with the date > format 'dd-mm- hh:mm:ss' and I only want to display the first 11 > characters of the field. > > The select statment is am using is > $query2 = "select Title, cast(Date as varchar(11)) Date, Artist, Country, > RecordCompany, CatalogueNumber, Composer FROM recording where title regexp > '$keyword'"; > > However when I try to use this I get an error about the cast function as > follows: > > You have an error in your SQL syntax near '(Date as varchar(11)) Date, > Artist, Country, RecordCompany, CatalogueNumber, Com' at line 1 > > Can anyone help me with the cast() function. I have gotten this to work on > an internal MSSQL server but not on the MySQL server. > > thanks > > Morgan Bardon > > > > > > -- > 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] MYSQL and PHP cast() function...
> Thanks for that, but I get a NULL entry in the field then for all the dates. What column type is the DATE column? Also, since DATE is a reserved word in MySQL, naming a column DATE probably wasn't a good idea. If you know you always want the first 11 characters, you can always do LEFT(Date,11) to retrieve them. DATE_FORMAT() will only work if your column is a date or time column, i.e. DATE, DATETIME, or TIMESTAMP. ---John Holmes... > - Original Message - > From: "Moreno Riccardi" <[EMAIL PROTECTED]> > To: "Morgan Bardon" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> > Sent: Friday, July 25, 2003 4:34 PM > Subject: R: [PHP-DB] MYSQL and PHP cast() function... > > > > Try > > $query2 = "select Title, date_format(Date,'%d-%m-%Y) as Date, Artist, > > Country, > > RecordCompany, CatalogueNumber, Composer FROM recording where title regexp > > '$keyword'"; > > > > Hi, > > Moreno > > -Messaggio originale----- > > Da: Morgan Bardon [mailto:[EMAIL PROTECTED] > > Inviato: venerdì 25 luglio 2003 17.17 > > A: [EMAIL PROTECTED] > > Oggetto: [PHP-DB] MYSQL and PHP cast() function... > > > > > > Hi there, > > > > I have been trying to get a solution to this select query from all over > the > > web and have found no answer so I was hoping someone here could help out. > > The date field of the database is imported from a text file with the date > > format 'dd-mm- hh:mm:ss' and I only want to display the first 11 > > characters of the field. > > > > The select statment is am using is > > $query2 = "select Title, cast(Date as varchar(11)) Date, Artist, Country, > > RecordCompany, CatalogueNumber, Composer FROM recording where title regexp > > '$keyword'"; > > > > However when I try to use this I get an error about the cast function as > > follows: > > > > You have an error in your SQL syntax near '(Date as varchar(11)) Date, > > Artist, Country, RecordCompany, CatalogueNumber, Com' at line 1 > > > > Can anyone help me with the cast() function. I have gotten this to work on > > an internal MSSQL server but not on the MySQL server. > > > > thanks > > > > Morgan Bardon > > > > > > > > > > > > -- > > 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] MYSQL and PHP cast() function...
Thanks for that, but I get a NULL entry in the field then for all the dates. - Original Message - From: "Moreno Riccardi" <[EMAIL PROTECTED]> To: "Morgan Bardon" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Friday, July 25, 2003 4:34 PM Subject: R: [PHP-DB] MYSQL and PHP cast() function... > Try > $query2 = "select Title, date_format(Date,'%d-%m-%Y) as Date, Artist, > Country, > RecordCompany, CatalogueNumber, Composer FROM recording where title regexp > '$keyword'"; > > Hi, > Moreno > -Messaggio originale- > Da: Morgan Bardon [mailto:[EMAIL PROTECTED] > Inviato: venerdì 25 luglio 2003 17.17 > A: [EMAIL PROTECTED] > Oggetto: [PHP-DB] MYSQL and PHP cast() function... > > > Hi there, > > I have been trying to get a solution to this select query from all over the > web and have found no answer so I was hoping someone here could help out. > The date field of the database is imported from a text file with the date > format 'dd-mm- hh:mm:ss' and I only want to display the first 11 > characters of the field. > > The select statment is am using is > $query2 = "select Title, cast(Date as varchar(11)) Date, Artist, Country, > RecordCompany, CatalogueNumber, Composer FROM recording where title regexp > '$keyword'"; > > However when I try to use this I get an error about the cast function as > follows: > > You have an error in your SQL syntax near '(Date as varchar(11)) Date, > Artist, Country, RecordCompany, CatalogueNumber, Com' at line 1 > > Can anyone help me with the cast() function. I have gotten this to work on > an internal MSSQL server but not on the MySQL server. > > thanks > > Morgan Bardon > > > > > > -- > 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] R: [PHP-DB] MYSQL and PHP cast() function...
Try $query2 = "select Title, date_format(Date,'%d-%m-%Y) as Date, Artist, Country, RecordCompany, CatalogueNumber, Composer FROM recording where title regexp '$keyword'"; Hi, Moreno -Messaggio originale- Da: Morgan Bardon [mailto:[EMAIL PROTECTED] Inviato: venerdì 25 luglio 2003 17.17 A: [EMAIL PROTECTED] Oggetto: [PHP-DB] MYSQL and PHP cast() function... Hi there, I have been trying to get a solution to this select query from all over the web and have found no answer so I was hoping someone here could help out. The date field of the database is imported from a text file with the date format 'dd-mm- hh:mm:ss' and I only want to display the first 11 characters of the field. The select statment is am using is $query2 = "select Title, cast(Date as varchar(11)) Date, Artist, Country, RecordCompany, CatalogueNumber, Composer FROM recording where title regexp '$keyword'"; However when I try to use this I get an error about the cast function as follows: You have an error in your SQL syntax near '(Date as varchar(11)) Date, Artist, Country, RecordCompany, CatalogueNumber, Com' at line 1 Can anyone help me with the cast() function. I have gotten this to work on an internal MSSQL server but not on the MySQL server. thanks Morgan Bardon -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MYSQL and PHP cast() function...
Hi there, I have been trying to get a solution to this select query from all over the web and have found no answer so I was hoping someone here could help out. The date field of the database is imported from a text file with the date format 'dd-mm- hh:mm:ss' and I only want to display the first 11 characters of the field. The select statment is am using is $query2 = "select Title, cast(Date as varchar(11)) Date, Artist, Country, RecordCompany, CatalogueNumber, Composer FROM recording where title regexp '$keyword'"; However when I try to use this I get an error about the cast function as follows: You have an error in your SQL syntax near '(Date as varchar(11)) Date, Artist, Country, RecordCompany, CatalogueNumber, Com' at line 1 Can anyone help me with the cast() function. I have gotten this to work on an internal MSSQL server but not on the MySQL server. thanks Morgan Bardon -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL full text search
Full text searches only work against fulltext indexes. http://www.mysql.com/doc/en/Fulltext_Search.html This isn't a PHP issue. Doug On Fri, 18 Jul 2003 09:42:17 +0200, Angelo Zanetti wrote: >Hi > >I have a table which contains 3 fields (ID, Title, Abstract) the title and abstract >fields have been fulltext indexes like this: > >ALTER TABLE biblio ADD FULLTEXT (title,abstract); > >that worked fine, however my problem is whenever I want to do a select statement only >comparing 1 of the columns to inputted data ( in a Select statement): > >$result = mysql_query("SELECT * FROM Biblio WHERE MATCH (title) AGAINST >('$searchString')"); > >It gives me this error: Can't find FULLTEXT index matching the column list. It >appears that i cant just compare a single fulltext indexed column if there are other >fulltext indexed columns. When I try it with both columns then it works but I just >want to compare 1 column. eg: >$result = mysql_query("SELECT * FROM Biblio WHERE MATCH (title, abstract) AGAINST >('$searchString')"); > >So is there anyway that I can just compare 1 column with text entered? Do I have t >make some sort of temporary table to do this? All the examples I have found show the >select statement with 2 columns or if they use 1 coumn its because there is only 1 >column in their table. > >Any help would be appreciated! > >TIA > >Angelo > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MySQL full text search
Hi I have a table which contains 3 fields (ID, Title, Abstract) the title and abstract fields have been fulltext indexes like this: ALTER TABLE biblio ADD FULLTEXT (title,abstract); that worked fine, however my problem is whenever I want to do a select statement only comparing 1 of the columns to inputted data ( in a Select statement): $result = mysql_query("SELECT * FROM Biblio WHERE MATCH (title) AGAINST ('$searchString')"); It gives me this error: Can't find FULLTEXT index matching the column list. It appears that i cant just compare a single fulltext indexed column if there are other fulltext indexed columns. When I try it with both columns then it works but I just want to compare 1 column. eg: $result = mysql_query("SELECT * FROM Biblio WHERE MATCH (title, abstract) AGAINST ('$searchString')"); So is there anyway that I can just compare 1 column with text entered? Do I have t make some sort of temporary table to do this? All the examples I have found show the select statement with 2 columns or if they use 1 coumn its because there is only 1 column in their table. Any help would be appreciated! TIA Angelo
Re: [PHP-DB] MySQL connection
Have you installed the php_mysql module in PHP5, it is not included by default now. Where can I find this Library? in the extensions subdirectory You will need the latest PHP5 download as it was missed from the early ones ;) biosad.mail.ru WHAT ?!?!?!?! HOW THEY. IT IS NOT GOOD. It is very good for those of use who do not bother with MySQL at all. Take a look at Firebird :) -- Lester Caine - L.S.Caine Electronic Services -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL connection
> Have you installed the php_mysql module in PHP5, it is not > included by default now. Where can I find this Library? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL connection
I have: WinNT_4.00 Server Apache PHP_5 MySQL_4 [myscript.php] ... $link = mysql_pconnect(); ... - If you run "php.exe myscript.php", you'll get message: "Fatal error: Call to undefined function: mysql_pconnect()..." HOW TO DECIDE THIS PROBLEM ? Have you installed the php_mysql module in PHP5, it is not included by default now. -- Lester Caine - L.S.Caine Electronic Services -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MySQL connection
I have: WinNT_4.00 Server Apache PHP_5 MySQL_4 [myscript.php] ... $link = mysql_pconnect(); ... - If you run "php.exe myscript.php", you'll get message: "Fatal error: Call to undefined function: mysql_pconnect()..." HOW TO DECIDE THIS PROBLEM ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MySQL Extention in PHP5.0.0b2-dev
Apache 2.0.46 (Win32) PHP/5.0.0b2-dev w/ MySQL 4.1.0 I have a question about the mySQL extension in the aforementioned version of PHP Whenever I try to load the extension thru adding it to PHP.INI like so I get an error extension_dir = "C:\Servers\PHP\extensions" . . . extension = php_gd2.dll extension = php_mysql.dll The error says that "C:\Servers\PHP\extensions\php_mysql.dll" could not be loaded. However, it doesn't give the same error for php_gd2.dll, it loads fine. When I change the extension_dir to the wrong directory, it gives me errors for both DLLs. When the directory is right, I still get the error for the mysql extension Any Ideas? Thanks. Adam Lundrigan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL error message...
mysql knows. this means your query failed, $command resulted in an invalid result set. try adding: or die(mysql_error()); to any call to mysql_query ()so in your code use this: $result = mysql_query("$command",$mysqlHandle) or die(mysql_error()); - and - $resultw = mysql_query("$commandw",$mysqlHandle) or die(mysql_error()); that will give you all the info you need. hth jeff Keith Spiller <[EMAIL PROTECTED]To: [EMAIL PROTECTED] ve.com> cc: Keith Spiller <[EMAIL PROTECTED]> Subject: [PHP-DB] MySQL error message... 06/30/2003 12:47 PM Hello, Does anyone know what would cause this message? Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in c:\program files\easyphp\www\bod-rse\bod\menu.php3 on line 49... Here is the code: \n"; $count++; } // IF MENU VALUE == COMMITTEES if ($myrow[2] == "Committees") { echo " Committees "; $currdate = date("Y-m",time()); $cdate= explode("-" , $currdate); $cyear= $cdate[0]; $cmonth = $cdate[1]; if ($cmonth >=7 AND $cmonth <=12) $fyear = $cyear + 1; else $fyear = $cyear; $fyear2 = $fyear - 1; $syear = "$fyear2 - $fyear"; $commandw = "SELECT menuname, type, active, name FROM bod_board_boards WHERE type='committee' AND active='1' ORDER BY name ASC"; $resultw = mysql_query("$commandw",$mysqlHandle); while ($myroww = mysql_fetch_row($resultw)) { if ($myroww[0] !="") { echo " $myroww[0]"; } } //echo " What They Do"; } else { echo " $myrow[2]\n"; } } ?> Any help would be unendingly appreciated... Keith -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MySQL error message...
Hello, Does anyone know what would cause this message? Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in c:\program files\easyphp\www\bod-rse\bod\menu.php3 on line 49... Here is the code: \n"; $count++; } // IF MENU VALUE == COMMITTEES if ($myrow[2] == "Committees") { echo " Committees "; $currdate = date("Y-m",time()); $cdate= explode("-" , $currdate); $cyear= $cdate[0]; $cmonth = $cdate[1]; if ($cmonth >=7 AND $cmonth <=12) $fyear = $cyear + 1; else $fyear = $cyear; $fyear2 = $fyear - 1; $syear = "$fyear2 - $fyear"; $commandw = "SELECT menuname, type, active, name FROM bod_board_boards WHERE type='committee' AND active='1' ORDER BY name ASC"; $resultw = mysql_query("$commandw",$mysqlHandle); while ($myroww = mysql_fetch_row($resultw)) { if ($myroww[0] !="") { echo " $myroww[0]"; } } //echo " What They Do"; } else { echo " $myrow[2]\n"; } } ?> Any help would be unendingly appreciated... Keith -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] mysql lock
Hi, I've never used a lock on a MySQL table so far, but need one now. Two questions: 1. Do I set the lock by a normal query, but in the form of "LOCK TABLE WRITE", instead of "SELECT * FROM WHERE x = 1"? 2. Can I set the lock in one query, then perform multiple other queries on the table, in between which I do some PHP work, and then release the lock several queries and lines of PHP code later? -- anders thoresson -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] mysql database function problem
Hello Everybody! I tried to connect with a mysql databasem , but It shows the follow error: Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in c:\inetpub\wwwroot\ejercicios\cap11\cursor.php on line 25 Número de filas en el resultado: Warning: mysql_num_fields(): supplied argument is not a valid MySQL result resource in c:\inetpub\wwwroot\ejercicios\cap11\cursor.php on line 29 Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in c:\inetpub\wwwroot\ejercicios\cap11\cursor.php on line 32 Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in c:\inetpub\wwwroot\ejercicios\cap11\cursor.php on line 40 It seems doesn't recognize the mysql functions I wrote in the code, or did I something wrong? I'm a newbie trying to learn and I have php 4.3.2 with mysql 4.0.13 in a windows xp with ISS 5.0 and I've Installed those programs a lot of times trying to fix it up but the problem remains. I'll really appreciate any help. Andres -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL Backup, final script !!!
thnks, i will give it a shot "Armand Turpel" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I use an db abstraction class. You have to replace this by yours. Of > course you got a "Fatal error: Call to a member function on a > non-object" because such an object dosen't exist in your script. First > you have to connect to a database using mysql_connect() and using > mysql_query and mysql_fetch_row. > > Armand > > Nabil wrote: > > >thanks a lot for your response but i got > > > >Fatal error: Call to a member function on a non-object in > >c:\inetpub\wwwroot\dump.php on line 3 > >not that mysql is 3.23.53 > > > >my script is : > >/ > > >$sql = 'SHOW TABLES FROM chat'; > >$db->query($sql); > >while ($row = $db -> fetchRow ('DB_GETMODE_NUM') ) > >{ > >$sql = ' BACKUP TABLE '.$row[0].' TO "/db_backup" '; > >$db->query($sql); > >} > >?> > >/ > > > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL Backup, final script !!!
I use an db abstraction class. You have to replace this by yours. Of course you got a "Fatal error: Call to a member function on a non-object" because such an object dosen't exist in your script. First you have to connect to a database using mysql_connect() and using mysql_query and mysql_fetch_row. Armand Nabil wrote: thanks a lot for your response but i got Fatal error: Call to a member function on a non-object in c:\inetpub\wwwroot\dump.php on line 3 not that mysql is 3.23.53 my script is : / $sql = 'SHOW TABLES FROM chat'; $db->query($sql); while ($row = $db -> fetchRow ('DB_GETMODE_NUM') ) { $sql = ' BACKUP TABLE '.$row[0].' TO "/db_backup" '; $db->query($sql); } ?> / -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL Backup, final script !!!
thanks a lot for your response but i got Fatal error: Call to a member function on a non-object in c:\inetpub\wwwroot\dump.php on line 3 not that mysql is 3.23.53 my script is : / query($sql); while ($row = $db -> fetchRow ('DB_GETMODE_NUM') ) { $sql = ' BACKUP TABLE '.$row[0].' TO "/db_backup" '; $db->query($sql); } ?> / "Armand Turpel" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > You have only to modify it to your environement > It works with mysql >= 3.23.52 > > // Get all table names of the database > // > $sql = ' > SHOW TABLES > FROM >test_db > ; > $db->query($sql); > > > while($row = $db->fetchRow( 'DB_GETMODE_NUM')) > { > > $sql = ' > BACKUP TABLE > '.$row[0].' > TO > "/db_backup" > '; > $db->query($sql); > } > > Armand > > > > Nabil wrote: > > >I have been searching inside the mailing lists regarding the a PHP code that > >dump all or a selected databases from MySQL ... > >and haven't managed to get a script like PhpMyAdmin does... please any ready > >script or idea ... > > > > backup.sql"); ?> > >//Because it didn't work with me (on windows by example). > > > >All what I am thinking to do is a script that retrieved the database names > >then retrieve the tables names, then fields names and dump the data in an > >schema like mysqldump does > > > >any suggestions?? > > > >Cheers... > >Nabil > > > > > > > > > > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL Backup, final script !!!
Hi, You have only to modify it to your environement It works with mysql >= 3.23.52 // Get all table names of the database // $sql = ' SHOW TABLES FROM test_db ; $db->query($sql); while($row = $db->fetchRow( 'DB_GETMODE_NUM')) { $sql = ' BACKUP TABLE '.$row[0].' TO "/db_backup" '; $db->query($sql); } Armand Nabil wrote: I have been searching inside the mailing lists regarding the a PHP code that dump all or a selected databases from MySQL ... and haven't managed to get a script like PhpMyAdmin does... please any ready script or idea ... backup.sql"); ?> //Because it didn't work with me (on windows by example). All what I am thinking to do is a script that retrieved the database names then retrieve the tables names, then fields names and dump the data in an schema like mysqldump does any suggestions?? Cheers... Nabil -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MySQL Backup, final script !!!
I have been searching inside the mailing lists regarding the a PHP code that dump all or a selected databases from MySQL ... and haven't managed to get a script like PhpMyAdmin does... please any ready script or idea ... backup.sql"); ?> //Because it didn't work with me (on windows by example). All what I am thinking to do is a script that retrieved the database names then retrieve the tables names, then fields names and dump the data in an schema like mysqldump does any suggestions?? Cheers... Nabil -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL editor
> With the exception of phpmyadmin is there anything else out there that will > allow you to work on your mysql stuff remotely? Any of the programs will. The real questions whether you have permission to connect remotely, though... :) ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL editor
On Friday 20 June 2003 01:11, Creative Solutions New Media wrote: > With the exception of phpmyadmin is there anything else out there that will > allow you to work on your mysql stuff remotely? They should all allow you to access a remote installation of mysql. Now can we please move this topic to the mysql list where it belongs? -- 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 -- /* Everything should be built top-down, except this time. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php