Re: [PHP] Re: MySQL and PHP weirdness - RESOLVED
This has been resolved. A previous programmer had snuck in a function that would convert the value of the "description" field to a date value if it contained the word "Date". This has been fixed. On Tue, Feb 14, 2012 at 5:44 PM, David Robley wrote: > Richard S. Crawford wrote: > > > Bear with me here. I have a problem with PHP and MySQL that's been > > stumping me for a couple of days now. I'm not even sure how to describe > > it, so I'll just do my best. > > > > There's a row in our bugs database that looks like every other row in the > > table, but when it's pulled from the database and displayed in PHP, the > > "description" field -- which is defined as a "mediumtext" field -- is > > displayed as a date field with a value of 12/31/1969. Moreoever, when I > > use PHPMyAdmin to look at the row directly, the "description" field has > > the data that I expect it to. > > > > Just for fun, here's the text in question: > > > > Quarterly Course Set Up - Spring 2012 (114) > > Section Course titleCourse Start > Date > > 114MHI214 The Internet and the Future of Patient Care 04/02/2012 > > 114MHI212 Health Information Systems Analysis and Design 04/02/2012 > > Program administrator 2 users; Laurel Aroner - Susan Catron - Jennifer > > Kremer > > Instructors; > > MHI214; Peter Yellowlees > > MHI212; Robert Balch > > Per instructions from Rita Smith-Simms - I'm creating this task for > myself > > and based on instructions given which are that all listed courses are now > > to be backed-up and restored sooner (original course set up time-frame > was > > a month before course starts). > > Adding instructions - Follow the 52-step quarterly course set up process > > and information from the course matrix; if matrix incomplete, input > > information during this set up > > As you track your time each day, please include in the notes which > courses > > (use project code) you worked on and indicate either working on or > > completed. > > Create and notify by 2/15/2012 > > > > > > I've made sure there are no odd characters that would mess up how PHP is > > displaying the text. I've tried changing the field type from "mediumtext" > > to "text" but this didn't work. > > > > If anyone has any ideas as to why this might be happening -- or if I just > > wasn't clear -- please let me know. > > > > > > If phpmyadmin gives expected results and _your_ code doesn't, I'd be > suspicious of your code :-) > > It might be helpful for you to post relevant part(s) ofthe actual code you > are using. > > > > Cheers > -- > David Robley > > Man who run behind car get exhausted. > Today is Sweetmorn, the 46th day of Chaos in the YOLD 3178. > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Sláinte, Richard S. Crawford (rich...@underpope.com) http://www.underpope.com Publisher and Editor in Chief, Daikaijuzine (http://www.daikaijuzine.com)
Re: [PHP] Re: MySQL ID -- what happens when you run out of range?
On 1/25/2010 1:19 PM, Nathan Rixham wrote: Parham Doustdar wrote: Hello there, A friend called me today and was wondering what happens if the ID colomn of an MYSQL database, set to autoinc reaches the int limit. Will it return and begin choosing the ID's that have been deleted, or... what? you change it to bigint before that happens :) for a more accurate answer ask on the mysql forum? Or the e-mail list: my...@lists.mysql.com (though I understand the cross-pollination) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql create table with date or timestamp
On Thu, May 28, 2009 at 11:20 AM, Daniel Brown wrote: > On Thu, May 28, 2009 at 11:15, Andrew Ballard wrote: >> >> Make that a 'comma', not the 'coma' that I seem to be in. Â :-) > > Â Â Eh, it's your birthday. Â You're allowed. Â ;-P > > Â Â Happy birthday, by the way. > Thanks! It's a weak excuse, but I'll take it. :-) Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql create table with date or timestamp
On Thu, May 28, 2009 at 11:15 AM, Andrew Ballard wrote: > 2009/5/28 Grega Leskovsek : >> I GOT THIS ERROR when I tried first sample with when timestamp; >> >> >> ERROR 1064 (42000): You have an error in your SQL syntax; check the >> manual thatcorresponds to your MySQL server version for the right >> syntax to use near 'id(iddiary) )' at line 1 >> >> >> 2009/5/28 João Cândido de Souza Neto : >>> If you need date and hour the best way is: >>> >>> CREATE TABLE diary ( >>> iddiary int auto_increment not null, >>> imepriimek varchar(50), >>> when timestamp, >>> action varchar(30), >>> onfile varchar(100) >>> unique id(iddiary) >>> ); >> >> Please advice. Thanks in advance, Grega > > There is a coma missing between the lines for the last column and the > unique key. > > Andrew > Make that a 'comma', not the 'coma' that I seem to be in. :-) Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql create table with date or timestamp
On Thu, May 28, 2009 at 11:15, Andrew Ballard wrote: > > Make that a 'comma', not the 'coma' that I seem to be in. Â :-) Eh, it's your birthday. You're allowed. ;-P Happy birthday, by the way. -- daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql create table with date or timestamp
The problem was I didn't type a comma before unique id(iddary). Thanks to everybody for helping me on the seminar. Love, Grega 2009/5/28 LinuxManMikeC : > Actually, AUTO_INCREMENT is the correct syntax for MySQL.  I think the > problem is NOT NULL should come first: iddiary INT NOT NULL > AUTO_INCREMENT. > > 2009/5/28 João Cândido de Souza Neto : >> It´s not auto_increment, it´s auto increment. >> >> -- >> João Cândido de Souza Neto >> SIENS SOLUÃÃES EM GESTÃO DE NEGÃCIOS >> Fone: (0XX41) 3033-3636 - JS >> www.siens.com.br >> >> "Grega Leskovsek" escreveu na mensagem >> news:1df2d4810905280748uec4f425kaf14b6410caa...@mail.gmail.com... >> I GOT THIS ERROR when  I tried first sample with when timestamp; >> >> >> ERROR 1064 (42000): You have an error in your SQL syntax; check the >> manual thatcorresponds to your MySQL server version for the right >> syntax to use near 'id(iddiary) )' at line 1 >> >> >> 2009/5/28 João Cândido de Souza Neto : >>> If you need date and hour the best way is: >>> >>> CREATE TABLE diary ( >>> iddiary int auto_increment not null, >>> imepriimek varchar(50), >>> when timestamp, >>> action varchar(30), >>> onfile varchar(100) >>> unique id(iddiary) >>> ); >> >> Please advice. Thanks in advance, Grega >>> >>> if you need only date you can use: >>> >>> CREATE TABLE diary ( >>> iddiary int auto_increment not null, >>> imepriimek varchar(50), >>> when date, >>> action varchar(30), >>> onfile varchar(100) >>> unique id(iddiary) >>> ); >>> >>> To get formated date you should use: >>> >>> select date_format(when, "%T%W%e%c%y") from diary; >>> >>> To put data in this field you can use: >>> >>> insert into diary (when) values (str_to_date("10:55:14Thursday28509", >>> "%T%W%e%c%y")); >>> >>> >>> >>> -- >>> João Cândido de Souza Neto >>> SIENS SOLUÃÃES EM GESTÃO DE NEGÃCIOS >>> Fone: (0XX41) 3033-3636 - JS >>> www.siens.com.br >>> >>> "Grega Leskovsek" escreveu na mensagem >>> news:1df2d4810905280643y62a0f092p91fa2c57558d8...@mail.gmail.com... CREATE TABLE diary(iddiary int auto_increment not null, imepriimek varchar(50), when date("%T%W%e%c%y"), action varchar(30), onfile varchar(100) unique id(iddiary)); I tried the above and it didn't work. What must I do to create a table with full time and date. If I should use timestamp how do I convert thee timestamp in php back to "normal" time? (I also tried the mysql command: when timestamp and when date in the above first mysql clause but it didnt work ) Please help me. Thanks in advance, -- When the sun rises I receive and when it sets I forgive -> http://users.skavt.net/~gleskovs/ All the Love, Grega Leskov'sek >>> >>> >>> >>> -- >>> PHP General Mailing List (http://www.php.net/) >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >>> >> >> >> >> -- >> When the sun rises I receive and when it sets I forgive -> >> http://users.skavt.net/~gleskovs/ >> All the Love, Grega Leskov'sek >> >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- When the sun rises I receive and when it sets I forgive -> http://users.skavt.net/~gleskovs/ All the Love, Grega Leskov'sek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql create table with date or timestamp
2009/5/28 Grega Leskovsek : > I GOT THIS ERROR when  I tried first sample with when timestamp; > > > ERROR 1064 (42000): You have an error in your SQL syntax; check the > manual thatcorresponds to your MySQL server version for the right > syntax to use near 'id(iddiary) )' at line 1 > > > 2009/5/28 João Cândido de Souza Neto : >> If you need date and hour the best way is: >> >> CREATE TABLE diary ( >>  iddiary int auto_increment not null, >>  imepriimek varchar(50), >>  when timestamp, >>  action varchar(30), >>  onfile varchar(100) >>  unique id(iddiary) >> ); > > Please advice. Thanks in advance, Grega There is a coma missing between the lines for the last column and the unique key. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql create table with date or timestamp
Actually, AUTO_INCREMENT is the correct syntax for MySQL. I think the problem is NOT NULL should come first: iddiary INT NOT NULL AUTO_INCREMENT. 2009/5/28 João Cândido de Souza Neto : > It´s not auto_increment, it´s auto increment. > > -- > João Cândido de Souza Neto > SIENS SOLUÃÃES EM GESTÃO DE NEGÃCIOS > Fone: (0XX41) 3033-3636 - JS > www.siens.com.br > > "Grega Leskovsek" escreveu na mensagem > news:1df2d4810905280748uec4f425kaf14b6410caa...@mail.gmail.com... > I GOT THIS ERROR when  I tried first sample with when timestamp; > > > ERROR 1064 (42000): You have an error in your SQL syntax; check the > manual thatcorresponds to your MySQL server version for the right > syntax to use near 'id(iddiary) )' at line 1 > > > 2009/5/28 João Cândido de Souza Neto : >> If you need date and hour the best way is: >> >> CREATE TABLE diary ( >> iddiary int auto_increment not null, >> imepriimek varchar(50), >> when timestamp, >> action varchar(30), >> onfile varchar(100) >> unique id(iddiary) >> ); > > Please advice. Thanks in advance, Grega >> >> if you need only date you can use: >> >> CREATE TABLE diary ( >> iddiary int auto_increment not null, >> imepriimek varchar(50), >> when date, >> action varchar(30), >> onfile varchar(100) >> unique id(iddiary) >> ); >> >> To get formated date you should use: >> >> select date_format(when, "%T%W%e%c%y") from diary; >> >> To put data in this field you can use: >> >> insert into diary (when) values (str_to_date("10:55:14Thursday28509", >> "%T%W%e%c%y")); >> >> >> >> -- >> João Cândido de Souza Neto >> SIENS SOLUÃÃES EM GESTÃO DE NEGÃCIOS >> Fone: (0XX41) 3033-3636 - JS >> www.siens.com.br >> >> "Grega Leskovsek" escreveu na mensagem >> news:1df2d4810905280643y62a0f092p91fa2c57558d8...@mail.gmail.com... >>> CREATE TABLE diary(iddiary int auto_increment not null, imepriimek >>> varchar(50), when date("%T%W%e%c%y"), action varchar(30), onfile >>> varchar(100) unique id(iddiary)); >>> >>> I tried the above and it didn't work. What must I do to create a table >>> with full time and date. If I should use timestamp how do I convert >>> thee timestamp in php back to "normal" time? (I also tried the mysql >>> command: >>> when timestamp >>> and >>> when date >>> in the above first mysql clause but it didnt work >>> ) >>> >>> Please help me. Thanks in advance, >>> -- >>> When the sun rises I receive and when it sets I forgive -> >>> http://users.skavt.net/~gleskovs/ >>> All the Love, Grega Leskov'sek >> >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > > > -- > When the sun rises I receive and when it sets I forgive -> > http://users.skavt.net/~gleskovs/ > All the Love, Grega Leskov'sek > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql create table with date or timestamp
It´s not auto_increment, it´s auto increment. -- João Cândido de Souza Neto SIENS SOLUÃÃES EM GESTÃO DE NEGÃCIOS Fone: (0XX41) 3033-3636 - JS www.siens.com.br "Grega Leskovsek" escreveu na mensagem news:1df2d4810905280748uec4f425kaf14b6410caa...@mail.gmail.com... I GOT THIS ERROR when I tried first sample with when timestamp; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual thatcorresponds to your MySQL server version for the right syntax to use near 'id(iddiary) )' at line 1 2009/5/28 João Cândido de Souza Neto : > If you need date and hour the best way is: > > CREATE TABLE diary ( > iddiary int auto_increment not null, > imepriimek varchar(50), > when timestamp, > action varchar(30), > onfile varchar(100) > unique id(iddiary) > ); Please advice. Thanks in advance, Grega > > if you need only date you can use: > > CREATE TABLE diary ( > iddiary int auto_increment not null, > imepriimek varchar(50), > when date, > action varchar(30), > onfile varchar(100) > unique id(iddiary) > ); > > To get formated date you should use: > > select date_format(when, "%T%W%e%c%y") from diary; > > To put data in this field you can use: > > insert into diary (when) values (str_to_date("10:55:14Thursday28509", > "%T%W%e%c%y")); > > > > -- > João Cândido de Souza Neto > SIENS SOLUÃÃES EM GESTÃO DE NEGÃCIOS > Fone: (0XX41) 3033-3636 - JS > www.siens.com.br > > "Grega Leskovsek" escreveu na mensagem > news:1df2d4810905280643y62a0f092p91fa2c57558d8...@mail.gmail.com... >> CREATE TABLE diary(iddiary int auto_increment not null, imepriimek >> varchar(50), when date("%T%W%e%c%y"), action varchar(30), onfile >> varchar(100) unique id(iddiary)); >> >> I tried the above and it didn't work. What must I do to create a table >> with full time and date. If I should use timestamp how do I convert >> thee timestamp in php back to "normal" time? (I also tried the mysql >> command: >> when timestamp >> and >> when date >> in the above first mysql clause but it didnt work >> ) >> >> Please help me. Thanks in advance, >> -- >> When the sun rises I receive and when it sets I forgive -> >> http://users.skavt.net/~gleskovs/ >> All the Love, Grega Leskov'sek > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- When the sun rises I receive and when it sets I forgive -> http://users.skavt.net/~gleskovs/ All the Love, Grega Leskov'sek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql create table with date or timestamp
I GOT THIS ERROR when I tried first sample with when timestamp; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual thatcorresponds to your MySQL server version for the right syntax to use near 'id(iddiary) )' at line 1 2009/5/28 João Cândido de Souza Neto : > If you need date and hour the best way is: > > CREATE TABLE diary ( >  iddiary int auto_increment not null, >  imepriimek varchar(50), >  when timestamp, >  action varchar(30), >  onfile varchar(100) >  unique id(iddiary) > ); Please advice. Thanks in advance, Grega > > if you need only date you can use: > > CREATE TABLE diary ( >  iddiary int auto_increment not null, >  imepriimek varchar(50), >  when date, >  action varchar(30), >  onfile varchar(100) >  unique id(iddiary) > ); > > To get formated date you should use: > > select date_format(when, "%T%W%e%c%y") from diary; > > To put data in this field you can use: > > insert into diary (when) values (str_to_date("10:55:14Thursday28509", > "%T%W%e%c%y")); > > > > -- > João Cândido de Souza Neto > SIENS SOLUÃÃES EM GESTÃO DE NEGÃCIOS > Fone: (0XX41) 3033-3636 - JS > www.siens.com.br > > "Grega Leskovsek" escreveu na mensagem > news:1df2d4810905280643y62a0f092p91fa2c57558d8...@mail.gmail.com... >> CREATE TABLE diary(iddiary int auto_increment not null, imepriimek >> varchar(50), when date("%T%W%e%c%y"), action varchar(30), onfile >> varchar(100) unique id(iddiary)); >> >> I tried the above and it didn't work. What must I do to create a table >> with full time and date. If I should use timestamp how do I convert >> thee timestamp in php back to "normal" time? (I also tried the mysql >> command: >> when timestamp >> and >> when date >> in the above first mysql clause but it didnt work >> ) >> >> Please help me. Thanks in advance, >> -- >> When the sun rises I receive and when it sets I forgive -> >> http://users.skavt.net/~gleskovs/ >> All the Love, Grega Leskov'sek > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- When the sun rises I receive and when it sets I forgive -> http://users.skavt.net/~gleskovs/ All the Love, Grega Leskov'sek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MYSQL 5 auto increment not working
On Thu, May 21, 2009 at 9:34 AM, Nathan Rixham wrote: > Leidago !Noabeb wrote: > >> Hi All >> >> >> I know this is not strictly a PHP question, but i have a problem whenever >> i >> insert a record using PHP. Basically the auto increment field does not >> work >> at all. Here's the structure of the table that i'm using: >> >> CREATE TABLE `children` ( >> `cid` int(4) NOT NULL auto_increment, >> `cname` char(50) default NULL, >> `csname` char(50) default NULL, >> PRIMARY KEY (`cid`) >> ) ENGINE=InnoDB >> >> I use PHP 5.1 and MYSQL 5 >> >> I'm pretty sure the code i use to insert the data is sound since i've >> tested >> it with older versions of MYSQL. >> >> Has anyone else had similar problems? >> >> > *works for me* > > check cid is empty in your insert statement > check you haven't hit rows, seeing as you are using int 4 > drop and recreate the table (or truncate) > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > openfire is something you may want to look at...it has a flash client in there somewhere...also i believe you can find FLEX based IM chat code that you can use -- Bastien Cat, the other other white meat
Re: [PHP] Re: MySQL Workbench coming for Linux
Luke wrote: >so it's like Microsoft Access? I don't get it... No, Microsoft Access is a development environment sitting on top of a simplistic database (JET). Access gives you a nice GUI to help you interactively build up your database, and it makes a great prototyping tool and data massage tool, but it isn't very good for data modelling. I'm talking about proper data modelling tools, where you design the conceptual and physical databases, then generate scripts to build them (e.g. in Oracle, Microsoft SQL Server, MySQL, etc.) and generate nice documentation including diagrams that help you understand your database at a quick glance. Usually, they can also suck a live database back in (reverse engineer) to help you document whatever nasty hack you've inherited from your predecessors in a legacy application ;-) MySQL Workbench is what I really want, or something similar. I just happen to already have a copy of Visio Enterprise Architect that comes close enough to doing the job, so I use that until Workbench is up and working properly on Linux. I hack the generated SQL scripts (minimally) to make them MySQL friendly, and I hack the generated RTF data dictionary files to make them more to my liking, and load them into OOo and embed the ER diagrams, to get nice, easily referenced documentation on my DBs. See here for more information about data modelling tools in general, and a couple of specific ones: http://en.wikipedia.org/wiki/Entity-relationship_model http://en.wikipedia.org/wiki/CA_ERwin_Data_Modeler http://en.wikipedia.org/wiki/ER/Studio http://en.wikipedia.org/wiki/Toad_Data_Modeler http://en.wikipedia.org/wiki/MySQL_Workbench -- Ross McKay, Toronto, NSW Australia "Before enlightenment: chop wood, carry water; After enlightenment: chop wood, carry water" - Wu Li -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL Workbench coming for Linux
so it's like Microsoft Access? I don't get it... 2008/9/18 Ross McKay <[EMAIL PROTECTED]> > Bastien Koert wrote: > > >what about dia on llinux? Not quite as nice as visio...but livable > > The Enterprise Architect version of Visio lets you add column > definitions to your entities, add foreign key relationships, add > indices, add comments at the table and column level, and then generate a > build script. It also has a reporting tool for generating a data > dictionary. In short, it makes a pretty good stab at being a data > modelling tool (imperfectly, but sufficiently for my needs). > > Dia is just a diagramming tool (unless you can tell me otherwise). > -- > Ross McKay, Toronto, NSW Australia > "Nobody ever rioted for austerity" - George Monbiot > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Luke Slater
Re: [PHP] Re: MySQL Workbench coming for Linux
Bastien Koert wrote: >what about dia on llinux? Not quite as nice as visio...but livable The Enterprise Architect version of Visio lets you add column definitions to your entities, add foreign key relationships, add indices, add comments at the table and column level, and then generate a build script. It also has a reporting tool for generating a data dictionary. In short, it makes a pretty good stab at being a data modelling tool (imperfectly, but sufficiently for my needs). Dia is just a diagramming tool (unless you can tell me otherwise). -- Ross McKay, Toronto, NSW Australia "Nobody ever rioted for austerity" - George Monbiot -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL Workbench coming for Linux
On Wed, Sep 17, 2008 at 4:13 AM, Ross McKay <[EMAIL PROTECTED]> wrote: > On Wed, 17 Sep 2008 09:00:45 +0100, Luke wrote: > > >What is it? > > > >I'm only familiar with the MySQL tools such as Query Browser and Admin? > > http://dev.mysql.com/downloads/workbench/5.0.html > > In short, it's a data modelling tool. Such things are very handy for > designing and building databases, and usually also for documenting them. > If your DB has more than a handful of tables, it's well worth the > effort. > -- > Ross McKay, Toronto, NSW Australia > "Let the laddie play wi the knife - he'll learn" > - The Wee Book of Calvin > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > what about dia on llinux? Not quite as nice as visio...but livable -- Bastien Cat, the other other white meat
Re: [PHP] Re: MySQL Workbench coming for Linux
On Wed, 17 Sep 2008 09:00:45 +0100, Luke wrote: >What is it? > >I'm only familiar with the MySQL tools such as Query Browser and Admin? http://dev.mysql.com/downloads/workbench/5.0.html In short, it's a data modelling tool. Such things are very handy for designing and building databases, and usually also for documenting them. If your DB has more than a handful of tables, it's well worth the effort. -- Ross McKay, Toronto, NSW Australia "Let the laddie play wi the knife - he'll learn" - The Wee Book of Calvin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL Workbench coming for Linux
What is it? I'm only familiar with the MySQL tools such as Query Browser and Admin? 2008/9/17 Dax Solomon Umaming <[EMAIL PROTECTED]> > Ross McKay wrote: > > Posting this here, because a few people responded when I mentioned not > > having a Linux-native data modelling tool. Apparently, MySQL Workbench > > should be alpha-ready by end of the month... > > I've been waiting for this. I'm getting tired of DBDesigner4's bugs and > all. > > -- > Dax Solomon Umaming > http://blog.knightlust.com/ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Luke Slater
Re: [PHP] Re: MySQL Group?
John Taylor-Johnston wrote: Thanks for getting me started. (Sorry, I'm a top quoter.) Below is some working code for the archives. What I've learned so far is that : 1) what I'm referring to in `person` has to be a key. It should be a unique item rather than just a 'key' (indexed item). If you add this data: insert into person(name, email) values ('my name', '[EMAIL PROTECTED]'); insert into person(name, email) values ('another name', '[EMAIL PROTECTED]'); and I share an email address, and you use "email" as the foreign key, which one is it going to link to? Mysql should really throw an error if you try to reference a non-unique field or combination of fields - every other db does. A unique key can cover more than one field: create table person ( person_id int primary key, name varchar(255), email varchar(255), unique key (name, email) ) engine=innodb; So you can only have one combination of name & email then you can use that as a foreign key: create table shopping ( shopping_id int primary key, person_name varchar(255), person_email varchar(255), foreign key (person_name, person_email) references person(name,email) ) engine=innodb; Though I'd suggest starting off with the person_id (primary key) as the foreign key so you don't have data redundancy and integrity issues (unless you use "on update cascade"). I'd also suggest getting an intro-to-sql book as this is all reasonably basic stuff. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL Group?
Thanks for getting me started. (Sorry, I'm a top quoter.) Below is some working code for the archives. What I've learned so far is that : 1) what I'm referring to in `person` has to be a key. 2) if I want to refer to more than one field from person in shopping, I have to use unique keys. I'm still discovering what keys are for. John DROP TABLE IF EXISTS `person`; CREATE TABLE `person` ( `person_id` int(11) NOT NULL auto_increment, `name` varchar(255) default NULL, `email` varchar(255) default NULL, PRIMARY KEY (`person_id`), KEY `email` (`email`), KEY `name` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; INSERT INTO `person`( `person_id`, `name`, `email` ) VALUES ( 1, 'Name', '[EMAIL PROTECTED]' ) ; INSERT INTO `person`( `person_id`, `name`, `email` ) VALUES ( 2, 'second Name', '[EMAIL PROTECTED]' ) ; DROP TABLE IF EXISTS `shopping`; CREATE TABLE IF NOT EXISTS `shopping` ( `shopping_id` int(11) NOT NULL, `email` varchar(255) default NULL, `name` varchar(255) default NULL, PRIMARY KEY (`shopping_id`), UNIQUE KEY `email` (`email`), UNIQUE KEY `name` (`name`), FOREIGN KEY (`email`) REFERENCES `person` (`email`), FOREIGN KEY (`name`) REFERENCES `person` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; You end up with something like this: create table person ( person_id int primary key, name varchar(255), email varchar(255) ) engine=innodb; create table shopping ( shopping_id int primary key, person_id int, foreign key (person_id) references person(person_id) ) engine=innodb; insert into person(person_id,name,email) values(1,'Name','[EMAIL PROTECTED]'); insert into shopping(shopping_id, person_id) values(1, 1); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL Group?
George J wrote: Hi John, "John Taylor-Johnston" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Does anyone know of a good MySQL group? I want to make a relational link from `data` to `shopping` so when I insert a new record in `shopping`, I will see the contents of `data`.`name` and `data`.`email` as a drop-down menu in `shopping`. Where does one go to get this kind of help? Thanks, John DROP TABLE IF EXISTS `data`; CREATE TABLE `data` ( `id` int(5) NOT NULL auto_increment, `name` varchar(255) NOT NULL, `email` varchar(255) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; INSERT INTO `data` VALUES(1, 'Allen, Carolyn', '[EMAIL PROTECTED]'); INSERT INTO `data` VALUES(2, 'Atwood, Margaret', '[EMAIL PROTECTED]'); DROP TABLE IF EXISTS `shopping`; CREATE TABLE `shopping` ( `id` int(5) NOT NULL auto_increment, `name` varchar(100) NOT NULL, `address` varchar(100) NOT NULL, `email` varchar(100) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ; I'm not certain but think you need to include a 'references table_name(field_name)' clause that sets up the Foreign key relationship between the 2 tables. I think the Reference clause would replace the auto_increment in your primary key of the referencing table. The references goes into the secondary table, not the main one and it definitely doesn't replace the auto_increment field. You end up with something like this: create table person ( person_id int primary key, name varchar(255), email varchar(255) ) engine=innodb; create table shopping ( shopping_id int primary key, person_id int, foreign key (person_id) references person(person_id) ) engine=innodb; insert into person(person_id,name,email) values(1,'Name','[EMAIL PROTECTED]'); insert into shopping(shopping_id, person_id) values(1, 1); The 'person' table still needs at least a unique field for the field being referenced (the foreign key), usually a primary key (and if necessary an auto_increment). The secondary table uses that key to check: - if that id exists: insert into shopping(shopping_id, person_id) values (2,2); ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails - if it should delete that id (when using "on delete cascade") mysql> delete from person where person_id=1; Query OK, 1 row affected (0.00 sec) mysql> select * from shopping; Empty set (0.00 sec) - if it needs to be updated (when using "on update cascade") mysql> update person set person_id=2 where person_id=1; Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from shopping; +-+---+ | shopping_id | person_id | +-+---+ | 1 | 2 | +-+---+ 1 row in set (0.00 sec) See manual for more examples: http://dev.mysql.com/doc/refman/4.1/en/innodb-foreign-key-constraints.html -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql input
Filter the data $data = str_replace("'", "", $data); I am sure there are many ways to filter the data before insert. (If you are SURE you have "A.D.D." then it wont matter what I say to you.) Rick B. On Feb 18, 2008 11:24 PM, Shawn McKenzie <[EMAIL PROTECTED]> wrote: > nihilism machine wrote: > > I have a user saving a VARCHAR(255) field in a mysql db which has single > > quotes in the text, how can i replace them so that they dont fuck up my > > mysql command? > > > > -e > > > Have you tried: dont_fuck_up_my_mysql_command() That has thrown E_DEPRECATED since PHP 4.1. RTFM, n00b. ;-D -- Daniel P. Brown Senior Unix Geek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql input
On Feb 18, 2008 11:24 PM, Shawn McKenzie <[EMAIL PROTECTED]> wrote: > nihilism machine wrote: > > I have a user saving a VARCHAR(255) field in a mysql db which has single > > quotes in the text, how can i replace them so that they dont fuck up my > > mysql command? > > > > -e > > > Have you tried: dont_fuck_up_my_mysql_command() That has thrown E_DEPRECATED since PHP 4.1. RTFM, n00b. ;-D -- Daniel P. Brown Senior Unix Geek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql input
Bastien Koert wrote: thats awesome bastien> To: php-general@lists.php.net> Date: Tue, 19 Feb 2008 11:21:02 +> From: [EMAIL PROTECTED]> Subject: Re: [PHP] Re: mysql input> > Zoltán Németh wrote:> > 2008. 02. 19, kedd keltezéssel 11.03-kor Nathan Rixham ezt írta:> >> Richard Heyes wrote:> >>> Shawn McKenzie wrote:> >>>> nihilism machine wrote:> >>>>> I have a user saving a VARCHAR(255) field in a mysql db which has single> >>>>> quotes in the text, how can i replace them so that they dont fuck up my> >>>>> mysql command?> >>>>>> >>>>> -e> >>>>> >>>> Have you tried: dont_fuck_up_my_mysql_command()> >>> Hrmph, I can't seem to find that in the manual...> >>>> >> it's been depricated I heard in favour of unfuck();> >>> > > > as I remember its also in SPL.> > $whatever = new MySqlCommandUnFucker($command);> > $whatever->unFuck();> > > > :D> > > > greets> > Zoltán Németh> > > class MySqlCommandUnFucker {> > public function _unfucker($toUnFuck) {> if(function_exists('get_magic_quotes_gpc')) {> if (get_mag ic_quotes_gpc()) {> $in = stripslashes($toUnFuck);> }> }> return $in;> }> > public function unFuck($fucked) {> if(function_exists('mysql_real_escape_string')) {> return mysql_real_escape_string($this->_unfucker($fucked));> } else {> return $fucked;> }> }> }> ?>> > > usage:> $unfucker = new MySqlCommandUnFucker;> $sql = $unfucker ->unFuck($sql);> > :)> > -- > PHP General Mailing List (http://www.php.net/)> To unsubscribe, visit: http://www.php.net/unsub.php> _ :) although $in should be $toUnFuck; just can't be bothered chanign a mock class again! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: mysql input
thats awesome bastien> To: php-general@lists.php.net> Date: Tue, 19 Feb 2008 11:21:02 +> From: [EMAIL PROTECTED]> Subject: Re: [PHP] Re: mysql input> > Zoltán Németh wrote:> > 2008. 02. 19, kedd keltezéssel 11.03-kor Nathan Rixham ezt írta:> >> Richard Heyes wrote:> >>> Shawn McKenzie wrote:> >>>> nihilism machine wrote:> >>>>> I have a user saving a VARCHAR(255) field in a mysql db which has single> >>>>> quotes in the text, how can i replace them so that they dont fuck up my> >>>>> mysql command?> >>>>>> >>>>> -e> >>>>> >>>> Have you tried: dont_fuck_up_my_mysql_command()> >>> Hrmph, I can't seem to find that in the manual...> >>>> >> it's been depricated I heard in favour of unfuck();> >>> > > > as I remember its also in SPL.> > $whatever = new MySqlCommandUnFucker($command);> > $whatever->unFuck();> > > > :D> > > > greets> > Zoltán Németh> > > class MySqlCommandUnFucker {> > public function _unfucker($toUnFuck) {> if(function_exists('get_magic_quotes_gpc')) {> if (get_magic_quotes_gpc()) {> $in = stripslashes($toUnFuck);> }> }> return $in;> }> > public function unFuck($fucked) {> if(function_exists('mysql_real_escape_string')) {> return mysql_real_escape_string($this->_unfucker($fucked));> } else {> return $fucked;> }> }> }> ?>> > > usage:> $unfucker = new MySqlCommandUnFucker;> $sql = $unfucker ->unFuck($sql);> > :)> > -- > PHP General Mailing List (http://www.php.net/)> To unsubscribe, visit: http://www.php.net/unsub.php> _
Re: [PHP] Re: mysql input
Nathan Rixham wrote: Zoltán Németh wrote: 2008. 02. 19, kedd keltezéssel 11.03-kor Nathan Rixham ezt írta: Richard Heyes wrote: Shawn McKenzie wrote: nihilism machine wrote: I have a user saving a VARCHAR(255) field in a mysql db which has single quotes in the text, how can i replace them so that they dont fuck up my mysql command? -e Have you tried: dont_fuck_up_my_mysql_command() Hrmph, I can't seem to find that in the manual... it's been depricated I heard in favour of unfuck(); as I remember its also in SPL. $whatever = new MySqlCommandUnFucker($command); $whatever->unFuck(); :D greets Zoltán Németh public function unFuck($fucked) { if(function_exists('mysql_real_escape_string')) { return mysql_real_escape_string($this->_unfucker($fucked)); } else { return $fucked; } } } ?> usage: $unfucker = new MySqlCommandUnFucker; $sql = $unfucker ->unFuck($sql); :) apologies! a slight correction for nihilism (the class does work..) usage: $unfucker = new MySqlCommandUnFucker; $sql = "INSERT INTO tablename (varcol) VALUES ('"; $sql .= $unfucker->unFuck($myfuckedvariable); $sql .= "')"; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql input
Zoltán Németh wrote: 2008. 02. 19, kedd keltezéssel 11.03-kor Nathan Rixham ezt írta: Richard Heyes wrote: Shawn McKenzie wrote: nihilism machine wrote: I have a user saving a VARCHAR(255) field in a mysql db which has single quotes in the text, how can i replace them so that they dont fuck up my mysql command? -e Have you tried: dont_fuck_up_my_mysql_command() Hrmph, I can't seem to find that in the manual... it's been depricated I heard in favour of unfuck(); as I remember its also in SPL. $whatever = new MySqlCommandUnFucker($command); $whatever->unFuck(); :D greets Zoltán Németh _unfucker($fucked)); } else { return $fucked; } } } ?> usage: $unfucker = new MySqlCommandUnFucker; $sql = $unfucker ->unFuck($sql); :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql input
2008. 02. 19, kedd keltezéssel 11.03-kor Nathan Rixham ezt írta: > Richard Heyes wrote: > > Shawn McKenzie wrote: > >> nihilism machine wrote: > >>> I have a user saving a VARCHAR(255) field in a mysql db which has single > >>> quotes in the text, how can i replace them so that they dont fuck up my > >>> mysql command? > >>> > >>> -e > >> > >> > >> Have you tried: dont_fuck_up_my_mysql_command() > > > > Hrmph, I can't seem to find that in the manual... > > > > it's been depricated I heard in favour of unfuck(); > as I remember its also in SPL. $whatever = new MySqlCommandUnFucker($command); $whatever->unFuck(); :D greets Zoltán Németh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql input
Richard Heyes wrote: Shawn McKenzie wrote: nihilism machine wrote: I have a user saving a VARCHAR(255) field in a mysql db which has single quotes in the text, how can i replace them so that they dont fuck up my mysql command? -e Have you tried: dont_fuck_up_my_mysql_command() Hrmph, I can't seem to find that in the manual... it's been depricated I heard in favour of unfuck(); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql input
Shawn McKenzie wrote: nihilism machine wrote: I have a user saving a VARCHAR(255) field in a mysql db which has single quotes in the text, how can i replace them so that they dont fuck up my mysql command? -e Have you tried: dont_fuck_up_my_mysql_command() Hrmph, I can't seem to find that in the manual... -- Richard Heyes http://www.websupportsolutions.co.uk Knowledge Base and Helpdesk software hosted for you - no installation, no maintenance, new features automatic and free -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL exceptions
Em Terça 10 Abril 2007 19:26, Richard Lynch escreveu: > > I don't think MySQL or even mysqli have any kind of exception throwing > yet, if ever. Googling a bit more, I think that MySQL already have some exceptions [1], the question, now, is: how to catch them with PHP? =] I think that just using the exceptions name I can do that... So... Let's make some testes... =] > > > i.e.: with if-then-else: > > > > $connect=mysql_connect(...); > > > > if($connect) > > { > > if(!(mysql_select_db(...,$connect))) > > { > > echo "Impossible select db."; > > } > > } > > else > > { > > echo "Impossible connect to server."; > > } > > If you didn't connect to the server, doing the select_db is rather > pointless, so I'd check the $connect FIRST, and deal with that > completely before trying to use a dead connection. If I don't connect to server, I'll echo an error... Otherwise, I'll select DB... > > You don't put more money into the phone if the line is dead, do you? > > :-) > : > > There is nothing you'd be able to get from a thrown exception that you > can't get with mysql_errno() and vice versa, in theory. Sure! But with try-catch, I get some advantages [2]... It's a _big_ project... So, I _need_ OOP structure... > > In reality, it will probably be some time before every possile MySQL > error code number (and they are legion) would be encapsulated as an > Exception. > > So for maxiumu customization, short-term, mysql_errno() is probably > the way to go. > > I often, for example, simply want to IGNORE mysql_errno($connection) > == 1062 becaue it's just a duplicate key insert, and that means I've > already dealt with whatever I was trying to insert, and just don't > care. > > -- BTW, thanks a lot... =] [1] - http://ehuss.org/mysql/api/mysql.exceptions-module.html [2] - http://java.sun.com/docs/books/tutorial/essential/exceptions/advantages.html -- Davi Vidal [EMAIL PROTECTED] [EMAIL PROTECTED] -- Agora com fortune: "You know you're using the computer too much when: when your life becomes routine enough to write a script to do it for you. -- smonijhay1" -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL exceptions
On Mon, April 9, 2007 6:34 pm, Davi wrote: > Em Segunda 09 Abril 2007 21:21, itoctopus escreveu: >> Use the @ in front of the statement and then check the result if >> it's >> valid. >> >> -- >> itoctopus - http://www.itoctopus.com > > > I already use it, but I believe that try-catch would be _more_ > useful... > With try-cath I can _get_ more errors instead with a if-then-else > clasule... I don't think MySQL or even mysqli have any kind of exception throwing yet, if ever. > i.e.: with if-then-else: > > $connect=mysql_connect(...); > > if($connect) > { > if(!(mysql_select_db(...,$connect))) > { > echo "Impossible select db."; > } > } > else > { > echo "Impossible connect to server."; > } If you didn't connect to the server, doing the select_db is rather pointless, so I'd check the $connect FIRST, and deal with that completely before trying to use a dead connection. You don't put more money into the phone if the line is dead, do you? :-) > If I want to get some debug info, I put some mysql_error() and I get > the error > string and error code (mysql_errno()), but I believe that with > exception I > can get some useful error message without... hum... *critical* > infos... There is nothing you'd be able to get from a thrown exception that you can't get with mysql_errno() and vice versa, in theory. In reality, it will probably be some time before every possile MySQL error code number (and they are legion) would be encapsulated as an Exception. So for maxiumu customization, short-term, mysql_errno() is probably the way to go. I often, for example, simply want to IGNORE mysql_errno($connection) == 1062 becaue it's just a duplicate key insert, and that means I've already dealt with whatever I was trying to insert, and just don't care. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL exceptions
Em Segunda 09 Abril 2007 21:21, itoctopus escreveu: > Use the @ in front of the statement and then check the result if it's > valid. > > -- > itoctopus - http://www.itoctopus.com I already use it, but I believe that try-catch would be _more_ useful... With try-cath I can _get_ more errors instead with a if-then-else clasule... i.e.: with if-then-else: $connect=mysql_connect(...); if($connect) { if(!(mysql_select_db(...,$connect))) { echo "Impossible select db."; } } else { echo "Impossible connect to server."; } If I want to get some debug info, I put some mysql_error() and I get the error string and error code (mysql_errno()), but I believe that with exception I can get some useful error message without... hum... *critical* infos... try { $connect=mysql_connect(...); mysql_select_db(...,$connect); } catch (CONNECTION_EXCEPTION $e) { echo "Impossible connect: ".$e->get_message(); } catch (SELECT_EXCEPTION $e) { echo "Impossible select db: ".$e->get_message(); } catch (ANOTHER_USEFUL_EXCEPTION $e) { echo "another error: ".$e->get_message(); } catch (Exception $e) { echo "Unknown error: ".$e->get_message(); } I'm right? TIA -- Davi Vidal [EMAIL PROTECTED] [EMAIL PROTECTED] -- Agora com fortune: "Stanford women are responsible for the success of many Stanford men: they give them "just one more reason" to stay in and study every night." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: mysql ORDER BY problem
Just do: SELECT * FROM thetable ORDER BY yourfieldyouwanttoorder If you want it in reverse order you add DESC in the end. /Peter -Original Message- From: John Nichel [mailto:[EMAIL PROTECTED] Sent: Monday, June 19, 2006 5:51 AM To: php-general@lists.php.net Subject: Re: [PHP] Re: mysql ORDER BY problem Rob W. wrote: > It's not in general to mysql, it's how php and mysql is displaying it. > That's not what you asked. You asked how to do it with your query, which has nothing, nadda, zip to do with PHP. You want MySQL to do the sorting, look at the MySQL manual under the select syntax, or ask on the MySQL list. You want PHP to do the sorting, look at PHP's array functions; however, it'd be more efficient to go the MySQL route. > - Original Message - From: "Michael Rasmussen" <[EMAIL PROTECTED]> > To: > Sent: Sunday, June 18, 2006 4:51 PM > Subject: [PHP] Re: mysql ORDER BY problem > > >> On Sun, 18 Jun 2006 15:55:14 -0500, Rob W. wrote: >> >>> >>> Is there a way with my mysql query so that I can list the numbers in >>> correct order? >>> >> In what way is this problem related to PHP? >> Try a MySQL group instead. >> -- By-Tor.com ...it's all about the Rush http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql ORDER BY problem
Rob W. wrote: It's not in general to mysql, it's how php and mysql is displaying it. That's not what you asked. You asked how to do it with your query, which has nothing, nadda, zip to do with PHP. You want MySQL to do the sorting, look at the MySQL manual under the select syntax, or ask on the MySQL list. You want PHP to do the sorting, look at PHP's array functions; however, it'd be more efficient to go the MySQL route. - Original Message - From: "Michael Rasmussen" <[EMAIL PROTECTED]> To: Sent: Sunday, June 18, 2006 4:51 PM Subject: [PHP] Re: mysql ORDER BY problem On Sun, 18 Jun 2006 15:55:14 -0500, Rob W. wrote: Is there a way with my mysql query so that I can list the numbers in correct order? In what way is this problem related to PHP? Try a MySQL group instead. -- By-Tor.com ...it's all about the Rush http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql ORDER BY problem
It's not in general to mysql, it's how php and mysql is displaying it. - Original Message - From: "Michael Rasmussen" <[EMAIL PROTECTED]> To: Sent: Sunday, June 18, 2006 4:51 PM Subject: [PHP] Re: mysql ORDER BY problem On Sun, 18 Jun 2006 15:55:14 -0500, Rob W. wrote: Is there a way with my mysql query so that I can list the numbers in correct order? In what way is this problem related to PHP? Try a MySQL group instead. -- Hilsen/Regards Michael Rasmussen http://keyserver.veridis.com:11371/pks/lookup?op=get&search=0xE3E80917 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql table row updation based on user input.
John Taylor-Johnston wrote: Me thinks you have to name the checkboxes differently, otherwise the post variable will only take the last value it found, overwriting previous values. Otherwise they act like radioboxes. print " "; No, he's passing an array of checkboxes -- see the [] ? If you haven't seen that done before check out these pages: http://php.net/language.variables.external#AEN3832 http://php.net/faq.html#faq.html.arrays -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySql injections....
On Wed, May 11, 2005 3:36 am, M. Sokolewicz said: > [EMAIL PROTECTED] wrote: > >> Hi, >> This is not the proper list to put this question but i hope you can help >> me. >> Does anyone know a good tutorial about mysql injections? >> >> Thanks a lot for your help >> >> > what's there to make a tutorial about? :| > If you can get out of a value via a variable, then that means there's a > possibility for a SQL injection. Easy as that... Actually... The combinations of SQL injections and potential statements and tips to scrub data could fill a good chapter in a book, much less a one-page tutorial... Just my opinion. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL empty row
DB Error: constraint violation What DB do you use? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL empty row
GamblerZG wrote: Please replace die($res->getMessage()) with user_error($res->getMessage(), E_USER_ERROR) and then post the output. on one table it still does not work: this is the error: DB Error: constraint violation -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL empty row
GamblerZG wrote: Please replace die($res->getMessage()) with user_error($res->getMessage(), E_USER_ERROR) and then post the output. If I uncomment this it seems to work. Not error or anything in the code. Truely don't know what the error is. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql problems
Jed R. Brubaker wrote: > Thank you both for your responces. > > Unfotuantely there is no form that instantiates this action. So the double > submit (while a good idea), is not possible. > > As for some sample code, it is part of a rather complicated system that > makes a number of changes but essentailly what is going on is this: > > 1. Grab all items that we need to do some shipping stuff to. > 2. Foreach through the items, giving each item number to a function to > assign it to a customer and create a mailling label. > > That simple! > > The interesting this is this - the duplicate record is inserted into the > mailing labels queue. I can see it long before I grab the data for output > to > labels. Moreover, I can tell that the problem isn't in the original item > select statement because the function (executed for each item) would have > created different insert times in the database based on the now( ). Show us code excerpts. We can't second-guess from your description, as good as it is. Pin-point the code that is doing the double insert, and print out some debugging info there. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RE: MySQL & PHP Examples & Training Providers Required
Jay, guys. Thanks very much for all your responses on this issue. I'm sorry if I don't always reply through the group but if I am working from the office I have a problem connecting to the mailing list. which is just one of the reasons I prefer working from home. I, along with your help, have instilled some level of confidence in the languages I am using within my colleagues here at work. even though I am knew, I am no newbie to programming and designing databases and knew that PHP and MySQL would be up to the job. I'm particularly interested in what you are doing with them Jay. I was very surprised to see how many record manipulations your system manages on a daily basis - maybe one day eh...? again: thanks very much :) -- - Michael Mason Arras People www.arraspeople.co.uk - "Jay Blanchard" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] [snip] > On Wed, 11 Aug 2004 18:20:23 -0400, Lukasz Karapuda <[EMAIL PROTECTED]> wrote: >>Why I chose to reply to your email is because PHP is not usually used for >>the development of more complex functionality like the Web site module that >>we have developed. > > I beg to differ. Many large and complex sites are written in PHP. > There are also many large and complex programs written in PHP which > are in production use. Take TYPO3, for example: http://www.typo3.org I'll second that, PHP is an excellent choice for website development - especially when supported by the correct web server and database ;) [/snip] I'll third this. Extremely complex applications are programmed using PHP. I responded off list to Michael about this, but we are using PHP to process and report on millions of records per day in MySQL databases. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] RE: MySQL & PHP Examples & Training Providers Required
[snip] > On Wed, 11 Aug 2004 18:20:23 -0400, Lukasz Karapuda <[EMAIL PROTECTED]> wrote: >>Why I chose to reply to your email is because PHP is not usually used for >>the development of more complex functionality like the Web site module that >>we have developed. > > I beg to differ. Many large and complex sites are written in PHP. > There are also many large and complex programs written in PHP which > are in production use. Take TYPO3, for example: http://www.typo3.org I'll second that, PHP is an excellent choice for website development - especially when supported by the correct web server and database ;) [/snip] I'll third this. Extremely complex applications are programmed using PHP. I responded off list to Michael about this, but we are using PHP to process and report on millions of records per day in MySQL databases. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RE: MySQL & PHP Examples & Training Providers Required
Justin Patrin wrote: On Wed, 11 Aug 2004 18:20:23 -0400, Lukasz Karapuda <[EMAIL PROTECTED]> wrote: Why I chose to reply to your email is because PHP is not usually used for the development of more complex functionality like the Web site module that we have developed. I beg to differ. Many large and complex sites are written in PHP. There are also many large and complex programs written in PHP which are in production use. Take TYPO3, for example: http://www.typo3.org I'll second that, PHP is an excellent choice for website development - especially when supported by the correct web server and database ;) MANAGING a PHP project can be fun. Remember to track all changes to EVERY file, but the ability to drop into a particular function and make corrections and changes means that little niggles do not need to wait for a full system update like we have with older Builder C++ based applications. -- Lester Caine - L.S.Caine Electronic Services -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RE: MySQL & PHP Examples & Training Providers Required
On Wed, 11 Aug 2004 18:20:23 -0400, Lukasz Karapuda <[EMAIL PROTECTED]> wrote: > Michael, > > My company has recently developed a Web site module for a local > manufacturing company. The Web site module is a PHP and MySQL application > composed of several screens and advanced engineering functionality > (graphing, calculations etc). One of the database tables for the application > has over 110,000 records. > > Why I chose to reply to your email is because PHP is not usually used for > the development of more complex functionality like the Web site module that > we have developed. I beg to differ. Many large and complex sites are written in PHP. There are also many large and complex programs written in PHP which are in production use. Take TYPO3, for example: http://www.typo3.org > The module performed well in testing. It has not been > released for production yet, so I don't have a good performance report on > the production version of the Web site module (with many concurrent users). > > I could provide you the URL to the Web site when it is released to > production. > > Regards, > > -- > Lukasz Karapuda > VP Application Development - newline Creations LLC > > e-mail: [EMAIL PROTECTED] > > http://www.thenewline.com > > > > > > -Original Message- > > From: Harlequin [mailto:[EMAIL PROTECTED] > > Sent: Tuesday, August 10, 2004 7:07 PM > > To: [EMAIL PROTECTED] > > Subject: MySQL & PHP Examples & Training Providers Required > > > > Hi all. > > > > This might sound like a strange request but here goes. > > > > I'm looking for some examples of sites that are purely MySQL > > and PHP running on Unix and that contain a few thousand > > records preferably held in relational databases. > > > > Rationale: > > > > I need to justify PHP as a tool of choice over say vb.net or > > Oracle. My recommendation, despite my limited knowledge of > > MySQL and PHP is that even if we have 10-15 databases holding > > upwards of 10,000 records each PHP and MySQL are the tools of > > choice and I doubt that there are any functions missing that > > you'd find in VB.Net. I could be wrong and if so, please let me know. > > > > My other question is that I am looking for training in the > > UK, preferably in the North. I have no idea about > > accreditation or certification requirements and wondered if > > anyone could provide any recommendations...? > > > > Thanks for your time guys. > > -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: [mysql]Problem with PHP5
Ciprian, I may have missed whether or not you were able to resolve your problem from a couple days ago. In one of my development environments (Win2K), I decided to install PHP 5.0 with MySQL(i) 4.1.x support in IIS5.0 and Apache 2 (running on different ports). It took a bit more work than I intended, but here's what I did: FOR IIS (port 80): 1. downloaded and unzipped php-5.0.0-Win32.zip to c:\php 2. installed php as ISAPI 3. edited php-ini-recommended, tailored it to my environment, and copied it as php.ini into c:\winnt NOTE: extension_dir = c:\php\ext 4. tested phpinfo() without extensions 5. edited php.ini enabling needed extensions. NOTE: when uncommenting the line: extension=mysql.dll, changed line to read: extension=mysqli.dll 6. downloaded and unzipped mysql-4.1.3b-beta-win-noinstall.zip to c:\ 7. configured mysql per www.mysql.com install instructions 8. copied c:\mysql\bin\libmysql.dll to c:\winnt\system32 9. restarted IIS, and IIS started successfully, 10. reloaded phpinfo(), and noticed that mysqli was properly loaded, but now my old mysql_connect_db scripts don't work! Refer to the new mysqli PHP code: http://us3.php.net/manual/en/ref.mysqli.php 11. Here's a VERY basic example of the old mysql VS. new mysqli PHP code: OLD mysql: // connect to the database mysql_connect("localhost", "wong", "password") or die ("Could not connect to mySQL server"); // select the database mysql_select_db("music") or die ("Could not connect to database"); // store result $result = mysql_query("SELECT * FROM artists") or die (mysql_error()); // display returned results while ($row = mysql_fetch_array($result)) { echo $row["artist"], " ", $row["album"]; echo ""; } // free result mysql_free_result($result); ?> NEW mysqli: // connect to the database $link = mysqli_connect("localhost", "wong", "password", "music"); // check connection if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } // store query $query = "SELECT * FROM artists"; // store result $result = mysqli_query($link, $query); // loop thru rows using associative array while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo $row["artist"], " ", $row["album"]; echo ""; } // free the result mysqli_free_result($result); // close the link mysqli_close($link); ?> Additionally, for Apache 2 on Win2k (running on port 82): 1. Copied php.ini to c:\Apache Groups\Apache2 2. edited httpd.conf: - added LoadModule php5_module "c:/php/php5apache2.dll" - added AddType application/x-httpd-php .php 3. Restarted Apache server Hopes this helps. Dan Ciprian Constantinescu wrote: I have included the extension. Now I get "Unable to load dynamic library 'C:\php\ext\php_mysql.dll' - The specified procedure could not be found" I have in Windows\System32 the file libmysql.dll. I have also put it in the php\ext directory without any result. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL Database Connection Question
Oh! :-) Thanks... John Nichel wrote: Afan Pasalic wrote: Daniel Kullik wrote: Note: You should checkout the thread 'Form Submission' started on July 6th since this is appearently not the best way to check if the user hit the submit-button. Daniel July 6th? What are you talking about? Can you please give me more info about that? afan He's saying RTFA. http://marc.theaimsgroup.com/?l=php-general&m=108910994407822&w=2 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL Database Connection Question
John Nichel wrote: Afan Pasalic wrote: Daniel Kullik wrote: Note: You should checkout the thread 'Form Submission' started on July 6th since this is appearently not the best way to check if the user hit the submit-button. Daniel July 6th? What are you talking about? Can you please give me more info about that? afan He's saying RTFA. http://marc.theaimsgroup.com/?l=php-general&m=108910994407822&w=2 Thanks for that URL, John. Eventually CVS come to Afan's mind when he read "checkout" and "thread". Sorry for the confusion. Daniel -- WWE e-commerce IT GmbH Eiffestrasse 462, D-20537 Hamburg Tel.: +49-40-2530659-0, Fax: +49-40-2530659-50 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL Database Connection Question
Afan Pasalic wrote: July 6th? What are you talking about? Can you please give me more info about that? afan Daniel Kullik wrote: Note: You should checkout the thread 'Form Submission' started on July 6th since this is appearently not the best way to check if the user hit the submit-button. Daniel Hello Afan. On July 6th 2004 (or 2004-06-07 if you prefer ISO-dates) [EMAIL PROTECTED] started a thread named 'Form Submission'. That's all. Daniel -- WWE e-commerce IT GmbH Eiffestrasse 462, D-20537 Hamburg Tel.: +49-40-2530659-0, Fax: +49-40-2530659-50 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL Database Connection Question
Afan Pasalic wrote: Daniel Kullik wrote: Note: You should checkout the thread 'Form Submission' started on July 6th since this is appearently not the best way to check if the user hit the submit-button. Daniel July 6th? What are you talking about? Can you please give me more info about that? afan He's saying RTFA. http://marc.theaimsgroup.com/?l=php-general&m=108910994407822&w=2 -- John C. Nichel KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL Database Connection Question
July 6th? What are you talking about? Can you please give me more info about that? afan Daniel Kullik wrote: Note: You should checkout the thread 'Form Submission' started on July 6th since this is appearently not the best way to check if the user hit the submit-button. Daniel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RE: MySQL Results Not Being Committed To Database
"John W. Holmes" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > >> $query = mysql_query($sql); > >> $mysql_result = mysql_query ($sql, $Connection) or die ("Invalid > >>Query - " . mysql_error()); > > You're running the query twice. Take out that first line. Michael, that's where your duplicate key error comes from. Forget about the table structure. Thanks, John. > > And I second the recommendation to please reply to the list and not > individuals unless they request it. > > -- > ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RE: MySQL Results Not Being Committed To Database
$query = mysql_query($sql); $mysql_result = mysql_query ($sql, $Connection) or die ("Invalid Query - " . mysql_error()); You're running the query twice. Take out that first line. And I second the recommendation to please reply to the list and not individuals unless they request it. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: MySQL QUERY Results Not Appearing[Scanned]
Don't know that this will work but it might help isolate the problem: /* MySQL Connection Variables */ $host="localhost"; $user="arras_WebMaster"; $password="qwerty"; $dbase="arras_Members"; /* MySQL Connection String */ if(!$dbConnect = @mysql_connect ("$host", "$user", "$password")) { echo "Couldn't connect to the database server: ".mysql_error().""; } if(!$dbSelect = @mysql_select_db ("$dbase")) { echo "Couldn't select the database: ".mysql_error().""; } if(!$query = @mysql_query("SELECT * FROM RegisteredMembers")) { echo "Couldn't execute query: ".mysql_error().""; } else { while($result = mysql_fetch_array($query)) { echo $result['UserID']; } } HTH, Michael Egan -Original Message- From: Harlequin [mailto:[EMAIL PROTECTED] Sent: 02 July 2004 09:34 To: [EMAIL PROTECTED] Subject: [PHP] Re: MySQL QUERY Results Not Appearing[Scanned] Craig. Thanks for the response and sorry I've been delayed in getting back to you. I put a new page together and dropped all the peripheral code and this is what I ended up with: active members should appear here"; $query = mysql_query("SELECT * FROM RegisteredMembers") or die("could not execute query"); while($result = mysql_fetch_array($query)){ echo $result['UserID']; } ?> Still no joy though. Any ideas...? -- - Michael Mason Arras People www.arraspeople.co.uk - The information contained in this email (and in any attachments sent with it) is confidential. It is intended for the addressee only. Access to this email by anyone else is unintended and unauthorized. If you are not the original addressee, 3tc asks you to please maintain confidentiality. If you have received this email in error please notify 3tc immediately by replying to it, then destroy any copies and delete it from your computer system. Any use, dissemination, forwarding, printing or copying of this email by anyone except the addressee in the normal course of his/her business, is strictly prohibited. 3tc owns the copyright in this email and any document created by us and assert the right to be identified as the author of it. Copyright has not been transferred to the addressee. We protect our systems with Sophos Anti-virus - www.sophos.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Mysql Problem
Hi, Yes that was my mistake. But even with the code, it still doesnt display the last one. If i didnt put a " it wouldnt work at all. Thanks, Ian -Original Message- From: Torsten Roehr [mailto:[EMAIL PROTECTED] Sent: 28 May 2004 13:56 To: [EMAIL PROTECTED] Subject: [PHP] Re: Mysql Problem "Ian Barnes" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I am generating a mysql statement and then printing it to a formatted field. > Here is my code: > > $sql="SELECT * from tablename where name in ('Web','HTML','PHP') group by > name; You are missing the closing quote here! Please set your error reporting to E_ALL while developing: ini_set('error_reporting', E_ALL); Regards, Torsten Roehr > $mysql_rslt1 = mysql_query($sql, $mysql_bconn) > or die ("Could not get data"); > while ($rec1 = mysql_fetch_array ($mysql_rslt1)) { > echo "some stuff here"; > } > > Now the problem is it will leave out the last line of the reply. So it would > leave out the 'PHP' line for the query above. Always the last line, and if > for some reason i only have 1 in my query, it displays nothing, although if > I do it manually using the mysql prompt, it works fine, and i get back the > info I want. All the other lines format properly and the info is correct, > just the last line doesnt display. > > Any ideas ? > > Ian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: MySQL: Order by
make your column of type int column -Original Message- From: Ben Ramsey [mailto:[EMAIL PROTECTED] Sent: Thursday, February 05, 2004 7:52 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: [PHP] Re: MySQL: Order by I assume "number" is a column name in your table. If so, I'm also guessing that it's probably of a varchar (or some other character type) datatype. Here's why: if it's a character, then ORDER BY will sort alphabetically. The way it sorts number alphabetically is rather odd, but it makes sense in an alphabetical way. If it is character data, then it should order like this: 1 10 11 12 13 2 3 4 .. To correct it, put a zero at the beginning of your single digits: 01 02 03 .. 10 11 12 That will order it correctly. Otherwise, change the number column to type int, and it should work just fine. Hope that answers your question, and, yes, this is more of a MySQL question. ;-) -Ben John Taylor-Johnston wrote: > This is probably a MySQL question, and maybe an easy question, but I'm here to learn <|:) > > When I order by number, it echoes 1,2,3,4,5,6,7,8,9,10 and hten jumps to 100...199 before it comes back to 11-19. Any way of ordering that differently? > > $sql = 'SELECT * FROM '.$table.' ORDER BY number desc;'; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Disclaimer This e-mail transmission contains confidential information, which is the property of the sender. The information in this e-mail or attachments thereto is intended for the attention and use only of the addressee. Should you have received this e-mail in error, please delete and destroy it and any attachments thereto immediately. Under no circumstances will the Cape Technikon or the sender of this e-mail be liable to any party for any direct, indirect, special or other consequential damages for any use of this e-mail. For the detailed e-mail disclaimer please refer to http://www.ctech.ac.za/polic or call +27 (0)21 460 3911 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: MySQL query problems
Not sure what the problem was, but I dug up a similar script I used for something else and modifed it for this project, and voila. I then put the two side by side and I still can't see where the problem is. Thanks for the input. -Original Message- From: Nomadeous [mailto:[EMAIL PROTECTED] Sent: July 16, 2003 5:31 PM To: [EMAIL PROTECTED] Subject: [PHP] Re: MySQL query problems But what's your prob ? When you say the second one seems to never be executed ... Does the line: $row = mysql_fetch_array($result2); launches a Php Error ? And pay attention, because you're using mysql_fetch_array and mysql_fetch_row, be sure that you are not treating the result in the same way ;-) "Beauford.2005" <[EMAIL PROTECTED]> a écrit dans le message de news: [EMAIL PROTECTED] > Hi, > > Not sure if the problem here is PHP or MySQL, but here we go. I am > trying to do two queries on a database - one after the other, but the > second one never seems to get executed. The two queries are identical > except for two variables. I have checked my form and they are correct > and are being sent to the PHP script the way they should be. > > The variables are $playerto, $playerfrom, $nameto, $namefrom. The 'TO' > query is the one that doesn't work. > > Here is my code. Any help is appreciated. > > if ($namefrom != $nameto) { > if ($playerfrom != $playerto) { > > include("2004server.inc"); > if($error) { > include("trades-input.php"); > exit; > } > > $query1 = "select manager.idn, manager.total, > roster.idp, position, points from roster join reference > join manager where manager.idn=reference.idn and > reference.idp=roster.idp and manager.idn like '$namefrom' and > roster.idp like '$playerfrom'"; > > $result1 = mysql_query($query1) or $mysqlerror = mysql_error(); > if ($mysqlerror) { > $error = "$d_base_error$email_error"; > include("trades-input.php"); > exit; > } > > $line = mysql_fetch_row($result1); > > mysql_free_result($result1); > > $query2 = "select manager.idn, manager.total, > roster.idp, position, points from roster join reference > join manager where manager.idn=reference.idn and > reference.idp=roster.idp and manager.idn like '$nameto' and roster.idp > like '$playerto'"; > > $result2 = mysql_query($query2) or $mysqlerror = mysql_error(); > if ($mysqlerror) { > $error = "$d_base_error$email_error"; > include("trades-inputs.php"); > exit; > } > > $row = mysql_fetch_array($result2); > > mysql_free_result($result2); > } > } > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Mysql DB connect failure
better to use something like mysql_connect("localhost", "test1", "test1")||die(mysql_error()); because you will make smaller code that way killing the script instantly when connection is refused and you will still get the same message: user access denied for '[EMAIL PROTECTED]' using password:(yes) in either case die would be better to use than testing a link variable since in very large amounts of hits on the db that way could cause a test to fall through and do something really uninteresting.. at least thats my experience with that... so if i purposfully make an error: mysql_connect("localhost", "root", "")||die(mysql_error()); i get the message above about the error - Original Message - From: "Hans Prins" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, February 21, 2003 11:07 AM Subject: Re: [PHP] Re: Mysql DB connect failure > > Would you care to explain to the rest of the list how you intend to use > > mysql_error () to return connection failure information? > > > > It returns the text of the error message from previous MySQL operation > > Description: string mysql_error ( [resource link_identifier]) > > > > Seems to me that without a connection, we wouldn't have a valid > > link_identifier. > > maybe so, but it works nonetheless. > > if for example the username stated in the connection initialization was > wrong it will print an error like: > > "Access denied for user: '[EMAIL PROTECTED]' (Using password: YES)" > > MI, > > my code would look somethign like this: > > $link = @mysql_pconnect("localhost", "test1", "test1"); > > // If connection failed... > if (!$link) { > // Inform user of error and quit > print "Couldn't connect to database server\n"; > print mysql_error(); > exit; > } > > > > "Jason K Larson" <[EMAIL PROTECTED]> schreef in bericht > news:[EMAIL PROTECTED] > > Would you care to explain to the rest of the list how you intend to use > > mysql_error () to return connection failure information? > > > > It returns the text of the error message from previous MySQL operation > > Description: string mysql_error ( [resource link_identifier]) > > > > Seems to me that without a connection, we wouldn't have a valid > > link_identifier. > > > > What you probably should attempt going for is getting something back > > from PHP itself regarding the error returned when the mysql_connect > failed. > > > > Here's a snippet from: > > http://www.php.net/manual/en/language.operators.errorcontrol.php > > > > If the track_errors feature is enabled, any error message generated by > > the expression will be saved in the global variable $php_errormsg. This > > variable will be overwritten on each error, so check early if you want > > to use it. > > > > Hope that clears things up a bit. > > > > Regards, > > Jason k Larson > > > > > > > > Hans Prins wrote: > > > did you try: > > > print mysql_error(); > > > > > > "Ml" <[EMAIL PROTECTED]> schreef in bericht > > > news:[EMAIL PROTECTED] > > > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.443 / Virus Database: 248 - Release Date: 1/11/2003 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Mysql DB connect failure
Thanks rick, that is a much cleaner solution! "Rick Emery" <[EMAIL PROTECTED]> wrote in message 009f01c2d9c1$51171d20$0500a8c0@honeybee">news:009f01c2d9c1$51171d20$0500a8c0@honeybee... > $db = mysql_pconnect("localhost", "test1", "test1") or die(mysql_error()); > > - Original Message - > From: "ML" <[EMAIL PROTECTED]> > To: <> > Sent: Friday, February 21, 2003 9:33 AM > Subject: [PHP] Re: Mysql DB connect failure > > > Where exactly would I put the print mysql_error() ? > Here is the code... > > > @ $db = mysql_pconnect("localhost", "test1", "test1") >or >die(" > > > > > "); > > > > > > "Hans Prins" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > did you try: > > print mysql_error(); > > > > "Ml" <[EMAIL PROTECTED]> schreef in bericht > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > Currently I have some php code that displays a message if a connect to > my > > > database fails. Is there anyway I > > > can get a more descriptive error message? So I can see exactly why my > php > > > can't connect to the Database? > > > I am pretty sure that the username and password are correct and the > > username > > > exists as a mysql user... > > > > > > > > > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Mysql DB connect failure
I see that its looking for mysql.sock in /tmp/mysql.sock but I searched on my system and only found mysql.sock in /var/lib/mysql/ is there a section where I need to change this setting? or a conf file? "Hans Prins" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > Would you care to explain to the rest of the list how you intend to use > > mysql_error () to return connection failure information? > > > > It returns the text of the error message from previous MySQL operation > > Description: string mysql_error ( [resource link_identifier]) > > > > Seems to me that without a connection, we wouldn't have a valid > > link_identifier. > > maybe so, but it works nonetheless. > > if for example the username stated in the connection initialization was > wrong it will print an error like: > > "Access denied for user: 'username@localhost' (Using password: YES)" > > MI, > > my code would look somethign like this: > > $link = @mysql_pconnect("localhost", "test1", "test1"); > > // If connection failed... > if (!$link) { > // Inform user of error and quit > print "Couldn't connect to database server\n"; > print mysql_error(); > exit; > } > > > > "Jason K Larson" <[EMAIL PROTECTED]> schreef in bericht > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > Would you care to explain to the rest of the list how you intend to use > > mysql_error () to return connection failure information? > > > > It returns the text of the error message from previous MySQL operation > > Description: string mysql_error ( [resource link_identifier]) > > > > Seems to me that without a connection, we wouldn't have a valid > > link_identifier. > > > > What you probably should attempt going for is getting something back > > from PHP itself regarding the error returned when the mysql_connect > failed. > > > > Here's a snippet from: > > http://www.php.net/manual/en/language.operators.errorcontrol.php > > > > If the track_errors feature is enabled, any error message generated by > > the expression will be saved in the global variable $php_errormsg. This > > variable will be overwritten on each error, so check early if you want > > to use it. > > > > Hope that clears things up a bit. > > > > Regards, > > Jason k Larson > > > > > > > > Hans Prins wrote: > > > did you try: > > > print mysql_error(); > > > > > > "Ml" <[EMAIL PROTECTED]> schreef in bericht > > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Mysql DB connect failure
You were right Prins, I got the error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) So I guess I need to investigate what this means now... Thanks! -ML "Hans Prins" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > Would you care to explain to the rest of the list how you intend to use > > mysql_error () to return connection failure information? > > > > It returns the text of the error message from previous MySQL operation > > Description: string mysql_error ( [resource link_identifier]) > > > > Seems to me that without a connection, we wouldn't have a valid > > link_identifier. > > maybe so, but it works nonetheless. > > if for example the username stated in the connection initialization was > wrong it will print an error like: > > "Access denied for user: 'username@localhost' (Using password: YES)" > > MI, > > my code would look somethign like this: > > $link = @mysql_pconnect("localhost", "test1", "test1"); > > // If connection failed... > if (!$link) { > // Inform user of error and quit > print "Couldn't connect to database server\n"; > print mysql_error(); > exit; > } > > > > "Jason K Larson" <[EMAIL PROTECTED]> schreef in bericht > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > Would you care to explain to the rest of the list how you intend to use > > mysql_error () to return connection failure information? > > > > It returns the text of the error message from previous MySQL operation > > Description: string mysql_error ( [resource link_identifier]) > > > > Seems to me that without a connection, we wouldn't have a valid > > link_identifier. > > > > What you probably should attempt going for is getting something back > > from PHP itself regarding the error returned when the mysql_connect > failed. > > > > Here's a snippet from: > > http://www.php.net/manual/en/language.operators.errorcontrol.php > > > > If the track_errors feature is enabled, any error message generated by > > the expression will be saved in the global variable $php_errormsg. This > > variable will be overwritten on each error, so check early if you want > > to use it. > > > > Hope that clears things up a bit. > > > > Regards, > > Jason k Larson > > > > > > > > Hans Prins wrote: > > > did you try: > > > print mysql_error(); > > > > > > "Ml" <[EMAIL PROTECTED]> schreef in bericht > > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Mysql DB connect failure
> Would you care to explain to the rest of the list how you intend to use > mysql_error () to return connection failure information? > > It returns the text of the error message from previous MySQL operation > Description: string mysql_error ( [resource link_identifier]) > > Seems to me that without a connection, we wouldn't have a valid > link_identifier. maybe so, but it works nonetheless. if for example the username stated in the connection initialization was wrong it will print an error like: "Access denied for user: 'username@localhost' (Using password: YES)" MI, my code would look somethign like this: $link = @mysql_pconnect("localhost", "test1", "test1"); // If connection failed... if (!$link) { // Inform user of error and quit print "Couldn't connect to database server\n"; print mysql_error(); exit; } "Jason K Larson" <[EMAIL PROTECTED]> schreef in bericht [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Would you care to explain to the rest of the list how you intend to use > mysql_error () to return connection failure information? > > It returns the text of the error message from previous MySQL operation > Description: string mysql_error ( [resource link_identifier]) > > Seems to me that without a connection, we wouldn't have a valid > link_identifier. > > What you probably should attempt going for is getting something back > from PHP itself regarding the error returned when the mysql_connect failed. > > Here's a snippet from: > http://www.php.net/manual/en/language.operators.errorcontrol.php > > If the track_errors feature is enabled, any error message generated by > the expression will be saved in the global variable $php_errormsg. This > variable will be overwritten on each error, so check early if you want > to use it. > > Hope that clears things up a bit. > > Regards, > Jason k Larson > > > > Hans Prins wrote: > > did you try: > > print mysql_error(); > > > > "Ml" <[EMAIL PROTECTED]> schreef in bericht > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Mysql DB connect failure
Would you care to explain to the rest of the list how you intend to use mysql_error () to return connection failure information? It returns the text of the error message from previous MySQL operation Description: string mysql_error ( [resource link_identifier]) Seems to me that without a connection, we wouldn't have a valid link_identifier. What you probably should attempt going for is getting something back from PHP itself regarding the error returned when the mysql_connect failed. Here's a snippet from: http://www.php.net/manual/en/language.operators.errorcontrol.php If the track_errors feature is enabled, any error message generated by the expression will be saved in the global variable $php_errormsg. This variable will be overwritten on each error, so check early if you want to use it. Hope that clears things up a bit. Regards, Jason k Larson Hans Prins wrote: did you try: print mysql_error(); "Ml" <[EMAIL PROTECTED]> schreef in bericht [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL for storing PHP code
Hi, Tuesday, February 11, 2003, 7:39:16 AM, you wrote: DP> Thanks for the comments everyone! eval() has just made my day :) DP> Cheers, DP> Daniel DP> "Daniel Page" <[EMAIL PROTECTED]> a écrit dans le message de news: DP> [EMAIL PROTECTED] >> Hi, >> >> Would it be possible to store PHP code in a MySQL table, then via a web >> page, connect to the DB, recover the code that corresponds to a certain id >> number, then include that code for execution? >> >> For example (quick, dirty, and untested!): >> >> $sql = "SELECT phpcode FROM phpstorage WHERE codeid = 1"; >> $result = mysql_query($sql); >> $_php_code = mysql_result($result, 0,"phpcode"); >> echo $_php_code; >> >> Will the echo (or print() ) just output code that can be read by the DP> reader >> of the page, or will it generate output that will be executed? >> >> If the echo/print does not work, is there another way to do this? >> >> Cheers, >> Daniel >> >> Be aware that it could also ruin your life :) It would be a good idea to store an encrypted checksum of the code to ensure it has not been tampered with as eval will do exactly what it is told to do. -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL/PHP Associative Array Insert
Chris Shiflett wrote: --- Cditty <[EMAIL PROTECTED]> wrote: A co-worker is teaching me to move to the next level in php. I have started using associative arrays for my scripts, but I am having a problem using them to do an insert into MySQL. Can someone give me an example of how to do an insert to the database using these arrays? My array is this...$item['itemID'] Using arrays is easy. For example: $sql = "insert into blah (foo) values('"; $sql .= $item['item_id']; $sql .= "')"; It isn't necessary for that to span three lines, but my mail client will annihilate it otherwise. Just use concatenation (.) to make things easy on yourself instead of embedding your variable in the string (possible with curly braces). Of course, if you want to do it the cool way (which is what your co-worker probably wants), look at Mr. Kimsal's example: (That's what I figured the co-worker was after, with the 'next level' bit) --- michael kimsal <[EMAIL PROTECTED]> wrote: The only problem here is that there is no table name, which is easily remedied. You probably want to pass the table name as another argument. Also, use "replace into" for an elegant way to insert the record if it does not exist (based on whether your where clause matches) or update the record if it does. Mr. Kimsal mentioned later in his explanation I believe. GOOD CALL - sorry - shouldn't have been trying to do that so late at night. :) You can eliminate the slashadd() function and the array_walk() call if you make sure your values are properly escaped. If magic_quotes is on, you definitely want to avoid the extra slashes, and it might be worth checking whether it is on in your script, so that you don't depend on any specific PHP configuration. Yeah, I was going to mention about that too, but I figured someone looking at the code might just assume that I hadn't thought about the slash issue. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL/PHP Associative Array Insert
--- Cditty <[EMAIL PROTECTED]> wrote: > A co-worker is teaching me to move to the next level > in php. I have started using associative arrays for my > scripts, but I am having a problem using them to do an > insert into MySQL. Can someone give me an example of > how to do an insert to the database using these arrays? > My array is this...$item['itemID'] Using arrays is easy. For example: $sql = "insert into blah (foo) values('"; $sql .= $item['item_id']; $sql .= "')"; It isn't necessary for that to span three lines, but my mail client will annihilate it otherwise. Just use concatenation (.) to make things easy on yourself instead of embedding your variable in the string (possible with curly braces). Of course, if you want to do it the cool way (which is what your co-worker probably wants), look at Mr. Kimsal's example: --- michael kimsal <[EMAIL PROTECTED]> wrote: > $x['name'] = "Mike's"; > $x['phone'] = 'fsdlfksdf'; > echo sql($x); > > function sql($a) { > $k = implode(",",array_keys($a)); > array_walk($a,'slashadd'); > $v = "'".implode("','",$a)."'"; > return "insert into ($k) values ($v)"; > } > function slashadd(&$bar) { $bar = addslashes($bar); } > ?> The only problem here is that there is no table name, which is easily remedied. You probably want to pass the table name as another argument. Also, use "replace into" for an elegant way to insert the record if it does not exist (based on whether your where clause matches) or update the record if it does. Mr. Kimsal mentioned later in his explanation I believe. You can eliminate the slashadd() function and the array_walk() call if you make sure your values are properly escaped. If magic_quotes is on, you definitely want to avoid the extra slashes, and it might be worth checking whether it is on in your script, so that you don't depend on any specific PHP configuration. Finally, since this only builds your SQL statement, you can enhance your function to execute the query for you (you might want to add another argument for the database name) and return true or false indicating success or failure. Have fun, and tell your co-worker hello. Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL back up
Okay, I took out all the reason for error, I took the variables out of the code and replaced them with the actual values. I do not execute the gzip function. All I get is an empty file. Also I made sure the back up directory is set to 777. Now phpMySQLAdmin will perform the same function, so there must be a way to do this without the phpMySQLAdmin program? Has anyone tried to do what I am trying to do? Has anyone tried with this code? One more thing, I borrowed a free script written in perl that uses mysqldump and it worked. The point here is that I want this to work in PHP so I can include this code in a bigger application I am writing. Thanks for all your ideas! "John W. Holmes" <[EMAIL PROTECTED]> wrote in message 01c27058$c1770170$7c02a8c0@coconut">news:01c27058$c1770170$7c02a8c0@coconut... > > Okay here is the new code and this is still not working. > > > > > > > require("./config.php"); > > > > $sqlserver = $server1; > > $sqlusername = $username1; > > $sqlpassword = $password1; > > $sqldatabase = $database1; > > > > //** > > $nam_bak=date('D,d-m-Y'); > > Can you have a filename with a comma in it? > > > exec("mysqldump -u\"$sqlusername\" -p\"$sqlpassword\" \"$sqldatabase\" > > > > $backupdir/$nam.sql"); > > Take out the \" quotes around username, password, and database. > > > > > exec("gzip $backupdir/$nam.sql"); > > ---John Holmes... > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: MySQL back up
Ken .. You have to replace exec("mysqldump -u\"$sqlusername\" -p\"$sqlpassword\" \"$sqldatabase\" > $backupdir/$nam.sql"); With this exec("mysqldump -u \"$sqlusername\" --password=\"$sqlpassword\" \"$sqldatabase\" > $backupdir/$nam.sql"); Please not the space after -u And i agree owen about 2. $backupdir MUST BE writeable by apache IT HAS TO WORK MAN !! Cordialmente Daniel Massón => Ingeniero de desarollo [EMAIL PROTECTED] www.imagine.com.co Tels: (57)(1) 2182064 - 6163218 Bogotá - Colombia - Soluciones web para internet e intranet - Asesoría y Soporte Técnico - Licenciamiento de Software -Mensaje original- De: Ken [mailto:[EMAIL PROTECTED]] Enviado el: miércoles, 09 de octubre de 2002 22:36 Para: [EMAIL PROTECTED] Asunto: Re: [PHP] Re: MySQL back up Okay here is the new code and this is still not working. $backupdir/$nam.sql"); exec("gzip $backupdir/$nam.sql"); ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: MySQL back up
> Okay here is the new code and this is still not working. > > > require("./config.php"); > > $sqlserver = $server1; > $sqlusername = $username1; > $sqlpassword = $password1; > $sqldatabase = $database1; > > //** > $nam_bak=date('D,d-m-Y'); Can you have a filename with a comma in it? > exec("mysqldump -u\"$sqlusername\" -p\"$sqlpassword\" \"$sqldatabase\" > > $backupdir/$nam.sql"); Take out the \" quotes around username, password, and database. > > exec("gzip $backupdir/$nam.sql"); ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL back up
Haven't really been following this thread but you may want to make sure that 1. mysqldump & gzip are executable by apache 2. $backupdir is writeable by apache 3. You have taken into consideration your php safe mode settings Cheers, Owen Prime http://www.noggin.com.au Ken wrote: > Okay here is the new code and this is still not working. > > > require("./config.php"); > > $sqlserver = $server1; > $sqlusername = $username1; > $sqlpassword = $password1; > $sqldatabase = $database1; > > //** > $nam_bak=date('D,d-m-Y'); > > exec("mysqldump -u\"$sqlusername\" -p\"$sqlpassword\" \"$sqldatabase\" > > $backupdir/$nam.sql"); > > exec("gzip $backupdir/$nam.sql"); > > ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL back up
Okay here is the new code and this is still not working. $backupdir/$nam.sql"); exec("gzip $backupdir/$nam.sql"); ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: MySQL back up
I agree everything, but Im not very sure if this is going to work: > $backup=@passthru("mysqldump --opt \"$sqldatabase\" > > $backupdir/$nam.sql"); You need to send mysqldump the username and password. Syntax is Mysqldump -uuser -ppassword databasename > filename.sql Y think tou should use: Mysqldump -u user --password user_password > filename.sql I had an expirience with perl trying like John "mysqldump -uuser -ppassword databasename > filename.sql" did not work, i think you have to send the password too. Regards. Daniel > -Original Message- > From: Ken [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, October 09, 2002 7:25 AM > To: [EMAIL PROTECTED] > Subject: [PHP] Re: MySQL back up > > Here is the code I tired to use: > > > session_start(); You don't need to start a session... > require("./config.php"); > > $sqlserver = $server1; > > $sqlusername = $username1; > > $sqlpassword = $password1; > > $sqldatabase = $database1; > > $nam=date('D,d-m-Y'); > > @ $db = mysql_pconnect($sqlserver, $sqlusername, $sqlpassword); You don't need to connect to the mysql server. > > if (!$db) > > { > > echo "Could not connect to MySQL"; > > exit; > > } > > $backup=@passthru("mysqldump --opt \"$sqldatabase\" > > $backupdir/$nam.sql"); You need to send mysqldump the username and password. Syntax is Mysqldump -uuser -ppassword databasename > filename.sql > passthru("gzip $backupdir/$nam.sql"); Why are you using passthru? Neither of these commands should return any output, so passthru isn't returning anything. You can use backticks or exec() instead. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: MySQL back up
> -Original Message- > From: Ken [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, October 09, 2002 7:25 AM > To: [EMAIL PROTECTED] > Subject: [PHP] Re: MySQL back up > > Here is the code I tired to use: > > > session_start(); You don't need to start a session... > require("./config.php"); > > $sqlserver = $server1; > > $sqlusername = $username1; > > $sqlpassword = $password1; > > $sqldatabase = $database1; > > $nam=date('D,d-m-Y'); > > @ $db = mysql_pconnect($sqlserver, $sqlusername, $sqlpassword); You don't need to connect to the mysql server. > > if (!$db) > > { > > echo "Could not connect to MySQL"; > > exit; > > } > > $backup=@passthru("mysqldump --opt \"$sqldatabase\" > > $backupdir/$nam.sql"); You need to send mysqldump the username and password. Syntax is Mysqldump -uuser -ppassword databasename > filename.sql > passthru("gzip $backupdir/$nam.sql"); Why are you using passthru? Neither of these commands should return any output, so passthru isn't returning anything. You can use backticks or exec() instead. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: MySQL back up
> Why don't you just do a hard backup of the files from the db. Find out the > location of the data folder where thd db saves its tables, perform a tar > cvzf data_folder and then pipe it directly to the user for download via > http. > > Havent tryed it that way, but should work. Another thing would be reoback > which is a perl script. You should be able to perform this backup via ftp > controled by a daily cron job. You'll have to shut down the database to do it this way, though. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL Problem
Well, that's just a typo...of course there should be a () to make it call a function... The whole point to my postings is that I can't get the darn variable to stay in place!!! Look where it says "Prints NOTHING". Does anyone know why it doesn't print "Hello World"??? ::Lewis "Mike Ford" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > -Original Message- > > From: OrangeHairedBoy [mailto:[EMAIL PROTECTED]] > > Sent: 03 October 2002 09:39 > > > > Here's a simplier version...and I'm still having a problem > > with it. It's > > driving me insane!!! :) > > > > class MySQL > > { > > function SET ( ) > > { > > $this->MYVAR = "Hello World!"; > > } > > function RETREIVE ( ) > > { > > print $this->MYVAR; > > } > > } > > $helpme = new MySQL; > > $helpme->SET; > > $helpme->RETREIVE; /* Prints NOTHING */ > > I'm pretty sure you have to add () on the end of those function names to get > PHP to actually *call* the function, so you need: > > $helpme->SET(); > $helpme->RETREIVE(); > > Without the parentheses, PHP evaluates the name of the function (returning > its "handle"), but then doesn't know what to do with it so just throws it > away on seeing the terminating semicolon. As far as PHP is concerned, you > could quite legitimately want to do something entirely different with the > handle, such as assigning it to a variable -- PHP won't assume you want to > call it as a function just because it happens to be a function name. For > instance, the following should work (I think! - although I haven't tested > it): > > $method = $helpme->SET; > $method(); > > In fact, you can ask PHP to try and call anything as a function by appending > parentheses, so this should work too: > > $method = "SET"; > $helpme->$method(); > > > Cheers! > > Mike > > - > Mike Ford, Electronic Information Services Adviser, > Learning Support Services, Learning & Information Services, > JG125, James Graham Building, Leeds Metropolitan University, > Beckett Park, LEEDS, LS6 3QS, United Kingdom > Email: [EMAIL PROTECTED] > Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: MySQL Problem
> -Original Message- > From: OrangeHairedBoy [mailto:[EMAIL PROTECTED]] > Sent: 03 October 2002 09:39 > > Here's a simplier version...and I'm still having a problem > with it. It's > driving me insane!!! :) > > class MySQL > { > function SET ( ) > { > $this->MYVAR = "Hello World!"; > } > function RETREIVE ( ) > { > print $this->MYVAR; > } > } > $helpme = new MySQL; > $helpme->SET; > $helpme->RETREIVE; /* Prints NOTHING */ I'm pretty sure you have to add () on the end of those function names to get PHP to actually *call* the function, so you need: $helpme->SET(); $helpme->RETREIVE(); Without the parentheses, PHP evaluates the name of the function (returning its "handle"), but then doesn't know what to do with it so just throws it away on seeing the terminating semicolon. As far as PHP is concerned, you could quite legitimately want to do something entirely different with the handle, such as assigning it to a variable -- PHP won't assume you want to call it as a function just because it happens to be a function name. For instance, the following should work (I think! - although I haven't tested it): $method = $helpme->SET; $method(); In fact, you can ask PHP to try and call anything as a function by appending parentheses, so this should work too: $method = "SET"; $helpme->$method(); Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL Problem
I thought someone might mention that, but that is actually correct. The problem is that the variable assigned on the line $this->DBLink[$MyVars[NAME]] = mysql_connect( $MyVars[HOST] , $MyVars[USERNAME] , $MyVars[PASSWORD] ); dissapears and can't be retreived on the line mysql_select_db( $MyVars[DATABASE] , $this->DBLink[$MyVars[LINK]] );. For instance, if the first line saves $this->DBLink["TEST"], when CHOOSEDB is called, the command PRINT $this->DBLink["TEST"] will print nothing when the same line right after the variable is saved would produce something like "Resource ID #38". That's the brain twister. Thanks though! ::Lewis "Tom Rogers" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi, > > Thursday, October 3, 2002, 6:01:53 PM, you wrote: > O> You know...maybe I should mention where this code is... > > O> I have my main file which loads using 'require.once' a second file called > O> 'everything.php'. > > O> Inside everything.php is a class called 'mainclass' which is called by the > O> mail file. > > O> This class ('mainclass') loads the MySQL class from the previous post which > O> is stored in yet another file, using require.once. > > O> MainClass then calls the MySQL->CONNECT and MySQL->CHOOSEDB functions. > > O> I know this sounds a bit over the top, but it works...at least it > O> did...until now. I thought I'd mention the circumstances in case that makes > O> a difference, which I suspect it will. > > O> Thanks again! > > O> Lewis > > O> "Orangehairedboy" <[EMAIL PROTECTED]> wrote in message > O> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > >> Hi everyone! I can't figure out why this doesn't work. The call to the > >> CONNECT function works and it connects with no problem, and it does save > O> the > >> Resource ID in $this->DBLink[]...however, when CHOOSEDB is called, the > >> Resource ID just saved is gone. $this->DBLink is just empty, and I can't > >> figure out why... > >> > >> Can anyone offer insight on this one? > >> > >> class MySQL > >> { > >> var $DBLink = array(); > >> function CONNECT ( $MyVars , $MyContents ) > >> { > >> $host = ( $MyVars[PORT] ) ? $MyVars[HOST] . ":" . $MyVars[PORT] : > >> $MyVars[HOST]; > >> $this->DBLink[$MyVars[NAME]] = mysql_connect( $MyVars[HOST] , > >> $MyVars[USERNAME] , $MyVars[PASSWORD] ); > >> } > >> function CHOOSEDB ( $MyVars , $MyContents ) > >> { > >> mysql_select_db( $MyVars[DATABASE] , $this->DBLink[$MyVars[LINK]] ); > >> } > >> } > >> > >> > >> Thanks! > >> > >> > >> Lewis > >> > >> > > Looks like you change the name of the index from NAME to LINK > and it should be $this->DBLink[$MyVars['LINK']] > > -- > regards, > Tom > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL Problem
Hi, Thursday, October 3, 2002, 6:01:53 PM, you wrote: O> You know...maybe I should mention where this code is... O> I have my main file which loads using 'require.once' a second file called O> 'everything.php'. O> Inside everything.php is a class called 'mainclass' which is called by the O> mail file. O> This class ('mainclass') loads the MySQL class from the previous post which O> is stored in yet another file, using require.once. O> MainClass then calls the MySQL->CONNECT and MySQL->CHOOSEDB functions. O> I know this sounds a bit over the top, but it works...at least it O> did...until now. I thought I'd mention the circumstances in case that makes O> a difference, which I suspect it will. O> Thanks again! O> Lewis O> "Orangehairedboy" <[EMAIL PROTECTED]> wrote in message O> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... >> Hi everyone! I can't figure out why this doesn't work. The call to the >> CONNECT function works and it connects with no problem, and it does save O> the >> Resource ID in $this->DBLink[]...however, when CHOOSEDB is called, the >> Resource ID just saved is gone. $this->DBLink is just empty, and I can't >> figure out why... >> >> Can anyone offer insight on this one? >> >> class MySQL >> { >> var $DBLink = array(); >> function CONNECT ( $MyVars , $MyContents ) >> { >> $host = ( $MyVars[PORT] ) ? $MyVars[HOST] . ":" . $MyVars[PORT] : >> $MyVars[HOST]; >> $this->DBLink[$MyVars[NAME]] = mysql_connect( $MyVars[HOST] , >> $MyVars[USERNAME] , $MyVars[PASSWORD] ); >> } >> function CHOOSEDB ( $MyVars , $MyContents ) >> { >> mysql_select_db( $MyVars[DATABASE] , $this->DBLink[$MyVars[LINK]] ); >> } >> } >> >> >> Thanks! >> >> >> Lewis >> >> Looks like you change the name of the index from NAME to LINK and it should be $this->DBLink[$MyVars['LINK']] -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql timestamp and php date
This is what I am using here: $db = DB::connect("mysql://$username:$password@$hostName/$databaseName"); if (DB::iserror($db)) die($db->getMessage()); $sql = "SELECT idnum, title, DATE_FORMAT(date, '%W, %M %D \@ %l:%i%p'), news FROM newslist ORDER BY idnum DESC"; $query = $db->query($sql); if (DB::iserror($query)) die($db->getMessage()); while ($query->fetchInto($row)) { echo "\n" . "\n\n\t$row[1] ID#$row[0]" . "\n\n\tAdded $row[2]" . "\n\n\t$row[3]" . "\n"; } I took out all the font formatting and stuff so its not so cluttered here. but it works just dandy, although I know what you are talkng about, when using the other way to connect it returns the name as whatever (like a COUNT(*) does). Although, I never knew the AS var thing, so that will help me with other stuff down the road! I know this is nothing fancy, but it is just what I've been wanting to do since before I started learning php and mysql. :) Bryan On Mon, 30 Sep 2002, Jason Young wrote: |No problem! | |Refresh MY memory here.. I noticed you didn't return the DATE_FORMAT |column "AS " .. is that working okay? I seemed to think that it |returned a long unwieldy column name.. maybe things are good.. let me |know :-D | |--Jason | -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql timestamp and php date
No problem! Refresh MY memory here.. I noticed you didn't return the DATE_FORMAT column "AS " .. is that working okay? I seemed to think that it returned a long unwieldy column name.. maybe things are good.. let me know :-D --Jason Bryan Koschmann - Gkt wrote: > Hi Jason, > > I had come across this earlier, and while I can get it to return > perfectly, I was more looking for something that I could do without having > to pull 2 queries. Err, well wait, I wouldn't have to would I? I have 4 > columns: > > idnum, title, date, news > > I was just doing a select * from newlist, but I suppose I can just address > each specifically: > > select idnum, title, DATE_FORMAT(date, '%W, %M %D \@ %h:%i%p'), news from > newslist > > right? Okay that works. > > (don't mind me talking to myself) > > Thanks for the help, and making me take a second to look further at it! > > Bryan > > > On Mon, 30 Sep 2002, Jason Young wrote: > > |In my pages, I just format the date from the SQL query: > | > |"SELECT DATE_FORMAT(last_modified, '%m/%d/%Y %h:%i:%s %p') AS > |last_modified (...)" > | > |Look up the DATE_FORMAT on mysql.com to get a list of the arguments. > | > |Hope this helps! > |-Jason > | > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql timestamp and php date
Hi Jason, I had come across this earlier, and while I can get it to return perfectly, I was more looking for something that I could do without having to pull 2 queries. Err, well wait, I wouldn't have to would I? I have 4 columns: idnum, title, date, news I was just doing a select * from newlist, but I suppose I can just address each specifically: select idnum, title, DATE_FORMAT(date, '%W, %M %D \@ %h:%i%p'), news from newslist right? Okay that works. (don't mind me talking to myself) Thanks for the help, and making me take a second to look further at it! Bryan On Mon, 30 Sep 2002, Jason Young wrote: |In my pages, I just format the date from the SQL query: | |"SELECT DATE_FORMAT(last_modified, '%m/%d/%Y %h:%i:%s %p') AS |last_modified (...)" | |Look up the DATE_FORMAT on mysql.com to get a list of the arguments. | |Hope this helps! |-Jason | -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL > Access
Thanks. That's fine, it's either $55 for this or a couple of hundred to pay someone to do it manually. Go figure ;-) Cheers, Liam - Original Message - From: "M1tch" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Saturday, September 21, 2002 3:51 AM Subject: [PHP] Re: MySQL > Access I had the problem a few days ago. Here's some software that makes it easy as clicking a button -> http://www.convert-in.com/sql2acc.htm Be warned though, it's only free to copy table structure. It requires registration to copy data. "Christian Calloway" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Can anyone suggest a strategy for importing data from MySQL to Access (it > sucks I know, but I have to do it for my work). I was thinking of using a > text-delimited file as an intermediate, but I am not quite sure on the > logistics. > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: mysql query
sorry bill, i misunderstood your question. I thought you wanted to only return one row, not just get one value. Given my new understanding, I would do something like this which is only a slight variant on what you did $result = mysql_query("select euro from brandstofprijzen where id=2") or die (mysql_error()); $row=mysql_fetch_array($result); $euro =$row[0]; -Original Message- From: bill [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 11, 2002 7:50 AM To: David Buerer Subject: Re: [PHP] Re: mysql query Maybe I wasn't clear. The value returned should be called "euro" not "row" I didn't think I needed LIMIT because the query should be written to only get one row; at least the function only returns the first row. kind regards, bill David Buerer wrote: Look into the LIMIT command, it will limit the number of rows in the result set to the number you specify -Original Message- From: bill [ mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> ] Sent: Wednesday, September 11, 2002 7:10 AM To: [EMAIL PROTECTED] Subject: [PHP] Re: mysql query function mysql_one_element($query, $element) { // quickly returns just one element from a query $one=mysql_query($query); // add error checking here if you wish $r=mysql_fetch_array($one); $thisvalue=$r[$element]; return($thisvalue); } $row=mysql_one_element("select euro from brandstofprijzen where id=2", "euro"); Chris Schoeman wrote: > I use the script below to get one value out of a database: > > $result = mysql_query("select euro from brandstofprijzen where id=2") > or die (mysql_error()); > while ($row = mysql_fetch_array($result)) > { > $euro = $row["euro"]; > } > mysql_free_result($result); > > This is working fine, but is there an easier (less code) way to do > this? > > Thankx -- PHP General Mailing List ( http://www.php.net/ <http://www.php.net/> ) To unsubscribe, visit: http://www.php.net/unsub.php <http://www.php.net/unsub.php>
RE: [PHP] Re: mysql query
Look into the LIMIT command, it will limit the number of rows in the result set to the number you specify -Original Message- From: bill [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 11, 2002 7:10 AM To: [EMAIL PROTECTED] Subject: [PHP] Re: mysql query function mysql_one_element($query, $element) { // quickly returns just one element from a query $one=mysql_query($query); // add error checking here if you wish $r=mysql_fetch_array($one); $thisvalue=$r[$element]; return($thisvalue); } $row=mysql_one_element("select euro from brandstofprijzen where id=2", "euro"); Chris Schoeman wrote: > I use the script below to get one value out of a database: > > $result = mysql_query("select euro from brandstofprijzen where id=2") > or die (mysql_error()); > while ($row = mysql_fetch_array($result)) > { > $euro = $row["euro"]; > } > mysql_free_result($result); > > This is working fine, but is there an easier (less code) way to do > this? > > Thankx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql statement (still a semi newbie)
I'm always making my inserts like this: $Insert = "INSERT INTO basket_db (name, image_id, customer_id, session_id) "; $Insert .= "VALUES ('$name', '$image_id', '$customer_id', '$PHPSESSID')"; ...and I'm using the SET Field = '$Value' in the Update Querys like this: $UpdateQuery = "UPDATE produkt "; $UpdateQuery .= "SET produkt_name = '$produkt_name', "; $UpdateQuery .= "size = '$size', kategorie = '$kategorie' "; $UpdateQuery .= "WHERE produkt_key = '$produkt_key'"; hope it helps someone out ;o) Schura - Original Message - From: "Tim Stoop" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, August 14, 2002 11:00 PM Subject: [PHP] Re: mysql statement (still a semi newbie) > Alexander Ross wrote: > > > That first column is an auto_incrementing column so i don't want any data > > INSERT INTO cast VALUES(DEFAULT, 'Rick', 'Blaine', 'Humphrey', 'Bogart', > > 'male'); > > I think you need to use NULL instead of DEFAULT... I'm not 100% sure. Just > try it :) > > -- > Kind regards, > Tim > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: mysql statement (still a semi newbie)
Tim's right about NULL. You can either specify what exactly are the fields of the row you want to update/insert using SET before VALUE (seek the manual at www.mysql.com for more info) or you can just write NULL (without any quotes) where the fields are automatic like *auto_increment* or like *timestamp*. I would suggest that you read more about syntax before you go on, and to place this kind of questions to the PHP Database list to get proper help. It is also a good idea for you to subscribe to the MySQL lists which are very crowded with MySQL gurus. HTH, C. > -Original Message- > From: Tim Stoop [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, August 14, 2002 6:00 PM > To: [EMAIL PROTECTED] > Subject: [PHP] Re: mysql statement (still a semi newbie) > > Alexander Ross wrote: > > > That first column is an auto_incrementing column so i don't want any > data > > INSERT INTO cast VALUES(DEFAULT, 'Rick', 'Blaine', 'Humphrey', 'Bogart', > > 'male'); > > I think you need to use NULL instead of DEFAULT... I'm not 100% sure. Just > try it :) > > -- > Kind regards, > Tim > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL - PHP combined log
Well, I think the solutions or ideas are maybe a bit too involved. I was hoping that the errors I am interested in were already logged by default to some obscure location, and I *could* if needed just go and scrutinize them by hand. But, it seems like a detailed (specially mysql) error log does not exist and thus cannot be scrutinized. Reading some of the possible solutions regarding adding error_log() functions to existing code leads me to believe that it could be easier to maybe incorporate those functions into PHP by means of a switch in php.ini, one could theoretically have two sets of functions, a mysql_query() for "normal" use that acts as we all know it, and another mysql_query() (yes, with the same name), that has the error_log() function call built into it, and the one that gets used is determined by the (lets call it) mysql_error_log = on in php.ini. This way, the entire thing will be transparent to both users and existing/future code. Granted, I have no idea how PHP is coded "behind the scenes" and if something like this is even possible, it's simply an idea, and hopefully some of the more learned people on this list will be able to comment on the feasability of something like that. Dave wrote: >>> >>> >how about this curve... getting PHP to append a line to the apache log. > How about reading the documentation? >>>Deserved that for not being clear enough... see below. >>> >>My apologies if I missed the word "access log" or even assumed you meant >>"error log" when you just said "log."I shouldn't have. >> > >RTFM never hurt anyone :) > >>You're right, you can't do that, without opening up security more than you >>want to. >> >>*ACTUALLY*... >> >>There *probably* is an Apache function for access logs just like the error >>logging one that PHP is using, and you could *PROBABLY* patch PHP with some >>dead-easy copy&paste to use it, and you could even submit that worthy patch >>to the PHP Group. I suspect it's not there only because nobody really saw a >>need for it. >> > >I've never had a use for it untill now, wanting to charge a customer for massive >uploads via file_upload forms... transfer that is not recorded in the apache >logs and therefor not collected for billable bandwidth (while still preserving >IP addresses and avoiding a ipfw counting per IP). Probably a requirement with >limited scope. > >>It's kinda icky that you'd almost have to use 4 (the next unused number) for >>"Apache access log" with 0 being "Apache error log" and 1,2,3 being other >>stuff between... Maybe -1 for "access log"? Ew. That's not 'right' >>either, but maybe it's 'less wrong' than 4. >> > >icky, I agree > >>Damn things shouldn't have been magic numbers in the first place. Should be >>constants. Hey, while you're in there, make up some decent constant names >>and let's migrate to them and then deprecate the magic numbers and fix it >>right :-) >> > >:) > >>Another option might involve some sort of nasty named pipe stuff and >>redirection and whatnot, and you *MIGHT* be able to have a "file" that you >>error_log into, but it really just ends up going into the Apache log... >>There may be some risk of corrupting your access log, however, if any >>incredibly *HUGE* entry over-steps the atomicity threshold for file >>appending in Linux... >> > >sounds like a nest of potential problems > >>Not so sure it's a Good Idea anyway to have two programs trying to write to >>the same file at once if it can be avoided. >> > >thus the interim solution of having PHP write to a seperate log file, then doing >a merge/sort during rotation time. > >Will look into it to see if something can be presented without creating more >problems than the solution is worth. > >Cheers, > >Dave > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: MySQL - PHP combined log
>> how about this curve... getting PHP to append a line to the apache log. >>> >>>How about reading the documentation? >> >>Deserved that for not being clear enough... see below. > >My apologies if I missed the word "access log" or even assumed you meant >"error log" when you just said "log."I shouldn't have. RTFM never hurt anyone :) >You're right, you can't do that, without opening up security more than you >want to. > >*ACTUALLY*... > >There *probably* is an Apache function for access logs just like the error >logging one that PHP is using, and you could *PROBABLY* patch PHP with some >dead-easy copy&paste to use it, and you could even submit that worthy patch >to the PHP Group. I suspect it's not there only because nobody really saw a >need for it. I've never had a use for it untill now, wanting to charge a customer for massive uploads via file_upload forms... transfer that is not recorded in the apache logs and therefor not collected for billable bandwidth (while still preserving IP addresses and avoiding a ipfw counting per IP). Probably a requirement with limited scope. >It's kinda icky that you'd almost have to use 4 (the next unused number) for >"Apache access log" with 0 being "Apache error log" and 1,2,3 being other >stuff between... Maybe -1 for "access log"? Ew. That's not 'right' >either, but maybe it's 'less wrong' than 4. icky, I agree >Damn things shouldn't have been magic numbers in the first place. Should be >constants. Hey, while you're in there, make up some decent constant names >and let's migrate to them and then deprecate the magic numbers and fix it >right :-) :) >Another option might involve some sort of nasty named pipe stuff and >redirection and whatnot, and you *MIGHT* be able to have a "file" that you >error_log into, but it really just ends up going into the Apache log... >There may be some risk of corrupting your access log, however, if any >incredibly *HUGE* entry over-steps the atomicity threshold for file >appending in Linux... sounds like a nest of potential problems >Not so sure it's a Good Idea anyway to have two programs trying to write to >the same file at once if it can be avoided. thus the interim solution of having PHP write to a seperate log file, then doing a merge/sort during rotation time. Will look into it to see if something can be presented without creating more problems than the solution is worth. Cheers, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL - PHP combined log
> >>>how about this curve... getting PHP to append a line to the apache log. >> >>How about reading the documentation? > >Deserved that for not being clear enough... see below. My apologies if I missed the word "access log" or even assumed you meant "error log" when you just said "log."I shouldn't have. You're right, you can't do that, without opening up security more than you want to. *ACTUALLY*... There *probably* is an Apache function for access logs just like the error logging one that PHP is using, and you could *PROBABLY* patch PHP with some dead-easy copy&paste to use it, and you could even submit that worthy patch to the PHP Group. I suspect it's not there only because nobody really saw a need for it. It's kinda icky that you'd almost have to use 4 (the next unused number) for "Apache access log" with 0 being "Apache error log" and 1,2,3 being other stuff between... Maybe -1 for "access log"? Ew. That's not 'right' either, but maybe it's 'less wrong' than 4. Damn things shouldn't have been magic numbers in the first place. Should be constants. Hey, while you're in there, make up some decent constant names and let's migrate to them and then deprecate the magic numbers and fix it right :-) Another option might involve some sort of nasty named pipe stuff and redirection and whatnot, and you *MIGHT* be able to have a "file" that you error_log into, but it really just ends up going into the Apache log... There may be some risk of corrupting your access log, however, if any incredibly *HUGE* entry over-steps the atomicity threshold for file appending in Linux... Not so sure it's a Good Idea anyway to have two programs trying to write to the same file at once if it can be avoided. -- Like Music? http://l-i-e.com/artists.htm I'm looking for a PRO QUALITY two-input sound card supported by Linux (any major distro). Need to record live events (mixed already) to stereo CD-quality. Soundcard Recommendations? Software to handle the recording? Don't need fancy mixer stuff. Zero (0) post-production time. Just raw PCM/WAV/AIFF 16+ bit, 44.1KHz, Stereo audio-to-disk. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: MySQL - PHP combined log
>>how about this curve... getting PHP to append a line to the apache log. > >How about reading the documentation? Deserved that for not being clear enough... see below. >http://php.net/error_log > >>would much rather pump the clf formatted log sting directly into the >appropriate >>apache log, but if I am not mistaken, using the above function would require >>permissions for user nobody(www, whatever) on the log files, no? > >Nope. >PHP is running as part of Apache. >PHP can ask Apache to write stuff into its own log. >That's one of the features of http://php.net/error_log > error_log into the apache generated "httpd-error.log" (or whatever you like to have it named) works just fine. error_log($fEntry,0); #success, entry appears in httpd-error.log What I am trying to do is to append an entry to the bottom of the "httpd-access.log" when the file upload succeeds to record the filesize etc... when attempting to do so a permission error is generated since uid nobody(web server) isn't allowed to write to the log file which is owned by the user (or root, or whomever) in this case (safe mode restriction, and file permissions) the safe mode restriction and file permissions are bypassed when writing to the httpd-error.log file, as the command was evidently designed to do. It does not bypass when using error_log($fEntry,3,"/path/to/httpd-access.log"); even though both files have the same ownership and permissions(644)... the command simply succeeds on the httpd-error.log and doesn't on the httpd-access.log ...or more correctly on our server setup :) Could remove safe mode and modify file permissions, but that requires opening up security (and log editing by clients) to accomplish it. Or am I missing something? Cheers, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL - PHP combined log
>Thanks, but all these "methods" require modification of the scripts >already on the server, and it won't ensure any new script being written >by a user on my system to comply. That is correct. >Are you all saying that there are no logs kept by default of errors >generated on php/mysql pages at all unless specifically coded? Wouldn't >it be possible then in future PHP releases to have a "set_error_logging" >directive in the php.ini file that will automatically run a wrapper >function on all mysql_query() functions to do this kind of thing? There *IS* a setting in php.ini to log every error. However, it only logs PHP errors, not unreported MySQL errors. I think you *MUST* write some PHP code to get MySQL errors to appear in the first place, and you'd have to write even more code to get them to be considered PHP errors -- I *THINK*. Never turned on this feature, so can't be 100% certain. >How are people out there managing the scripts/script errors caused by >users on their systems? Or is it a case of "handling the crisis when it >happens"? In most cases, dedicated applications *ARE* using a common 'include' file and the Project Manager or Lead Developer will kill you if you don't. In a shared ISP sort of environment, you just have to educate your users, and be sure you make it easy for them to Do The Right Thing. Does their default include_path have a non web-tree directory conveniently placed in their home directory for them to throw their db_connnect.inc file into it? My ISP does that, but I dunno if the rest are that smart or not. He called the directory 'php' instead of 'include' like I would have, but I can live with that. :-) Actually, he provides a db class pre-built in a file in that directory, along with some custom pre-built PHP scripts like guestbook and Tour Calendar... But that's because he focuses on a particular market. >You see, as administrator, I need to be able to quickly see who are >coding in such a way as to leave security holes, or even worse, cause >the server to crash due to poor coding. There are almost 1000 individual >php files on my server, and it wouldn't be possible for me to scrutinize >all of them to make sure they are OK. You won't catch a security hole by logging anyway, I don't think... Though I guess you could pull out the file names and make sure they aren't in the web-tree and aren't, say, world-writable (shudder). 1000 PHP files? That's not that many :-) If you need to log every MySQL query specifically, that's *probably* gonna be a debugging feature (not recommended for production use) in /etc/my.conf, assuming a recent install following the instructions that come with MySQL. If you installed with Triad or an RPM or anything like that, you're on your own. It's actually fairly hard to bring down the whole machine using PHP and MySQL -- You'd have to work at it, or do something incredibly stupid... Locking up or killing off a single Apache child is less unlikely (still not common) but that usually takes care of itself with Apache children doomed to die within a certain time-frame or # of requests. So you run enough Apache children that it doesn't matter if a few get locked up for awhile. >Are there any admins out there that have policies about scripting >practices on their systems; ie, checking a script from a user before it >is allowed to be uploaded etc? Possibly. But that's *GOT* to be very resource-intensive on the human side, and probably not useful for most situations. I think the actual answer is that *MOST* admins are looking at the "big picture" and monitoring their machines rather than try to force users into a single channel or scrutinize every line of code. If you try to force users into a single channel, you'll either make them all frustrated and drive them away, or there will be so many who find some work-around that it won't really be effective anyway. I think we can safely say that scrutinizing every line of code is not an option for most. Set up a monitoring system of your critical services (HTTP, MySQL) and just focus on quality of service, rather than perfection of your users. While I understand your concerns, I think you're focusing too much on the details of what could go wrong, and missing the forest for the trees. If something does go wrong, there will most likely be physical evidence (logs, error messages, top output) that you can use to find the problem quickly. In the rare cases where it doesn't, be prepared to turn on logging and take the performance hit until you *CAN* find it. Another suggestion: Provide a "development" setup for your users. If they have an easy place to put scripts/database calls and pound on it before it goes into Production to a live audience, they'll more likely use that and make sure the damn thing doesn't take down anything before going "live" -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: htt
Re: [PHP] Re: MySQL - PHP combined log
> >>>I want to be able to view a single log that contains the following: > >> >>http://php.net/error_log >> > >how about this curve... getting PHP to append a line to the apache log. How about reading the documentation? http://php.net/error_log >would much rather pump the clf formatted log sting directly into the appropriate >apache log, but if I am not mistaken, using the above function would require >permissions for user nobody(www, whatever) on the log files, no? Nope. PHP is running as part of Apache. PHP can ask Apache to write stuff into its own log. That's one of the features of http://php.net/error_log NOTE: If you are running PHP as a CGI, this probably ain't gonna work, because, as noted, you need access to those logs, and PHP running as a CGI is a separate process and probably can't convince Apache that it's kosher to write into its log files. YMMV. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: MySQL - PHP combined log
I guess I missed the part where you wanted to implement something w/o changing existing scripts. There's no easy way to do it right now. You could write a script that'll run in the background and combine all of the error logs together. You can turn on error logs for PHP and for MySQL. You'll still have the problem of identifying which PHP page caused the MySQL error, though... ---John Holmes... > -Original Message- > From: PHPCoder [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, July 23, 2002 2:23 AM > To: Richard Lynch > Cc: php-general > Subject: Re: [PHP] Re: MySQL - PHP combined log > > Thanks, but all these "methods" require modification of the scripts > already on the server, and it won't ensure any new script being written > by a user on my system to comply. > Are you all saying that there are no logs kept by default of errors > generated on php/mysql pages at all unless specifically coded? Wouldn't > it be possible then in future PHP releases to have a "set_error_logging" > directive in the php.ini file that will automatically run a wrapper > function on all mysql_query() functions to do this kind of thing? > > How are people out there managing the scripts/script errors caused by > users on their systems? Or is it a case of "handling the crisis when it > happens"? > You see, as administrator, I need to be able to quickly see who are > coding in such a way as to leave security holes, or even worse, cause > the server to crash due to poor coding. There are almost 1000 individual > php files on my server, and it wouldn't be possible for me to scrutinize > all of them to make sure they are OK. > Are there any admins out there that have policies about scripting > practices on their systems; ie, checking a script from a user before it > is allowed to be uploaded etc? > > Thanks > > > Richard Lynch wrote: > > >>Hi, tried this on mysql list, no luck: > >> > >>I want to be able to view a single log that contains the following: > >> > >>IP of user : page_name (PHP only): time/date: MySQL query ( 'select * > >> > >>from xxx' etc.) : error msg from mysql/php if any > > > >>So it's almost a hybrid between apache and mysql with some extra's > >> > >>I'm sure you all should see the benifit of this in troubleshooting and > >>specially keeping track of who does what when it comes to PHP coding on > >>ones server, specially with crappy code that kills the server. > >> > >>Is something like this possible, already there? > >> > >>PS, Running RedHat 7.0 with PHP4 and mysql 3.23.x > >> > > > >http://php.net/error_log > > > >if you can get everybody to use your own function to query the database. > > > >Or, you could use http://php.net/set_error_handler and > >http://php.net/trigger_error and catch all errors thrown by all PHP code. > > > >Actually, to get the PHP page name and line number, set_error_handler is > >probably your best bet. > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL - PHP combined log
Thanks, but all these "methods" require modification of the scripts already on the server, and it won't ensure any new script being written by a user on my system to comply. Are you all saying that there are no logs kept by default of errors generated on php/mysql pages at all unless specifically coded? Wouldn't it be possible then in future PHP releases to have a "set_error_logging" directive in the php.ini file that will automatically run a wrapper function on all mysql_query() functions to do this kind of thing? How are people out there managing the scripts/script errors caused by users on their systems? Or is it a case of "handling the crisis when it happens"? You see, as administrator, I need to be able to quickly see who are coding in such a way as to leave security holes, or even worse, cause the server to crash due to poor coding. There are almost 1000 individual php files on my server, and it wouldn't be possible for me to scrutinize all of them to make sure they are OK. Are there any admins out there that have policies about scripting practices on their systems; ie, checking a script from a user before it is allowed to be uploaded etc? Thanks Richard Lynch wrote: >>Hi, tried this on mysql list, no luck: >> >>I want to be able to view a single log that contains the following: >> >>IP of user : page_name (PHP only): time/date: MySQL query ( 'select * >> >>from xxx' etc.) : error msg from mysql/php if any > >>So it's almost a hybrid between apache and mysql with some extra's >> >>I'm sure you all should see the benifit of this in troubleshooting and >>specially keeping track of who does what when it comes to PHP coding on >>ones server, specially with crappy code that kills the server. >> >>Is something like this possible, already there? >> >>PS, Running RedHat 7.0 with PHP4 and mysql 3.23.x >> > >http://php.net/error_log > >if you can get everybody to use your own function to query the database. > >Or, you could use http://php.net/set_error_handler and >http://php.net/trigger_error and catch all errors thrown by all PHP code. > >Actually, to get the PHP page name and line number, set_error_handler is >probably your best bet. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: MySQL - PHP combined log
>>I want to be able to view a single log that contains the following: > >http://php.net/error_log > how about this curve... getting PHP to append a line to the apache log. Currently we are exporting via fopen clf formatted logs for file uploads (whose file sizes are not recorded by Apache's logging) then doing a merge of the log files afterwards... would much rather pump the clf formatted log sting directly into the appropriate apache log, but if I am not mistaken, using the above function would require permissions for user nobody(www, whatever) on the log files, no? cheers, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: MySQL fetch data
Jeff, Also, try php.weblogs.com ADODB if you absolutly MUST have all of your data in an array. I'll agree with Richard that it's not a great idea unless there is a specific need. While loops for displaying the contents of many records are much better. (IMHO, etc...) =C= * * Cal Evans * Journeyman Programmer * Techno-Mage * http://www.calevans.com * -Original Message- From: Richard Lynch [mailto:[EMAIL PROTECTED]] Sent: Sunday, June 30, 2002 5:41 PM To: [EMAIL PROTECTED] Subject: [PHP] Re: MySQL fetch data In article <00e001c21db3$7b1b66a0$0a01a8c0@jcowart> , [EMAIL PROTECTED] (Jefferson Cowart) wrote: >Is there any way to return all the rows returned by a mysql query with >one command. Currently I have to run through a for or while loop the >same number of times as there are rows and take that row and copy it to >an array. I end up with an array of arrays but it seems like it would be >a common enough problem that the function would already exist. Why do you think you need the data in an array? Usually, you can just deal with it immediately and discard it. I think Oracle lets you snatch a whole array at once, but not MySQL. If you screw up your SQL, you don't want to try to snatch the whole thing at once anyway -- The potential for trashing your web/db-server by asking for, oh, 10,000 records at once is just too high. Better safe than sorry. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL Problem with PHP
On Wednesday, June 26, 2002, at 08:58 AM, John Holmes wrote: >> I just preg_replace("/\'/","\'",$text) and all was good :o) > > That's what addslashes() is for. It handles single and double quotes, > backslashes, and nulls, so you won't have any problems... Plus IIRC it's a C extension so it'll run faster anyway. Erik Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: MySQL Problem with PHP
> I just preg_replace("/\'/","\'",$text) and all was good :o) That's what addslashes() is for. It handles single and double quotes, backslashes, and nulls, so you won't have any problems... ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: MySQL or FlatFile
I am very new to PHP(Still awaiting a book, Only done a few tutorials and read bits of the PHP manual). But if you used: mysql_pconnect($host, $user, $password) It would keep a consistant connection to the database so it may speed things up a bit. JJ Harrison[EMAIL PROTECTED]www.tececo.com -Original Message- If the content is going to be the same each time, then loading from aflat-file would probably be better, because accessing a database wouldrequire the connection to be established, the database to parse and executeyour query, then send that data back. Where as reading from the file, it'sjust open file, read file, close file, a lot quicker.-Original Message-From: David Duong [mailto:[EMAIL PROTECTED]]Sent: Monday, May 13, 2002 10:46 AMTo: [EMAIL PROTECTED]Subject: [PHP] Re: MySQL or FlatFileI am referring to whole PHP/Perl files. It is necessary to load them asmuch as 20+ times within the same hour what would be better MySql orFlatfile?-- PHP General Mailing List (http://www.php.net/)To unsubscribe, visit: http://www.php.net/unsub.php-- PHP General Mailing List (http://www.php.net/)To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: MySQL or FlatFile
If the content is going to be the same each time, then loading from a flat-file would probably be better, because accessing a database would require the connection to be established, the database to parse and execute your query, then send that data back. Where as reading from the file, it's just open file, read file, close file, a lot quicker. -Original Message- From: David Duong [mailto:[EMAIL PROTECTED]] Sent: Monday, May 13, 2002 10:46 AM To: [EMAIL PROTECTED] Subject: [PHP] Re: MySQL or FlatFile I am referring to whole PHP/Perl files. It is necessary to load them as much as 20+ times within the same hour what would be better MySql or Flatfile? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php