Re: [PHP] PHP+MySQL question
On 11-02-16 11:37 AM, דניאל דנון wrote: Hi. I have a table called images with 4 columns - `image_id`, `item_name`, `image_url`, `image_views` (Where image_id is UNIQUE and AUTO-INCREMENT). Sometimes, there might be many items with the same name (but not with the same url). I want to make sure that each item name has at most 3 images (and therefore I need to delete the rest). The problem is that I want to keep the images with the most views. I've tried to look for efficient solutions either in MySQL or in PHP, but they are mostly very resource-intensive, Such as selecting all different names in PHP (using GROUP BY), then, for each name, doing DELETE FROM images WHERE item_name = 'ITEM-NAME-HERE' ORDER BY image_views ASC LIMIT (here some sub-query with count on how many rows have the name ITEM-NAME-HERE minus 3). I'd be glad if anyone could help me or point me to the right direction. I'd use a cron job to manage the purging process... and off the top of my head I'd probably go the following route: Get the list of images with more than 3 of the same name: SELECT item_name, SUM( 1 ) AS total FROM images HAVING total 3; Get the 3 best images for each image returned above: SELECT image_id FROM images WHERE image_name = '[[NAME]]' ORDER BY image_views DESC. (Make sure to quote your criteria properly in the above-- this is pseudo codish). Now delete the laggards using the ID we just retrieved: DELETE FROM images WHERE image_id NOT IN ([[ID_LIST]]). That should get you to a decent solution. Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP+MySQL question
On 11-02-16 11:55 AM, Robert Cummings wrote: On 11-02-16 11:37 AM, דניאל דנון wrote: Hi. I have a table called images with 4 columns - `image_id`, `item_name`, `image_url`, `image_views` (Where image_id is UNIQUE and AUTO-INCREMENT). Sometimes, there might be many items with the same name (but not with the same url). I want to make sure that each item name has at most 3 images (and therefore I need to delete the rest). The problem is that I want to keep the images with the most views. I've tried to look for efficient solutions either in MySQL or in PHP, but they are mostly very resource-intensive, Such as selecting all different names in PHP (using GROUP BY), then, for each name, doing DELETE FROM images WHERE item_name = 'ITEM-NAME-HERE' ORDER BY image_views ASC LIMIT (here some sub-query with count on how many rows have the name ITEM-NAME-HERE minus 3). I'd be glad if anyone could help me or point me to the right direction. I'd use a cron job to manage the purging process... and off the top of my head I'd probably go the following route: Get the list of images with more than 3 of the same name: SELECT item_name, SUM( 1 ) AS total FROM images HAVING total 3; Get the 3 best images for each image returned above: SELECT image_id FROM images WHERE image_name = '[[NAME]]' ORDER BY image_views DESC. Oops... that should have a LIMIT clause on it: SELECT image_id FROM images WHERE image_name = '[[NAME]]' ORDER BY image_views DESC LIMIT 3 Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP MYSQL sorting
At 8:16 PM -0400 4/11/10, Ernie Kemp wrote: Simple idea I thought. I need a webpage that displays a drop down list of number with a checkbox on the side that when checked will select the database again only in descending order. Small database with maybe 100 records. The user can click the submit button when they have located the correct number. The trick is to make the checkbox trigger a new Select statement. Thanks. Ernie: form name=myForm action= input type=checkbox name=sort id=sort onClick=getData(this) /form The javascript getData() will have to launch a php script to get the data again OR you can simply sort the data yourself using sort(). Here's another idea using jQuery: http://webbytedd.com/jquery/sortable-table/ Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP MYSQL sorting
You can use javascript to trigger an onclick function every time a checkbox is selected. The onclick function can make an ajax call to a remote php script which can then make the database query.
Re: [PHP] PHP MYSQL sorting
On 04/12/10 05:46, Ernie Kemp wrote: Simple idea I thought. I need a webpage that displays a drop down list of number with a checkbox on the side that when checked will select the database again only in descending order. Small database with maybe 100 records. The user can click the submit button when they have located the correct number. The trick is to make the checkbox trigger a new Select statement. Thanks. Use jquery, trigger an ajax request onclick of that checkbox. -- Nilesh Govindarajan Site Server Administrator www.itech7.com मेरा भारत महान ! मम भारत: महत्तम भवतु ! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP MySQL Insert Statements
2010/3/12 Martine Osias webi...@gmail.com Hi, My insert statements on this web page don't execute. The select statements do work. This tells me that the database connection is working. The username and password are the administrator's. What else could prevent the insert statements from executing? The assigned permissions to that account. Using MySQL, you can define *who* is allowed to do *what*. (i.e. SELECT, INSERT, GRANT) (or syntax errors in your insert statements, like others said before.) Regards
Re: [PHP] PHP MySQL Insert Statements
Always make sure your dynamic sql string in php code are as expected var_dump($sql) before query On Thu, Mar 11, 2010 at 10:13 PM, Martine Osias webi...@gmail.com wrote: Hi, My insert statements on this web page don't execute. The select statements do work. This tells me that the database connection is working. The username and password are the administrator's. What else could prevent the insert statements from executing? Thank you. Martine -- 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] PHP MySQL Insert Statements
2010/3/11 Martine Osias webi...@gmail.com: Hi, My insert statements on this web page don't execute. The select statements do work. This tells me that the database connection is working. The username and password are the administrator's. What else could prevent the insert statements from executing? Would you mind giving us some hints about how the INSERT statements looks like? Thanks. Thank you. Martine -- 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] PHP MySQL Insert Statements
Martine Osias wrote: My insert statements on this web page don't execute. The select statements do work. This tells me that the database connection is working. The username and password are the administrator's. What else could prevent the insert statements from executing? Most likely syntax of the insert statement. Do your insert statements work if used in MySQL Query Browser? What is MySQL returning? Are you using OOP or old functions? Have you tried having PHP echo your insert statement so you can see exactly what you are sending MySQL? Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP MySQL Insert Statements
Martine Osias wrote: Hi, My insert statements on this web page don't execute. The select statements do work. This tells me that the database connection is working. The username and password are the administrator's. What else could prevent the insert statements from executing? Thank you. Martine Should be trivial to find out what's happening. Something like: $success=mysql_query($insert_statement) or die(Uh-oh, mysql said:.mysql.error()); HTH, Kevin Kinsey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP / mySQL Project... Real men use 'cat'
On Wed, Feb 24, 2010 at 5:12 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Wed, 2010-02-24 at 09:18 +, Pete Ford wrote: sudo ln -s /bin/cat /bin/dog sudo ln -s /bin/cat /bin/rabbit sudo ln -s /bin/cat /bin/rat Sorted... But now they're in /bin, surely at some point you'll want to execute these poor pets? Haven't they been through enough already?! Thanks, Ash http://www.ashleysheridan.co.uk If you have a cat, dog, rabbit and rat together in a bin, you probably won't have to execute them. At least not all of them. :-P Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP / mySQL Project... Real men use 'cat'
On Wed, 2010-02-24 at 09:22 -0500, Andrew Ballard wrote: On Wed, Feb 24, 2010 at 5:12 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Wed, 2010-02-24 at 09:18 +, Pete Ford wrote: sudo ln -s /bin/cat /bin/dog sudo ln -s /bin/cat /bin/rabbit sudo ln -s /bin/cat /bin/rat Sorted... But now they're in /bin, surely at some point you'll want to execute these poor pets? Haven't they been through enough already?! Thanks, Ash http://www.ashleysheridan.co.uk If you have a cat, dog, rabbit and rat together in a bin, you probably won't have to execute them. At least not all of them. :-P Andrew Reminds me of Eddie Izzards Noah's Ark sketch: http://www.youtube.com/watch?v=CFdmG-TRxzE The bit I'm thinking of is about 6 minutes in ;) Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] PHP / mySQL Project... Real men use 'cat'
On Wed, 2010-02-24 at 14:24 +, Ashley Sheridan wrote: On Wed, 2010-02-24 at 09:22 -0500, Andrew Ballard wrote: On Wed, Feb 24, 2010 at 5:12 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Wed, 2010-02-24 at 09:18 +, Pete Ford wrote: sudo ln -s /bin/cat /bin/dog sudo ln -s /bin/cat /bin/rabbit sudo ln -s /bin/cat /bin/rat Sorted... But now they're in /bin, surely at some point you'll want to execute these poor pets? Haven't they been through enough already?! Thanks, Ash http://www.ashleysheridan.co.uk If you have a cat, dog, rabbit and rat together in a bin, you probably won't have to execute them. At least not all of them. :-P Andrew Reminds me of Eddie Izzards Noah's Ark sketch: http://www.youtube.com/watch?v=CFdmG-TRxzE The bit I'm thinking of is about 6 minutes in ;) Thanks, Ash http://www.ashleysheridan.co.uk Actually, this clip is a bit better: http://www.youtube.com/watch?v=GrP8ey8VheU Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] PHP / mySQL Project... Real men use 'cat'
On 23 February 2010 00:28, Daevid Vincent dae...@daevid.com wrote: -Original Message- From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] On Mon, 2010-02-22 at 14:39 -0800, Don Wieland wrote: I am needing assistance IMMEDIATELY in finishing up a project (the developer went in to have shoulder surgery and will be out of commission for 3 weeks) and I need this finished soon. That only puts one arm out of action surely? A real programmer would use the one hand! Real programmers use 'cat'. I've always found 'dog' and 'rabbit' to be more stimulating. -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP / mySQL Project... Real men use 'cat'
Depends on what you do with them! Bastien Sent from my iPod On Feb 23, 2010, at 6:42 AM, Richard Quadling rquadl...@googlemail.com wrote: On 23 February 2010 00:28, Daevid Vincent dae...@daevid.com wrote: -Original Message- From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] On Mon, 2010-02-22 at 14:39 -0800, Don Wieland wrote: I am needing assistance IMMEDIATELY in finishing up a project (the developer went in to have shoulder surgery and will be out of commission for 3 weeks) and I need this finished soon. That only puts one arm out of action surely? A real programmer would use the one hand! Real programmers use 'cat'. I've always found 'dog' and 'rabbit' to be more stimulating. -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- 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] PHP / mySQL Project...
At 11:46 PM + 2/22/10, Ashley Sheridan wrote: On Mon, 2010-02-22 at 14:39 -0800, Don Wieland wrote: Hello, I am needing assistance IMMEDIATELY in finishing up a project (the developer went in to have shoulder surgery and will be out of commission for 3 weeks) and I need this finished soon. -snip- Don Wieland D W D a t a C o n c e p t s That only puts one arm out of action surely? A real programmer would use the one hand! Only joking, hope his/her surgery goes without any problems. Thanks, Ash I was thinking the same thing. I suffered a massive DVT and PE that confined me to a hospital bed for three weeks, yet I worked almost every day with my laptop. Some clients understand and some don't. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP / mySQL Project... Real men use 'cat'
Am I the only Linux/Unix guy here? Do you guys not know what 'cat' is? :-\ http://en.wikipedia.org/wiki/Cat_(Unix) http://techrepublic.com.com/5208-12846-0.html?forumID=102threadID=310099m essageID=3099392tag=content;leftCol -Original Message- From: Richard Quadling [mailto:rquadl...@googlemail.com] Sent: Tuesday, February 23, 2010 3:43 AM On 23 February 2010 00:28, Daevid Vincent dae...@daevid.com wrote: -Original Message- From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] On Mon, 2010-02-22 at 14:39 -0800, Don Wieland wrote: I am needing assistance IMMEDIATELY in finishing up a project (the developer went in to have shoulder surgery and will be out of commission for 3 weeks) and I need this finished soon. That only puts one arm out of action surely? A real programmer would use the one hand! Real programmers use 'cat'. I've always found 'dog' and 'rabbit' to be more stimulating. -Original Message- From: Phpster [mailto:phps...@gmail.com] Sent: Tuesday, February 23, 2010 4:56 AM Depends on what you do with them! Bastien -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP / mySQL Project... Real men use 'cat'
On Tue, 2010-02-23 at 15:06 -0800, Daevid Vincent wrote: Am I the only Linux/Unix guy here? Do you guys not know what 'cat' is? :-\ http://en.wikipedia.org/wiki/Cat_(Unix) http://techrepublic.com.com/5208-12846-0.html?forumID=102threadID=310099m essageID=3099392tag=content;leftCol -Original Message- From: Richard Quadling [mailto:rquadl...@googlemail.com] Sent: Tuesday, February 23, 2010 3:43 AM On 23 February 2010 00:28, Daevid Vincent dae...@daevid.com wrote: -Original Message- From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] On Mon, 2010-02-22 at 14:39 -0800, Don Wieland wrote: I am needing assistance IMMEDIATELY in finishing up a project (the developer went in to have shoulder surgery and will be out of commission for 3 weeks) and I need this finished soon. That only puts one arm out of action surely? A real programmer would use the one hand! Real programmers use 'cat'. I've always found 'dog' and 'rabbit' to be more stimulating. -Original Message- From: Phpster [mailto:phps...@gmail.com] Sent: Tuesday, February 23, 2010 4:56 AM Depends on what you do with them! Bastien It's like a dog, but smaller and smarter :p Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] PHP / mySQL Project... Real men use 'cat'
On Tue, Feb 23, 2010 at 11:05:14PM +, Ashley Sheridan wrote: On Tue, 2010-02-23 at 15:06 -0800, Daevid Vincent wrote: http://techrepublic.com.com/5208-12846-0.html?forumID=102threadID=310099messageID=3099392tag=content;leftCol That guy's partial to JOE. Pffft. Real men use Vim. And Emacs is for Martians with ten fingers on each hand. And yeah, for what it's worth, I've been running Linux since 1996. And yeah, cats are smarter than dogs. Flame on! ;-} Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP / mySQL Project...
On Mon, 2010-02-22 at 14:39 -0800, Don Wieland wrote: Hello, I am needing assistance IMMEDIATELY in finishing up a project (the developer went in to have shoulder surgery and will be out of commission for 3 weeks) and I need this finished soon. Candidate must have good english skills, a solid knowledge of HTML, CSS, PHP, mySQL, Javascript, AJAX, and JQuery. Developer may work remotely. Please contact me via email, PRIVATELY, with your skills and sample of online project you have done. Also, this will be an hourly job - so what Hourly Rate you expect to get paid would be nice. Thanks! Don Wieland D W D a t a C o n c e p t s ~ d...@dwdataconcepts.com Direct Line - (949) 305-2771 Integrated data solutions to fit your business needs. Need assistance in dialing in your FileMaker solution? Check out our Developer Support Plan at: http://www.dwdataconcepts.com/DevSup.html Appointment 1.0v9 - Powerful Appointment Scheduling for FileMaker Pro 9 or higher http://www.appointment10.com For a quick overview - http://www.appointment10.com/Appt10_Promo/Overview.html That only puts one arm out of action surely? A real programmer would use the one hand! Only joking, hope his/her surgery goes without any problems. Thanks, Ash http://www.ashleysheridan.co.uk
RE: [PHP] PHP / mySQL Project... Real men use 'cat'
-Original Message- From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] On Mon, 2010-02-22 at 14:39 -0800, Don Wieland wrote: I am needing assistance IMMEDIATELY in finishing up a project (the developer went in to have shoulder surgery and will be out of commission for 3 weeks) and I need this finished soon. That only puts one arm out of action surely? A real programmer would use the one hand! Real programmers use 'cat'. ;-) I don't see Stephen Hawking complaining... In fact, he raps about it! http://www.mchawking.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP/MySQL Superstars
At 4:29 PM -0400 10/1/09, Robert Cummings wrote: I'm a superstar... send me a check for $500,000 and I'll fly on over. Or did you completely misuse the word superstar? Cheers, Rob. Rob: Well, in my book you are a superstar. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP/MySQL Superstars
I'm a superstar... send me a check for $500,000 and I'll fly on over. Or did you completely misuse the word superstar? Cheers, Rob. Jerome Botbol wrote: Hi All, We require a PHP / MySQL superstar to work in-house at our offices near Edgware, London for 3 months on a ground breaking new web 2.0 project which involves a variety of exciting new technologies. You will need at least 2 years proven experience on commercial projects. Relevant experience on the CI framework is a must. You will be working with an actionscript and front-end XHTML developer, a framework developer who is providing a database design and class system and a design team. Please email your CV to j...@cyber-duck.co.uk (reference PG-tech-01) or feel free to contact me directly. Please let me know if this is of interest to you. Kind regards Jerome Operations Manager | Cyber-Duck Ltd | http://www.cyber-duck.co.uk/ 020 8736 0920 -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php/mysql Query Question.
I tend to do this robert, while looking at your example i thought to myself since i am trying to mimick a shell command why not run one. Result: ? $db = 'db'; $host = 'host'; $user = 'user'; $pass = 'pass'; $query = select * from $db.my_table; $ddvery = shell_exec(mysql -u$user -p$pass --html --execute=$query); echo pre$ddvery/pre; ? Not are the results safe but the unlimited possibilites are amazing. Thanks so much for the kick starter ad...@buskirkgraphics.com wrote: Would you mind giving me an example of this that i can stick right into a blank php file and run. I get what you are saying but i cant seem to make that even echo out the data. php 5.2 mysql 5.1.3 Apache 2.2 ?php $db = 'db'; $host = 'host'; $user = 'user'; $pass = 'pass'; $query = select * from my_table; $db = escapeShellArg( $db ); $host = escapeShellArg( $host ); $user = escapeShellArg( $user ); $pass = escapeShellArg( $pass ); $query = escapeShellArg( $query ); $command = echo $query | mysql --html -h$host -u$user -p$pass $db; echo 'Command: '.$command.\n; $html = `$command`; echo $html.\n; ? Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for 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] php/mysql Query Question.
ad...@buskirkgraphics.com wrote: I tend to do this robert, while looking at your example i thought to myself since i am trying to mimick a shell command why not run one. Result: ? $db = 'db'; $host = 'host'; $user = 'user'; $pass = 'pass'; $query = select * from $db.my_table; $ddvery = shell_exec(mysql -u$user -p$pass --html --execute=$query); echo pre$ddvery/pre; ? Not are the results safe but the unlimited possibilites are amazing. Thanks so much for the kick starter This presumes your information is all safe and that there are no special shell characters in any of the configuration settings (now and in the future). Also, the shell_exec() function is identical to the backtick operator that I used in my example (see the help). You've essentially done what I did, but made it less robust... except for the use of the --execute parameter which I wasn't aware existed since it's just as easy to pipe :) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php/mysql Query Question.
ad...@buskirkgraphics.com wrote: Before most of you go on a rampage of how to please read below... As most of you already know when using MySQL from the shell you can write your queries in html format in an out file. Example: shellmysql -uyourmom -plovesme --html This now will return all results in an html format from all queries. Now I could “tee” this to a file and save the results returned if I so choose to save the result of the display . Let’s say I want to be lazy and write a php MySQL query to do the same so that any result I queried for would return the html results in a table without actually writing the table tags in the results. Is there a mysql_connect or select_db or mysql_query tag option to do that since mysql can display it from the shell? Here is my rendition of an result to HTML table output function. This is normally used within my db class but I have modified it to work with a MySQLi result object function debug($result) { /* get column metadata */ $html = 'table border=1tr'; foreach ( $result-fetch_fields() AS $val ) { $html .= 'th'.$val-name.'/th'; } $html .= '/tr'; foreach ( $result-fetch_row() AS $row ) { $html .= 'tr'; foreach ( $row AS $value ) { $html .= 'tdnbsp;'.$value.'/td'; } $html .= '/tr'; } $html .= '/table'; return $html; } Let us know if that works for you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php/mysql Query Question.
ad...@buskirkgraphics.com wrote: Before most of you go on a rampage of how to please read below... As most of you already know when using MySQL from the shell you can write your queries in html format in an out file. Example: shellmysql -uyourmom -plovesme --html This now will return all results in an html format from all queries. Now I could “tee” this to a file and save the results returned if I so choose to save the result of the display . Let’s say I want to be lazy and write a php MySQL query to do the same so that any result I queried for would return the html results in a table without actually writing the table tags in the results. Is there a mysql_connect or select_db or mysql_query tag option to do that since mysql can display it from the shell? echo Select * from my_table | mysql --html -ufoo -pfee database_name However, this allows for your database password to be visible in the process list for a brief moment of time. You might be better served by finer grained process control where you can check the output and provide input as needed. Or a simple expect script might suffice. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php/mysql Query Question.
ad...@buskirkgraphics.com wrote: Would you mind giving me an example of this that i can stick right into a blank php file and run. I get what you are saying but i cant seem to make that even echo out the data. php 5.2 mysql 5.1.3 Apache 2.2 ?php $db = 'db'; $host = 'host'; $user = 'user'; $pass = 'pass'; $query = select * from my_table; $db = escapeShellArg( $db ); $host = escapeShellArg( $host ); $user = escapeShellArg( $user ); $pass = escapeShellArg( $pass ); $query = escapeShellArg( $query ); $command = echo $query | mysql --html -h$host -u$user -p$pass $db; echo 'Command: '.$command.\n; $html = `$command`; echo $html.\n; ? Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP/mysql equivalent of PEAR's tableInfo()??
On Jul 13, 2009, at 10:03 AM, Govinda wrote: I have this code: $db_billing=mysqli_connect(localhost,metheuser,mypass,billing); if (mysqli_connect_error()) { die(Can't connect: . mysqli_connect_error()); } mysqli //$dbname = 'billing'; $sql = SHOW TABLES; $result = mysql_query($sql); // line 53 Now mysql, What are you doing? Yes. 3 lashing. Thanks. I am not likely to neglect again remembering that mysql and mysqli are different and have different syntax. unfortunately I am still in over my head enough to have to ask.. Here is what I have now: $db_billing=mysql_connect(localhost,metheuser,mypass,billing); if (!$db_billing) { die('Could not connect: ' . mysql_error()); } $sql = SHOW TABLES; $result = mysql_query($sql); foreach(mysql_fetch_assoc($result) as $k = $v) { //line 62 $ssql = DESCRIBE .mysql_real_escape_string($v); $rresult = mysql_query($ssql); echo b.$k./b:br /\n; echo pre\n; print_r(mysql_fetch_assoc($rresult)); echo /pre\n; echo br /\n; } giving this error: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/meee/public_html/somedir/test.php on line 62 I read about: -mysql_fetch_assoc -mysql_query -SHOW TABLES but do not see why this should be failing. Why isn't $result a ' valid MySQL result resource'? Better late then never! :) I played around with your code tonight and got this working on a test server: ?PHP $db_billing = mysql_connect($DBHOST, $DBUSER, $DBPASS) or die(Could not connect: .mysql_error()); $db_selected = mysql_select_db($DB, $db_billing); if(!$db_selected) { die(Can't use database: . mysql_error()); } if (!$db_billing) { die('Could not connect: ' . mysql_error()); } $sql = SHOW TABLES; $result = mysql_query($sql) or die(query failed: .mysql_error()); $resulttest = mysql_fetch_assoc($result); foreach($resulttest as $k = $v) { //line 62 $ssql = DESCRIBE .mysql_real_escape_string($v); $rresult = mysql_query($ssql); echo b.$k./b:br /\n; echo pre\n; print_r(mysql_fetch_assoc($rresult)); echo /pre\n; echo br /\n; } ? The only big difference from what you had is that I moved the mysql_fetch_assoc($result); into a separate line rather then running it from the foreach... Let me know if that helps. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP/mysql equivalent of PEAR's tableInfo()??
Better late then never! :) I played around with your code tonight and got this working on a test server: ?PHP $db_billing = mysql_connect($DBHOST, $DBUSER, $DBPASS) or die(Could not connect: .mysql_error()); $db_selected = mysql_select_db($DB, $db_billing); if(!$db_selected) { die(Can't use database: . mysql_error()); } if (!$db_billing) { die('Could not connect: ' . mysql_error()); } $sql = SHOW TABLES; $result = mysql_query($sql) or die(query failed: .mysql_error()); $resulttest = mysql_fetch_assoc($result); foreach($resulttest as $k = $v) { //line 62 $ssql = DESCRIBE .mysql_real_escape_string($v); $rresult = mysql_query($ssql); echo b.$k./b:br /\n; echo pre\n; print_r(mysql_fetch_assoc($rresult)); echo /pre\n; echo br /\n; } ? The only big difference from what you had is that I moved the mysql_fetch_assoc($result); into a separate line rather then running it from the foreach... Let me know if that helps. Thanks Jason :-) What you just offered just shows info about only the first column in the table. I got this working to show info about all the columns in the table: $ssql = DESCRIBE billing_table; $rresult = mysql_query($ssql); echo hr /pre\n; while ($row = mysql_fetch_assoc($rresult)) { print_r($row); //line 278 } echo /pre\n; echo hr /\n; -G
Re: [PHP] PHP/mysql equivalent of PEAR's tableInfo()??
I have this code: $db_billing=mysqli_connect(localhost,metheuser,mypass,billing); if (mysqli_connect_error()) { die(Can't connect: . mysqli_connect_error()); } mysqli //$dbname = 'billing'; $sql = SHOW TABLES; $result = mysql_query($sql); // line 53 Now mysql, What are you doing? Yes. 3 lashing. Thanks. I am not likely to neglect again remembering that mysql and mysqli are different and have different syntax. unfortunately I am still in over my head enough to have to ask.. Here is what I have now: $db_billing=mysql_connect(localhost,metheuser,mypass,billing); if (!$db_billing) { die('Could not connect: ' . mysql_error()); } $sql = SHOW TABLES; $result = mysql_query($sql); foreach(mysql_fetch_assoc($result) as $k = $v) { //line 62 $ssql = DESCRIBE .mysql_real_escape_string($v); $rresult = mysql_query($ssql); echo b.$k./b:br /\n; echo pre\n; print_r(mysql_fetch_assoc($rresult)); echo /pre\n; echo br /\n; } giving this error: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/meee/public_html/somedir/test.php on line 62 I read about: -mysql_fetch_assoc -mysql_query -SHOW TABLES but do not see why this should be failing. Why isn't $result a ' valid MySQL result resource'? -G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP/mysql equivalent of PEAR's tableInfo()??
On Sat, Jul 11, 2009 at 19:57, Govindagovinda.webdnat...@gmail.com wrote: I have been using PEAR's tableInfo() to remind myself about the columns in the table.. but now I want to see as much data as possible about the table and its contents *without* using PEAR. (I.e. just using built in stuff for mysqli.) This is not mysqli_#() directly, but just mocked up here in this email. Not guaranteed to work, but should give you the right idea at least. ;-P ?php include('inc/config.php'); // Your configuration include('inc/db.php'); // Your database connection info $sql = SHOW TABLES; $result = mysql_query($sql); foreach(mysql_fetch_assoc($result) as $k = $v) { $ssql = DESCRIBE .mysql_real_escape_string($v); $rresult = mysql_query($ssql); echo b.$k./b:br /\n; echo pre\n; print_r(mysql_fetch_assoc($rresult)); echo /pre\n; echo br /\n; } ? Dan I get roughly the idea, but alas I am stumped so easily in this new ocean.. it frustrates me. I have this code: $db_billing=mysqli_connect(localhost,metheuser,mypass,billing); if (mysqli_connect_error()) { die(Can't connect: . mysqli_connect_error()); } //$dbname = 'billing'; $sql = SHOW TABLES; $result = mysql_query($sql); // line 53 foreach(mysql_fetch_assoc($result) as $k = $v) { // line 55 $ssql = DESCRIBE .mysql_real_escape_string($v); $rresult = mysql_query($ssql); echo b.$k./b:br /\n; echo pre\n; print_r(mysql_fetch_assoc($rresult)); echo /pre\n; echo br /\n; } Which is just giving these errors: Warning: mysql_query() [function.mysql-query]: Access denied for user 'meee'@'localhost' (using password: NO) in /home/meee/public_html/ somedir/test.php on line 53 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/meee/public_html/somedir/test.php on line 53 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/meee/public_html/somedir/test.php on line 55 Warning: Invalid argument supplied for foreach() in /home/meee/ public_html/somedir/test.php on line 55 -- I am looking forward to when I have enough of my bearings that I can just cruise around all the various docs and figure out my own answers. Now there are just so many unknowns, I often can't tell which way to even look to solve the issues. -G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP/mysql equivalent of PEAR's tableInfo()??
Top-posting. This would be an excellent question for Prune (CC'd) to field, based on the error message. Prune? On Sun, Jul 12, 2009 at 17:49, Govindagovinda.webdnat...@gmail.com wrote: On Sat, Jul 11, 2009 at 19:57, Govindagovinda.webdnat...@gmail.com wrote: I have been using PEAR's tableInfo() to remind myself about the columns in the table.. but now I want to see as much data as possible about the table and its contents *without* using PEAR. (I.e. just using built in stuff for mysqli.) This is not mysqli_#() directly, but just mocked up here in this email. Not guaranteed to work, but should give you the right idea at least. ;-P ?php include('inc/config.php'); // Your configuration include('inc/db.php'); // Your database connection info $sql = SHOW TABLES; $result = mysql_query($sql); foreach(mysql_fetch_assoc($result) as $k = $v) { $ssql = DESCRIBE .mysql_real_escape_string($v); $rresult = mysql_query($ssql); echo b.$k./b:br /\n; echo pre\n; print_r(mysql_fetch_assoc($rresult)); echo /pre\n; echo br /\n; } ? Dan I get roughly the idea, but alas I am stumped so easily in this new ocean.. it frustrates me. I have this code: $db_billing=mysqli_connect(localhost,metheuser,mypass,billing); if (mysqli_connect_error()) { die(Can't connect: . mysqli_connect_error()); } //$dbname = 'billing'; $sql = SHOW TABLES; $result = mysql_query($sql); // line 53 foreach(mysql_fetch_assoc($result) as $k = $v) { // line 55 $ssql = DESCRIBE .mysql_real_escape_string($v); $rresult = mysql_query($ssql); echo b.$k./b:br /\n; echo pre\n; print_r(mysql_fetch_assoc($rresult)); echo /pre\n; echo br /\n; } Which is just giving these errors: Warning: mysql_query() [function.mysql-query]: Access denied for user 'meee'@'localhost' (using password: NO) in /home/meee/public_html/somedir/test.php on line 53 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/meee/public_html/somedir/test.php on line 53 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/meee/public_html/somedir/test.php on line 55 Warning: Invalid argument supplied for foreach() in /home/meee/public_html/somedir/test.php on line 55 -- I am looking forward to when I have enough of my bearings that I can just cruise around all the various docs and figure out my own answers. Now there are just so many unknowns, I often can't tell which way to even look to solve the issues. -G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Check out our great hosting and dedicated server deals at http://twitter.com/pilotpig -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP/mysql equivalent of PEAR's tableInfo()??
On Mon, Jul 13, 2009 at 3:19 AM, Govinda govinda.webdnat...@gmail.comwrote: On Sat, Jul 11, 2009 at 19:57, Govindagovinda.webdnat...@gmail.com wrote: I have been using PEAR's tableInfo() to remind myself about the columns in the table.. but now I want to see as much data as possible about the table and its contents *without* using PEAR. (I.e. just using built in stuff for mysqli.) This is not mysqli_#() directly, but just mocked up here in this email. Not guaranteed to work, but should give you the right idea at least. ;-P ?php include('inc/config.php'); // Your configuration include('inc/db.php'); // Your database connection info $sql = SHOW TABLES; $result = mysql_query($sql); foreach(mysql_fetch_assoc($result) as $k = $v) { $ssql = DESCRIBE .mysql_real_escape_string($v); $rresult = mysql_query($ssql); echo b.$k./b:br /\n; echo pre\n; print_r(mysql_fetch_assoc($rresult)); echo /pre\n; echo br /\n; } ? Dan I get roughly the idea, but alas I am stumped so easily in this new ocean.. it frustrates me. I have this code: $db_billing=mysqli_connect(localhost,metheuser,mypass,billing); if (mysqli_connect_error()) { die(Can't connect: . mysqli_connect_error()); } mysqli //$dbname = 'billing'; $sql = SHOW TABLES; $result = mysql_query($sql); // line 53 Now mysql, What are you doing? foreach(mysql_fetch_assoc($result) as $k = $v) { // line 55 $ssql = DESCRIBE .mysql_real_escape_string($v); $rresult = mysql_query($ssql); echo b.$k./b:br /\n; echo pre\n; print_r(mysql_fetch_assoc($rresult)); echo /pre\n; echo br /\n; } Which is just giving these errors: Warning: mysql_query() [function.mysql-query]: Access denied for user 'meee'@'localhost' (using password: NO) in /home/meee/public_html/somedir/test.php on line 53 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/meee/public_html/somedir/test.php on line 53 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/meee/public_html/somedir/test.php on line 55 Warning: Invalid argument supplied for foreach() in /home/meee/public_html/somedir/test.php on line 55 -- I am looking forward to when I have enough of my bearings that I can just cruise around all the various docs and figure out my own answers. Now there are just so many unknowns, I often can't tell which way to even look to solve the issues. -G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Zareef Ahmed :: A PHP Developer in India ( Delhi ) Homepage :: http://www.zareef.net
Re: [PHP] PHP/mysql equivalent of PEAR's tableInfo()??
On Sat, Jul 11, 2009 at 19:57, Govindagovinda.webdnat...@gmail.com wrote: I have been using PEAR's tableInfo() to remind myself about the columns in the table.. but now I want to see as much data as possible about the table and its contents *without* using PEAR. (I.e. just using built in stuff for mysqli.) This is not mysqli_#() directly, but just mocked up here in this email. Not guaranteed to work, but should give you the right idea at least. ;-P ?php include('inc/config.php'); // Your configuration include('inc/db.php'); // Your database connection info $sql = SHOW TABLES; $result = mysql_query($sql); foreach(mysql_fetch_assoc($result) as $k = $v) { $ssql = DESCRIBE .mysql_real_escape_string($v); $rresult = mysql_query($ssql); echo b.$k./b:br /\n; echo pre\n; print_r(mysql_fetch_assoc($rresult)); echo /pre\n; echo br /\n; } ? -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Check out our great hosting and dedicated server deals at http://twitter.com/pilotpig -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP MySQL 500 Internal Error
On Thu, 2009-06-18 at 22:10 -0400, Shawn Simmons wrote: Wrote a small script to connect to the MySql database. Tried to run the script (http://localhost/dbscript.php) and I get a 500 Internal Server error. I have been up and down the web for two days looking for a solution and I am completely frustrated. I HAVE to be missing something. PLEASE PLEASE PLEASE help. Thanks. Check permissions and ownership on the file. That often happens when the permissions are set to 0777 as opposed to 755 (in *nix speak), so check that the webserver user has read and execute access on the file and that it ownds the directory etc -- Paul http://www.paulscott.za.net http://twitter.com/paulscott56 http://avoir.uwc.ac.za -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP MySQL 500 Internal Error
Check the mysql user permissions, then check the root directory permissions, if you use some .htacess file, check this to. This error occurs when you have, permissions errors, server is not working well, .htacess errors and other things, try acess your script to with http://127.0.0.1 Yuri Yarlei. Programmer PHP, CSS, Java, PostregreSQL; Today PHP, tomorrow Java, after the world. Kyou wa PHP, ashita wa Java, sono ato sekai desu. To: php-general@lists.php.net From: elcid...@gmail.com Date: Thu, 18 Jun 2009 22:10:44 -0400 Subject: [PHP] PHP MySQL 500 Internal Error Greetings Gurus! I am attempting to use PHP+MYSQL+APACHE and I have downloaded all the latest verions and installed them on a fresh windows XP install. Got the Apache server up and running, got MySQL up and running and installed PHP. Tested PHP with a script containing phpinfo(). Everything works great. Wrote a small script to connect to the MySql database. Tried to run the script (http://localhost/dbscript.php) and I get a 500 Internal Server error. I have been up and down the web for two days looking for a solution and I am completely frustrated. I HAVE to be missing something. PLEASE PLEASE PLEASE help. Thanks. MySql is enabled in php.ini. Paths are set to the php folder. I have NOT moved or copied any files whatsoever. Apache version is 2.2. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ Deixe suas conversas mais divertidas. Baixe agora mesmo novos emoticons. É grátis! http://specials.br.msn.com/ilovemessenger/pacotes.aspx
Re: [PHP] PHP MySQL 500 Internal Error
On Thu, Jun 18, 2009 at 22:10, Shawn Simmonselcid...@gmail.com wrote: Greetings Gurus! Also, please keep new threads on the list limited to one at a time, except in extenuating circumstances. And as a developer, there certainly are and will be more of those circumstances. ;-P -- /Daniel P. Brown 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] PHP MySQL 500 Internal Error
Sorry about thatI wasn't sure if it went the first time when I didn't see the post sfter a refresh8-) Daniel Brown danbr...@php.net wrote in message news:ab5568160906190558u1a585cedpf73eb5690330d...@mail.gmail.com... On Thu, Jun 18, 2009 at 22:10, Shawn Simmonselcid...@gmail.com wrote: Greetings Gurus! Also, please keep new threads on the list limited to one at a time, except in extenuating circumstances. And as a developer, there certainly are and will be more of those circumstances. ;-P -- /Daniel P. Brown 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] PHP/MYSQL/ Encrypting Sensetive information
At 10:00 AM -0400 4/17/09, Russell Jones wrote: We are looking at a project where we will potentially need to store sensetive information in a few fields of a MySQL table. Any recommendations on where to look for best practices in doing this? for encrypting the data, etc.? We will need to be able to decrypt the data as well, although this can probably be done locally, so hashing alone is not really an option. Russell Jones Try the manual: http://www.php.net/crypt Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP/MYSQL/ Encrypting Sensetive information
If its by a user-basis, something that can be a bit risky but possible - You can encrypt it, password is hashed on database, and the key to the other data is the un-encrypted password.. On Fri, Apr 17, 2009 at 5:00 PM, Russell Jones rjon...@gmail.com wrote: We are looking at a project where we will potentially need to store sensetive information in a few fields of a MySQL table. Any recommendations on where to look for best practices in doing this? for encrypting the data, etc.? We will need to be able to decrypt the data as well, although this can probably be done locally, so hashing alone is not really an option. Russell Jones -- Use ROT26 for best security
Re: [PHP] PHP/MYSQL/ Encrypting Sensetive information
MySQLs own Function AES_(EN|DE)CRYPT is pretty cool for this case. -- Stefan Langwald 2009/4/17 דניאל דנון danondan...@gmail.com: If its by a user-basis, something that can be a bit risky but possible - You can encrypt it, password is hashed on database, and the key to the other data is the un-encrypted password.. On Fri, Apr 17, 2009 at 5:00 PM, Russell Jones rjon...@gmail.com wrote: We are looking at a project where we will potentially need to store sensetive information in a few fields of a MySQL table. Any recommendations on where to look for best practices in doing this? for encrypting the data, etc.? We will need to be able to decrypt the data as well, although this can probably be done locally, so hashing alone is not really an option. Russell Jones -- Use ROT26 for best security -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP/MYSQL/ Encrypting Sensetive information
On Fri, Apr 17, 2009 at 10:15 AM, דניאל דנון danondan...@gmail.com wrote: If its by a user-basis, something that can be a bit risky but possible - You can encrypt it, password is hashed on database, and the key to the other data is the un-encrypted password.. On Fri, Apr 17, 2009 at 5:00 PM, Russell Jones rjon...@gmail.com wrote: We are looking at a project where we will potentially need to store sensetive information in a few fields of a MySQL table. Any recommendations on where to look for best practices in doing this? for encrypting the data, etc.? We will need to be able to decrypt the data as well, although this can probably be done locally, so hashing alone is not really an option. Russell Jones -- Use ROT26 for best security I do similiar stuff here and the approach is: 1. provded a salted hashed value for searching (if this is not required, you don't need this) 2. encrypt using the mcrypt functions (using the rijndael algorithm), we add a salt and ecnrypt each record with its record number as the key. (the advantage is that there is no common key for all records, just gonna make a hackers life tougher) Personally, I would prefer to situate all encrypted records in their own table with a structure like: record_id int auto number main_record_id (whatever your system has as a main record) field_namevarchar(32) enc_value varchar(255) you could also add some tracking [last_access_time] int (unix timestamp) [last_access_id] varchar(32) if you want to store the data with the record -- Bastien Cat, the other other white meat
Re: [PHP] PHP/MYSQL/ Encrypting Sensetive information
On Apr 17, 2009, at 10:17 AM, Stefan Langwald wrote: MySQLs own Function AES_(EN|DE)CRYPT is pretty cool for this case. -- Stefan Langwald We use MySQL's AES_(EN|DE)CRYPT. It's fast, easy to use and uses 128 bit encryption (optionally 256). http://dev.mysql.com/doc/refman/5.1/en/encryption-functions.html ~Philip 2009/4/17 דניאל דנון danondan...@gmail.com: If its by a user-basis, something that can be a bit risky but possible - You can encrypt it, password is hashed on database, and the key to the other data is the un-encrypted password.. On Fri, Apr 17, 2009 at 5:00 PM, Russell Jones rjon...@gmail.com wrote: We are looking at a project where we will potentially need to store sensetive information in a few fields of a MySQL table. Any recommendations on where to look for best practices in doing this? for encrypting the data, etc.? We will need to be able to decrypt the data as well, although this can probably be done locally, so hashing alone is not really an option. Russell Jones -- Use ROT26 for best security -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP-MYSQL Question
This isn't PHP but mysql question. You didn't mention that the table itslef is created or not. If not, then it is probably a mysql error, maybe your installation of mysql doesn't support INNODB. SanTa - Original Message - From: abdulazeez alugo defati...@hotmail.com To: php-general@lists.php.net Sent: Tuesday, April 07, 2009 3:05 PM Subject: [PHP] PHP-MYSQL Question Hi guys, Please can anyone tell me what I'm doing wrong with the code below? It keep returning unsuccessful. $result=mysql_query(CREATE TABLE table2(table2_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, table1_id INT NOT NULL, name VARCHAR(100) NOT NULL, school VARCHAR(100) NOT NULL, comment TEXT NOT NULL, entrydate TIMESTAMP NOT NULL, FOREIGN KEY(table1_id) REFERENCES table1(table1_id)) ENGINE = INNODB ); if($result){ printSuccessful;} else {print Unsuccessful;} Thanks in advance. Cheers. Alugo Abdulazeez. _ Drag n’ drop—Get easy photo sharing with Windows Live™ Photos. http://www.microsoft.com/windows/windowslive/products/photos.aspx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP-MYSQL Question
abdulazeez alugo wrote: Hi guys, Please can anyone tell me what I'm doing wrong with the code below? It keep returning unsuccessful. Why don't you print out mysql_error() ? It'll tell you right away. /Per -- Per Jessen, Zürich (20.1°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP-MYSQL Question
From: p...@computer.org Date: Tue, 7 Apr 2009 15:18:35 +0200 To: php-general@lists.php.net Subject: Re: [PHP] PHP-MYSQL Question abdulazeez alugo wrote: Hi guys, Please can anyone tell me what I'm doing wrong with the code below? It keep returning unsuccessful. Why don't you print out mysql_error() ? It'll tell you right away. /Per Thanks Per, I should have thought of that. Now I owe you a beer. Cheers. _ More than messages–check out the rest of the Windows Live™. http://www.microsoft.com/windows/windowslive/
Re: [PHP] PHP/MySQL ISP recommendation that lets one edit ft_min_word_len variable?
Rob Gould wrote: Can anyone here recommend an ISP that will let me have a dedicated server (not shared), and also allow me to adjust the ft_min_word_len mySQL parameter? I was originally thinking Dreamhost PS, but I recently found out that they do not allow changes to mySQL environmental variables. I really need to adjust ft_min_word_len so that I can do rapid text searches on words less than 4 chars. http://www.linode.com/ You get root on your very own xen vm running the Linux distro of your choice (you can even upload an image if they don't have your favorite) - starting at I think around $20 a month for one IP. You can set it up however you want. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP/MySQL ISP recommendation that lets one edit ft_min_word_len variable?
Hi, Can anyone here recommend an ISP that will let me have a dedicated server (not shared), and also allow me to adjust the ft_min_word_len mySQL parameter? I was originally thinking Dreamhost PS, but I recently found out that they do not allow changes to mySQL environmental variables. I really need to adjust ft_min_word_len so that I can do rapid text searches on words less than 4 chars. Dan the man on this very mailing list. Or Rackspace. -- Richard Heyes HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari: http://www.rgraph.net (Updated March 28th) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP + MySQL - Load last inserts
Sebastian Muszytowski wrote: Hello :) I have some troubles with php and mysql. I have a normal MySQL Query and this returns X 3 rows. Now i want to get the last 3 inserted values. For Example i've inserted A, B, C, D, E I want to get the last inserted values, e.g. E D C (in reversed order) So how to do this? I already searched the web and the whole php.net site but i don't see any workaround. Thanks in advance Sebastian It's not really a PHP question. But here goes : SELECT column FROM `table` ORDER BY column DESC LIMIT 3 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP + MySQL - Load last inserts
I have some troubles with php and mysql. I have a normal MySQL Query and this returns X 3 rows. Now i want to get the last 3 inserted values. For Example i've inserted A, B, C, D, E I want to get the last inserted values, e.g. E D C (in reversed order) So how to do this? I already searched the web and the whole php.net site but i don't see any workaround. I guess you have a numeric primary key with auto_increment activated. Then just order your select by that primary key in descending order and limit the output to 3. For instance: SELECT * FROM table ORDER BY primary_key DESC LIMIT 0, 3; Greetins from Germany Marc -- Sync and share your files over the web for free http://bithub.net My Twitter feed http://www.twitter.com/MarcSteinert -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP + MySQL - Load last inserts
Thijs Lensselink schrieb: Sebastian Muszytowski wrote: Hello :) I have some troubles with php and mysql. I have a normal MySQL Query and this returns X 3 rows. Now i want to get the last 3 inserted values. For Example i've inserted A, B, C, D, E I want to get the last inserted values, e.g. E D C (in reversed order) So how to do this? I already searched the web and the whole php.net site but i don't see any workaround. Thanks in advance Sebastian It's not really a PHP question. But here goes : SELECT column FROM `table` ORDER BY column DESC LIMIT 3 Oh okay thank you very much :) I thought I must do this with php and some sort of mysql_fetch_asssoc or something like this -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP + MySQL - Load last inserts
On Mon, Mar 30, 2009 at 7:55 AM, Sebastian Muszytowski s.muszytow...@googlemail.com wrote: Thijs Lensselink schrieb: Sebastian Muszytowski wrote: Hello :) I have some troubles with php and mysql. I have a normal MySQL Query and this returns X 3 rows. Now i want to get the last 3 inserted values. For Example i've inserted A, B, C, D, E I want to get the last inserted values, e.g. E D C (in reversed order) So how to do this? I already searched the web and the whole php.net site but i don't see any workaround. Thanks in advance Sebastian It's not really a PHP question. But here goes : SELECT column FROM `table` ORDER BY column DESC LIMIT 3 Oh okay thank you very much :) I thought I must do this with php and some sort of mysql_fetch_asssoc or something like this Except when your primary key value rolls over, or fills a gap between two other rows that was left when a row was deleted/moved/etc... there has got to be a better way than grabbing rows in descending order based on the auto_increment value. Are you doing the inserts one at a time? If so, why not just use code to remember what you put in the DB? -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP + MySQL - Load last inserts
haliphax schrieb: [..cut...] Except when your primary key value rolls over, or fills a gap between two other rows that was left when a row was deleted/moved/etc... there has got to be a better way than grabbing rows in descending order based on the auto_increment value. Are you doing the inserts one at a time? If so, why not just use code to remember what you put in the DB? I do the inserts one at a time, i could use code to remember but i think it would be very slow when i have too much users. The second thing that aware me from doing this is, why use/build ressources when you could use others? i think why should i use and add another system? I work with mysql already and when php+mysql have the function i need it's better and i don't waste ressources :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP + MySQL - Load last inserts
Date: Mon, 30 Mar 2009 14:55:08 +0200 From: s.muszytow...@googlemail.com To: p...@addmissions.nl CC: php-general@lists.php.net Subject: Re: [PHP] PHP + MySQL - Load last inserts Thijs Lensselink schrieb: Sebastian Muszytowski wrote: Hello :) I have some troubles with php and mysql. I have a normal MySQL Query and this returns X 3 rows. Now i want to get the last 3 inserted values. For Example i've inserted A, B, C, D, E I want to get the last inserted values, e.g. E D C (in reversed order) So how to do this? I already searched the web and the whole php.net site but i don't see any workaround. Thanks in advance Sebastian It's not really a PHP question. But here goes : SELECT column FROM `table` ORDER BY column DESC LIMIT 3 Oh okay thank you very much :) I thought I must do this with php and some sort of mysql_fetch_asssoc or something like this Hey Dude, I'm sure you don't wanna complicate issues for yourself. You've been given two correct ways to go about it. I think you should try those. Ciao. _ Drag n’ drop—Get easy photo sharing with Windows Live™ Photos. http://www.microsoft.com/windows/windowslive/products/photos.aspx
Re: [PHP] PHP + MySQL - Load last inserts
On Mon, Mar 30, 2009 at 9:13 AM, Sebastian Muszytowski s.muszytow...@googlemail.com wrote: haliphax schrieb: [..cut...] Except when your primary key value rolls over, or fills a gap between two other rows that was left when a row was deleted/moved/etc... there has got to be a better way than grabbing rows in descending order based on the auto_increment value. Are you doing the inserts one at a time? If so, why not just use code to remember what you put in the DB? I do the inserts one at a time, i could use code to remember but i think it would be very slow when i have too much users. The second thing that aware me from doing this is, why use/build ressources when you could use others? i think why should i use and add another system? I work with mysql already and when php+mysql have the function i need it's better and i don't waste ressources :) Insert 100 records. Delete 50 of them at random. Now do your grab the last few records and sort them in descending order trick and see where it gets you. Not trying to be rude, it just doesn't seem like you read any of what I wrote in my last message. Also--if you're already doing the inserts one at a time, you're not going to lose any noticeable speed by tracking the last 5 inserted rows or so. You are not working with an embedded system--this is a high-level programming language. Why is everybody always so concerned about adding two or three lines of code like it's going to slow their system to a crawl? Unless you're messing with file IO, chewing up gigantic amounts of RAM, or performing cryptography/compression, you don't need to be quite so frugal with your methods. I'm not saying you should be sloppy--just that you shouldn't completely disregard an option because it adds 1 term (NOT magnitude) to your project's Big-O Notation measure. My 2c. Go with ORDER BY asdf_id DESC if it suits your fancy. -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP + MySQL - Load last inserts
haliphax wrote: On Mon, Mar 30, 2009 at 9:13 AM, Sebastian Muszytowski s.muszytow...@googlemail.com wrote: haliphax schrieb: [..cut...] Except when your primary key value rolls over, or fills a gap between two other rows that was left when a row was deleted/moved/etc... there has got to be a better way than grabbing rows in descending order based on the auto_increment value. Are you doing the inserts one at a time? If so, why not just use code to remember what you put in the DB? I do the inserts one at a time, i could use code to remember but i think it would be very slow when i have too much users. The second thing that aware me from doing this is, why use/build ressources when you could use others? i think why should i use and add another system? I work with mysql already and when php+mysql have the function i need it's better and i don't waste ressources :) Insert 100 records. Delete 50 of them at random. Now do your grab the last few records and sort them in descending order trick and see where it gets you. Mysql does not re-use id's (nor does any other db as far as I'm aware, and nor should it). I don't know where you got that idea from. mysql create table test (id int auto_increment not null primary key, name text); Query OK, 0 rows affected (0.12 sec) mysql insert into test(name) values ('one'),('two'),('three'),('four'),('five'),('six'),('seven'),('eight'),('nine'),('ten'); Query OK, 10 rows affected (0.00 sec) Records: 10 Duplicates: 0 Warnings: 0 mysql select * from test; ++---+ | id | name | ++---+ | 1 | one | | 2 | two | | 3 | three | | 4 | four | | 5 | five | | 6 | six | | 7 | seven | | 8 | eight | | 9 | nine | | 10 | ten | ++---+ 10 rows in set (0.00 sec) mysql delete from test where id in (1,3,7); Query OK, 3 rows affected (0.00 sec) mysql insert into test(name) values('eleven'); Query OK, 1 row affected (0.00 sec) mysql select * from test; +++ | id | name | +++ | 2 | two| | 4 | four | | 5 | five | | 6 | six| | 11 | eleven | | 8 | eight | | 9 | nine | | 10 | ten| +++ 8 rows in set (0.00 sec) The physical order of the rows changed (as you can see) but it does not re-use the id's that were deleted. Ordering by the id will get you the last bunch inserted. If you're using innodb you'll have to be aware it's transaction specific, if you're using myisam it will be system wide. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP + MySQL - Load last inserts
On Mon, Mar 30, 2009 at 5:10 PM, Chris dmag...@gmail.com wrote: haliphax wrote: On Mon, Mar 30, 2009 at 9:13 AM, Sebastian Muszytowski s.muszytow...@googlemail.com wrote: haliphax schrieb: [..cut...] Except when your primary key value rolls over, or fills a gap between two other rows that was left when a row was deleted/moved/etc... there has got to be a better way than grabbing rows in descending order based on the auto_increment value. Are you doing the inserts one at a time? If so, why not just use code to remember what you put in the DB? I do the inserts one at a time, i could use code to remember but i think it would be very slow when i have too much users. The second thing that aware me from doing this is, why use/build ressources when you could use others? i think why should i use and add another system? I work with mysql already and when php+mysql have the function i need it's better and i don't waste ressources :) Insert 100 records. Delete 50 of them at random. Now do your grab the last few records and sort them in descending order trick and see where it gets you. Mysql does not re-use id's (nor does any other db as far as I'm aware, and nor should it). I don't know where you got that idea from. mysql create table test (id int auto_increment not null primary key, name text); Query OK, 0 rows affected (0.12 sec) mysql insert into test(name) values ('one'),('two'),('three'),('four'),('five'),('six'),('seven'),('eight'),('nine'),('ten'); Query OK, 10 rows affected (0.00 sec) Records: 10 Duplicates: 0 Warnings: 0 mysql select * from test; ++---+ | id | name | ++---+ | 1 | one | | 2 | two | | 3 | three | | 4 | four | | 5 | five | | 6 | six | | 7 | seven | | 8 | eight | | 9 | nine | | 10 | ten | ++---+ 10 rows in set (0.00 sec) mysql delete from test where id in (1,3,7); Query OK, 3 rows affected (0.00 sec) mysql insert into test(name) values('eleven'); Query OK, 1 row affected (0.00 sec) mysql select * from test; +++ | id | name | +++ | 2 | two | | 4 | four | | 5 | five | | 6 | six | | 11 | eleven | | 8 | eight | | 9 | nine | | 10 | ten | +++ 8 rows in set (0.00 sec) The physical order of the rows changed (as you can see) but it does not re-use the id's that were deleted. Ordering by the id will get you the last bunch inserted. If you're using innodb you'll have to be aware it's transaction specific, if you're using myisam it will be system wide. I'll have to check my DBs then, because the exact situation I described happened to me a few years back when I was first getting into the DB scene. Regardless, I'm fairly certain the MSSQL box we have at work behaves this way. -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP + MySQL - Load last inserts
The physical order of the rows changed (as you can see) but it does not re-use the id's that were deleted. Ordering by the id will get you the last bunch inserted. If you're using innodb you'll have to be aware it's transaction specific, if you're using myisam it will be system wide. I'll have to check my DBs then, because the exact situation I described happened to me a few years back when I was first getting into the DB scene. Regardless, I'm fairly certain the MSSQL box we have at work behaves this way. Maybe it's a version thing, that test was done on mysql 5 (I'm sure it'll work on mysql 4.0/4.1 as well). No idea about ones before that. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] [PHP MySQL] Introduction to using relational databases
From: Dirk Thilo Klein wrote: Dear readers, I am new to relational DB but not to MySQL PHP in general. I created a RDB using Struggling with the program's complexity I managed to create a set of databases being interconnected via (foreign) keys. What I want to know is how to use this database via php. How does my ER-Diagram come into play? In other words I want to know more about a general approach to using relational databases via php. well you export the db you designed into ansi sql and use the cmdline mysql client to create a db with it... this guide http://www.databasejournal.com/features/mysql/article.php/1469211/Using -a-MySQL-database-with-PHP.htm seems ok on the first look.. Is there a Postgres translation of this or other DB articles available? Bob McConnell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [PHP MySQL] Introduction to using relational databases
Bob McConnell wrote: From: Dirk Thilo Klein wrote: Dear readers, I am new to relational DB but not to MySQL PHP in general. I created a RDB using Struggling with the program's complexity I managed to create a set of databases being interconnected via (foreign) keys. What I want to know is how to use this database via php. How does my ER-Diagram come into play? In other words I want to know more about a general approach to using relational databases via php. well you export the db you designed into ansi sql and use the cmdline mysql client to create a db with it... this guide http://www.databasejournal.com/features/mysql/article.php/1469211/Using -a-MySQL-database-with-PHP.htm seems ok on the first look.. Is there a Postgres translation of this or other DB articles available? Haven't read that article but I have a few intro's on my site: http://www.designmagick.com/category/4/PostgreSQL/Starting-Out -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [PHP MySQL] Introduction to using relational databases
Thilo Klein wrote: Dear readers, I am new to relational DB but not to MySQL PHP in general. I created a RDB using Struggling with the program's complexity I managed to create a set of databases being interconnected via (foreign) keys. What I want to know is how to use this database via php. How does my ER-Diagram come into play? In other words I want to know more about a general approach to using relational databases via php. Regards from .de Thilo PS: If you speak german, answer in german. Appreciate it. well you export the db you designed into ansi sql and use the cmdline mysql client to create a db with it... this guide http://www.databasejournal.com/features/mysql/article.php/1469211/Using-a-MySQL-database-with-PHP.htm seems ok on the first look.. from php you access the db like this... ?php $username = pee_wee; $password = let_me_in; $hostname = localhost; $dbh = mysql_connect($hostname, $username, $password) or die(Unable to connect to mysql); print connected to mysqlbr; $selected = mysql_select_db(first_test,$dbh) or die(Could not select first_test); if (mysql_query(insert into people values('5','Hazel','Burger'))) { print successfully inserted record; } else { print Failed to insert record; } mysql_close($dbh); ? Dirk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [PHP MySQL] Introduction to using relational databases
On Tue, Mar 10, 2009 at 05:44:31AM +0100, Thilo Klein wrote: Dear readers, I am new to relational DB but not to MySQL PHP in general. I created a RDB using Powerdesigner. Struggling with the program's complexity I managed to create a set of databases being interconnected via (foreign) keys. What I want to know is how to use this database via php. How does my ER-Diagram come into play? In other words I want to know more about a general approach to using relational databases via php. Assuming you want to use straight PHP (as opposed to an object-relational mapping framework), you have several choices. You can use the native PHP mysql functions to access the tables. Or you can use PHP's PDO classes (or similar). Both are documented at php.net (and very well, I might add). Your ER diagram is a visual representation of various CREATE TABLE statements in SQL. Using straight PHP, you'll need to learn to use the SQL language to make queries and changes to the tables. It is relatively simple to learn, but essential unless you want to use some odd framework, as I mentioned before. SQL queries would look something like this: $result = mysql_query(SELECT name, address FROM people WHERE country = 'Germany', $connection_info); Then, you would do something like: $person = mysql_fetch_array($result) And $person would look like this: $person = array('name' = 'Helmut Schmidt', 'address' = '123 Anystrasse'); I want to stress that PHP is *not* a *visual* language. You have to sit down with an editor and write it. Very unlike programs which allow you to design tables using visual means. Hope that helps. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [PHP MySQL] Introduction to using relational databases
Thilo Klein wrote: Dear readers, I am new to relational DB but not to MySQL PHP in general. I created a RDB using Powerdesigner. Struggling with the program's complexity I managed to create a set of databases being interconnected via (foreign) keys. What I want to know is how to use this database via php. How does my ER-Diagram come into play? In other words I want to know more about a general approach to using relational databases via php. Regards from .de Thilo PS: If you speak german, answer in german. Appreciate it. The ER-Diagram can be printed and rolled up to a nice weapon for smacking your co-workers with so they learn the layout faster... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Php mysql update
Hello, you have to do : $dwsl = mysql_query('UPDATE database SET Field=Field+1 WHERE Criteria=\'Criteria\''); From: ad...@buskirkgraphics.com To: php-general@lists.php.net Date: Mon, 29 Dec 2008 12:05:37 -0500 Subject: [PHP] Php mysql update Okay maybe i have just forgot. I am trying to update the database and do a +1 to a int field without pulling the data and adding 1 to it and sticking it back in. Someone refresh me on this please. I think it is something like. $dwsl = mysql_query(UPDATE database set Field='+1' WHERE Criteria='Criteria'); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ Téléphonez gratuitement à tous vos proches avec Windows Live Messenger ! Téléchargez-le maintenant ! http://www.windowslive.fr/messenger/1.asp
Re: [PHP] Php mysql update
Wouldn't it be: mysql_query(UPDATE database set Field = Field+1 WHERE Criteria='Criteria'); Note: no '' around +1, = operator John Corry ad...@buskirkgraphics.com wrote: Okay maybe i have just forgot. I am trying to update the database and do a +1 to a int field without pulling the data and adding 1 to it and sticking it back in. Someone refresh me on this please. I think it is something like. $dwsl = mysql_query(UPDATE database set Field='+1' WHERE Criteria='Criteria'); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Php mysql update
Sorry about that it hit me right after i sent the email. Thank You so much for you reply Hello, you have to do : $dwsl = mysql_query('UPDATE database SET Field=Field+1 WHERE Criteria=\'Criteria\''); From: ad...@buskirkgraphics.com To: php-general@lists.php.net Date: Mon, 29 Dec 2008 12:05:37 -0500 Subject: [PHP] Php mysql update Okay maybe i have just forgot. I am trying to update the database and do a +1 to a int field without pulling the data and adding 1 to it and sticking it back in. Someone refresh me on this please. I think it is something like. $dwsl = mysql_query(UPDATE database set Field='+1' WHERE Criteria='Criteria'); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ Téléphonez gratuitement à tous vos proches avec Windows Live Messenger ! Téléchargez-le maintenant ! http://www.windowslive.fr/messenger/1.asp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP/mySQL question using ORDER BY with logic
On Fri, 2008-10-24 at 00:18 -0400, Rob Gould wrote: Question about mySQL and PHP, when using the mySQL ORDER BY method... Basically I've got data coming from the database where a wine producer-name is a word like: Château Bahans Haut-Brion or La Chapelle de La Mission Haut-Brion or Le Clarence de Haut-Brion but I need to ORDER BY using a varient of the string: 1) If it begins with Château, don't include Chateau in the string to order by. 2) If it begins with La, don't order by La, unless the first word is Chateau, and then go ahead and order by La. Example sort: Notice how the producer as-in comes before the parenthesis, but the ORDER BY actually occurs after a re-ordering of the producer-string, using the above rules. Red: Château Bahans Haut-Brion (Bahans Haut-Brion, Château ) Red: La Chapelle de La Mission Haut-Brion (Chapelle de La Mission Haut-Brion, La ) Red: Le Clarence de Haut-Brion (Clarence de Haut-Brion, Le ) Red: Château Haut-Brion (Haut-Brion, Château ) Red: Château La Mission Haut-Brion (La Mission Haut-Brion, Château ) Red: Domaine de La Passion Haut Brion (La Passion Haut Brion, Domaine de ) Red: Château La Tour Haut-Brion (La Tour Haut-Brion, Château ) Red: Château Larrivet-Haut-Brion (Larrivet-Haut-Brion, Château ) Red: Château Les Carmes Haut-Brion (Les Carmes Haut-Brion, Château ) That logic between mySQL and PHP, I'm just not sure how to accomplish? I think it might involve a mySQL alias-technique but I could be wrong. Right now, my PHP call to generate the search is this: $query = 'SELECT * FROM wine WHERE MATCH(producer, varietal, appellation, designation, region, vineyard, subregion, country, vintage) AGAINST ( ' . $searchstring . ') ORDER BY producer LIMIT 0,100'; Maybe there's a good way to do it with the table as is... but I'm doubtful. I would create a second field that contains a pre-processed version of the name that performs stripping to achieve what you want. This could be done by a PHP script when the data is inserted into the database, or if not possible like that, then a cron job could run once in a while, check for entries with this field empty and generate it. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP + MySQL transactions
See http://dev.mysql.com/doc/refman/5.0/en/savepoints.html The situation might not come up but it can't hurt to have it already built in just in case. This doesn't appear deal with *nested transactions.* It appears that it will use a single transaction and you can just save up to a certain point upon failure. As of this point, it's all or nothing b/c we are dealing with fairly crucial information. However, I will look into building savepoints into the class so that I'll have that option in the future. Sounds like a difference in semantics :P In my head they're the same thing - if the middle bit fails, it'll roll back. If it works, you continue doing whatever you're doing. If everything succeeds then you commit everything at once. If part of something fails, then you roll it all back. At least you're more protected in the situation I mentioned above where you'd get partial data saved. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP + MySQL transactions
On May 22, 2008, at 7:25 PM, Chris wrote: Philip Thompson wrote: Hi all. I'm currently working on a project that's in its beta stage. Due to time restraints, we were unable to build in transactions from the beginning. Well, we're getting to the point where we can now put in transactions. Basically, I'm curious to find out your opinion on the best way to accomplish this. Currently, my thoughts for doing this are: ?php function someFunctionThatNeedsTransactions () { $this-db-begin(); // Start transaction $this-db-query(SELECT...); // Run my queries here $this-db-query(UPDATE...); // Do some PHP logic here $this-db-query(SELECT...); // Run more queries $this-db-query(INSERT...); $this-db-commit(); // Commit transaction } ? If there was a failure in one of the queries, that would be caught in the database class ('db' instance) and ?php $this-rollback(); ? would be called. Note that all the tables are InnoDB and the above code/functionality works. Ideally, I would have liked to use stored procedures, but that decision was not mine. So are there any complications I'm potentially missing? I'd get your db class to handle nested transactions, so if you had something like this: $db-begin(); someFunctionThatNeedsTransactions(); ... .. oops, need to rollback. $db-rollback(); the bits between someFunction and the rollback will be committed (by the function) and can't be rolled back. See http://dev.mysql.com/doc/refman/5.0/en/savepoints.html The situation might not come up but it can't hurt to have it already built in just in case. This doesn't appear deal with *nested transactions.* It appears that it will use a single transaction and you can just save up to a certain point upon failure. As of this point, it's all or nothing b/c we are dealing with fairly crucial information. However, I will look into building savepoints into the class so that I'll have that option in the future. It seems like I've used savepoints or nested transactions in MSSQL in the past (in stored procedures). I hope MySQL will support nested transactions in future releases. So, am I taking the best approach (at this point) for dealing with transactions? I will basically have to evaluate every situation in the program where a failure would occur and put in a $db-rollback(); call? What about try/catch blocks? I'm not currently using them, but maybe it would be the best way to handle exceptions when dealing with multiple queries. If there's *any* query failure, explode! Thanks! ~Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP + MySQL transactions
Philip Thompson wrote: Hi all. I'm currently working on a project that's in its beta stage. Due to time restraints, we were unable to build in transactions from the beginning. Well, we're getting to the point where we can now put in transactions. Basically, I'm curious to find out your opinion on the best way to accomplish this. Currently, my thoughts for doing this are: ?php function someFunctionThatNeedsTransactions () { $this-db-begin(); // Start transaction $this-db-query(SELECT...); // Run my queries here $this-db-query(UPDATE...); // Do some PHP logic here $this-db-query(SELECT...); // Run more queries $this-db-query(INSERT...); $this-db-commit(); // Commit transaction } ? If there was a failure in one of the queries, that would be caught in the database class ('db' instance) and ?php $this-rollback(); ? would be called. Note that all the tables are InnoDB and the above code/functionality works. Ideally, I would have liked to use stored procedures, but that decision was not mine. So are there any complications I'm potentially missing? I'd get your db class to handle nested transactions, so if you had something like this: $db-begin(); someFunctionThatNeedsTransactions(); ... .. oops, need to rollback. $db-rollback(); the bits between someFunction and the rollback will be committed (by the function) and can't be rolled back. See http://dev.mysql.com/doc/refman/5.0/en/savepoints.html The situation might not come up but it can't hurt to have it already built in just in case. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] php mysql live feed
Nameless, I see someone mentioned the setTimeout(function, milliseconds) function for JavaScript. I would also like to point out that you can use setInterval(function, milliseconds) in order to have an event repeat at a set interval. For instance, let's say you had a page laid out like so: --- div id=blah Text here /div --- You would want to add a script somewhere that would begin the interval in order to update the div: --- script type=text/javascript function ajaxRequest() { // insert postback code here document.getElementById(blah).innerHTML = ajax.responseText; } var t = setInterval(ajaxRequest(), 5000); /script --- This assumes that your XmlHttpRequest object is named ajax. Assigning the interval to variable t ensures that you can clear the interval if you need to (via clearInterval(t);). I suppose innerText can be used instead of innerHTML, as well. I would recommend using innerHTML only if you will be populating the div with HTML code, however. Hope this helps, Todd Boyd Web Programmer -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 20, 2008 3:25 PM To: php-general@lists.php.net Subject: [PHP] php mysql live feed Okay before i pull more hair out... I am trying to use php to pull mysql data and refresh the mysql data every say 5 seconds for like a live display of the database without the screen reloading. I want the data to refresh but not the screen. Ajax seems to hate me because everything i have seen/read/tried is wrapped around ASP.NET or requires a user interaction to invoke the query. If you have example scripts or a good tutorial that actually works where you can open a php script and the data changes on the page as the database does and the screen does not refresh, and you don’t have to onclick, onfocus, or onblur kind of thing. I would be in your debt Frustrated Rick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] php mysql live feed
Todd I want to thank you. You sent me thinking in the right direction to resolving this issue. I now have successfully created a live Pika Card status GUI using PHP, MYSQL, AJAX. The key word in what you said was unique function. I was not thinking to write a function. I was looking for the quick solve (php MySQL loop or something stupid). Not only does this work flawless but it has surpassed all my expectations of the gui. Todd thank you again for your suggestions and you helped me allot. Nameless, I see someone mentioned the setTimeout(function, milliseconds) function for JavaScript. I would also like to point out that you can use setInterval(function, milliseconds) in order to have an event repeat at a set interval. For instance, let's say you had a page laid out like so: --- div id=blah Text here /div --- You would want to add a script somewhere that would begin the interval in order to update the div: --- script type=text/javascript function ajaxRequest() { // insert postback code here document.getElementById(blah).innerHTML = ajax.responseText; } var t = setInterval(ajaxRequest(), 5000); /script --- This assumes that your XmlHttpRequest object is named ajax. Assigning the interval to variable t ensures that you can clear the interval if you need to (via clearInterval(t);). I suppose innerText can be used instead of innerHTML, as well. I would recommend using innerHTML only if you will be populating the div with HTML code, however. Hope this helps, Todd Boyd Web Programmer -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 20, 2008 3:25 PM To: php-general@lists.php.net Subject: [PHP] php mysql live feed Okay before i pull more hair out... I am trying to use php to pull mysql data and refresh the mysql data every say 5 seconds for like a live display of the database without the screen reloading. I want the data to refresh but not the screen. Ajax seems to hate me because everything i have seen/read/tried is wrapped around ASP.NET or requires a user interaction to invoke the query. If you have example scripts or a good tutorial that actually works where you can open a php script and the data changes on the page as the database does and the screen does not refresh, and you don’t have to onclick, onfocus, or onblur kind of thing. I would be in your debt Frustrated Rick -- 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] php mysql live feed
Hi: The following could be taken from MySQL just as well: http://webbytedd.com/b/timed-php/ Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php mysql live feed
Check out jQuery. http://jquery.com On May 20, 2008, at 1:24 PM, [EMAIL PROTECTED] wrote: Okay before i pull more hair out... I am trying to use php to pull mysql data and refresh the mysql data every say 5 seconds for like a live display of the database without the screen reloading. I want the data to refresh but not the screen. Ajax seems to hate me because everything i have seen/read/tried is wrapped around ASP.NET or requires a user interaction to invoke the query. If you have example scripts or a good tutorial that actually works where you can open a php script and the data changes on the page as the database does and the screen does not refresh, and you don’t have to onclick, onfocus, or onblur kind of thing. I would be in your debt Frustrated Rick -- 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] php mysql live feed
[EMAIL PROTECTED] wrote: Okay before i pull more hair out... I am trying to use php to pull mysql data and refresh the mysql data every say 5 seconds for like a live display of the database without the screen reloading. I want the data to refresh but not the screen. Ajax seems to hate me because everything i have seen/read/tried is wrapped around ASP.NET or requires a user interaction to invoke the query. If you have example scripts or a good tutorial that actually works where you can open a php script and the data changes on the page as the database does and the screen does not refresh, and you don’t have to onclick, onfocus, or onblur kind of thing. I would be in your debt You can use setTimeout() to delay a call to a Jabbascript function. Remember that the second argument is milliseconds, and not seconds. Eg. setTimeout('alert(Hello)', 1000); -- Richard Heyes In Cambridge? Employ me http://www.phpguru.org/cv ++ | Access SSH with a Windows mapped drive | |http://www.phpguru.org/sftpdrive| ++ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP-MYSQL Error: Can't connect to MySQL socket. Can someonehelp me out please?
Ok. I apologize for the mix. When I'm mailing someone, I simply don't get Google into mind. :) Thanks, Rahul On Sun, May 11, 2008 at 12:53 AM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Sun, May 11, 2008 at 1:46 AM, Rahul P [EMAIL PROTECTED] wrote: Ok I removed mysql using yum remove mysql. But is there a special way to tell yum to install that version of mysql? ahh, this is where google comes in for sure. it looks like you could download an older rpm, like from mysql and use 'yum localinstall' or there is a way to search for older versions that are still in the yum repos. heres a quick link i found http://www.fedoraforum.org/forum/showthread.php?t=96684 -nathan -- Rahul Computer Engineering and Systems Division. Department of Electrical Engineering and Computer Science Robert R. McCormick School of Engineering Northwestern University 2145 Sheridan Road, Evanston,IL60208. Administrator: The En?gma Project Website: http://www.enigmaportal.com
Re: [PHP] PHP-MYSQL Error: Can't connect to MySQL socket. Can someonehelp me out please?
On Sun, May 11, 2008 at 1:59 AM, Rahul P [EMAIL PROTECTED] wrote: Ok. I apologize for the mix. When I'm mailing someone, I simply don't get Google into mind. :) no problem, if it were emerge id be much more capable of helping ;) -nathan
Re: [PHP] PHP-MYSQL Error: Can't connect to MySQL socket. Can someonehelp me out please?
Rahul P wrote: Ok I removed mysql using yum remove mysql. But is there a special way to tell yum to install that version of mysql? On Sun, May 11, 2008 at 12:44 AM, Rahul P [EMAIL PROTECTED] wrote: On Sun, May 11, 2008 at 12:42 AM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Sun, May 11, 2008 at 1:29 AM, Rahul P [EMAIL PROTECTED] wrote: Oh... This is the fourth time I'm doing that except that this time yum installed mysql6 instead of older versions... I don't see any way out other than reinstalling the OS itself... There are so many dependency failures I'm spending more time troubleshooting than actually coding something :) i dont even think mysql6 is any where near ready for real usage (tho could be wrong). can you see if you could put 5 or 5.1 on there instead? os reinstall sounds painful =/ -nathan -- Rahul Computer Engineering and Systems Division. Department of Electrical Engineering and Computer Science Robert R. McCormick School of Engineering Northwestern University 2145 Sheridan Road, Evanston,IL60208. Administrator: The En?gma Project Website: http://www.enigmaportal.com yum search mysql Find the one that looks like mysql5 or similar and use that. -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP-MYSQL Error: Can't connect to MySQL socket. Can someone help me out please?
On Sun, May 11, 2008 at 12:30 AM, Rahul [EMAIL PROTECTED] wrote: I am using Fedora Core 4. As I was unable to use PHP or MySQL together, I uninstalled both of them and installed again using the following commands: yum install mysql And then apt-get install php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc curl curl-devel perl-libwww-perl ImageMagick And then started the mysql server. I am able to connect to the server from the console my typing mysql -h hostname -u root -p mypass However, when I try to connect to mysql through PHP I get the following errors: PHP Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /export/home/rahul/may/sample.php on line 5 PHP Warning: mysql_query(): A link to the server could not be established in /export/home/rahul/may/sample.php on line 5 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) Can someone please help me out? what is the hostname you are typing at the command line and what is the one you are using when trying to connect from php? when using mysql, you will have to have a separate entry for localhost connections. -nathan
Re: [PHP] PHP-MYSQL Error: Can't connect to MySQL socket. Can someone help me out please?
Thanks a lot for your reply. I have tried using $host = localhost; $db = dbname; $table_main = tablename; $dbusername = root; $dbpass = passhere; mysql_connect($host, $dbusername, $dbpass) or die(mysql_error()); and $host = mycomputer.webaddress.com; $db = dbname; $table_main = tablename; $dbusername = root; $dbpass = passhere; mysql_connect($host, $dbusername, $dbpass) or die(mysql_error()); And this mycomputer.webaddress.com works when I use with mysql like this: mysql -h mycomputer.webaddress.com -u root -p Thank You Nathan Nobbe wrote: On Sun, May 11, 2008 at 12:30 AM, Rahul [EMAIL PROTECTED] wrote: I am using Fedora Core 4. As I was unable to use PHP or MySQL together, I uninstalled both of them and installed again using the following commands: yum install mysql And then apt-get install php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc curl curl-devel perl-libwww-perl ImageMagick And then started the mysql server. I am able to connect to the server from the console my typing mysql -h hostname -u root -p mypass However, when I try to connect to mysql through PHP I get the following errors: PHP Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /export/home/rahul/may/sample.php on line 5 PHP Warning: mysql_query(): A link to the server could not be established in /export/home/rahul/may/sample.php on line 5 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) Can someone please help me out? what is the hostname you are typing at the command line and what is the one you are using when trying to connect from php? when using mysql, you will have to have a separate entry for localhost connections. -nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP-MYSQL Error: Can't connect to MySQL socket. Can someone help me out please?
On Sun, May 11, 2008 at 12:42 AM, Rahul [EMAIL PROTECTED] wrote: Thanks a lot for your reply. I have tried using $host = localhost; $db = dbname; $table_main = tablename; $dbusername = root; $dbpass = passhere; mysql_connect($host, $dbusername, $dbpass) or die(mysql_error()); and $host = mycomputer.webaddress.com; $db = dbname; $table_main = tablename; $dbusername = root; $dbpass = passhere; mysql_connect($host, $dbusername, $dbpass) or die(mysql_error()); And this mycomputer.webaddress.com works when I use with mysql like this: mysql -h mycomputer.webaddress.com -u root -p so, from above (previous post), it looks like the errors youve shown are actually coming from mysql_query(). what is the result of this (using credentials from this post and [mycomputer.webaddress.com]) ?php if(!mysql_connect($host, $dusername, $dbpass)) { die(mysql_error()); } else { die('successful connection established'); } -nathan
Re: [PHP] PHP-MYSQL Error: Can't connect to MySQL socket. Can someonehelp me out please?
I have recorded both the errors by changing the variable: $host = mycomputer.webaddress.com PHP Warning: mysql_connect(): Lost connection to MySQL server during query in /export/home/rpo219/may/conf_global.php on line 18 Lost connection to MySQL server during query $host = localhost PHP Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111) in /export/home/rpo219/may/conf_global.php on line 18 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' I found something weird for the first time: I tried looking at the mysql6 data directory and it says the following: total 28 drwxr-xr-x 3 nfsnobody nfsnobody 4096 May 10 23:57 . drwxrwxrwx 21 root root 4096 May 7 14:35 .. -rw-rw 1 nfsnobody nfsnobody 1009 May 10 23:57 mycomputer.webaddress.com.err drwxr-xr-x 2 nfsnobody nfsnobody 4096 Jan 24 20:07 mysql And when I try to change the ownership of the directory to mysql by [EMAIL PROTECTED] chown mysql ./mysql6 chown: changing ownership of `./mysql6': Operation not permitted Just thought it might be related to the problem Thanks, Rahul Rahul wrote: Thanks a lot for your reply. I have tried using $host = localhost; $db = dbname; $table_main = tablename; $dbusername = root; $dbpass = passhere; mysql_connect($host, $dbusername, $dbpass) or die(mysql_error()); and $host = mycomputer.webaddress.com; $db = dbname; $table_main = tablename; $dbusername = root; $dbpass = passhere; mysql_connect($host, $dbusername, $dbpass) or die(mysql_error()); And this mycomputer.webaddress.com works when I use with mysql like this: mysql -h mycomputer.webaddress.com -u root -p Thank You Nathan Nobbe wrote: On Sun, May 11, 2008 at 12:30 AM, Rahul [EMAIL PROTECTED] wrote: I am using Fedora Core 4. As I was unable to use PHP or MySQL together, I uninstalled both of them and installed again using the following commands: yum install mysql And then apt-get install php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc curl curl-devel perl-libwww-perl ImageMagick And then started the mysql server. I am able to connect to the server from the console my typing mysql -h hostname -u root -p mypass However, when I try to connect to mysql through PHP I get the following errors: PHP Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /export/home/rahul/may/sample.php on line 5 PHP Warning: mysql_query(): A link to the server could not be established in /export/home/rahul/may/sample.php on line 5 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) Can someone please help me out? what is the hostname you are typing at the command line and what is the one you are using when trying to connect from php? when using mysql, you will have to have a separate entry for localhost connections. -nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP-MYSQL Error: Can't connect to MySQL socket. Can someonehelp me out please?
On Sun, May 11, 2008 at 1:05 AM, Rahul [EMAIL PROTECTED] wrote: I have recorded both the errors by changing the variable: $host = mycomputer.webaddress.com PHP Warning: mysql_connect(): Lost connection to MySQL server during query in /export/home/rpo219/may/conf_global.php on line 18 Lost connection to MySQL server during query i have seen this before, but i cant recall, specifically what the problem could be. i recommend google ;) $host = localhost PHP Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111) in /export/home/rpo219/may/conf_global.php on line 18 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' i believe this is because the user root, does not have permission to connect to the datbase from host 'localhost', especially since you said this didnt work from the command line either. you will have to add a grant clause to allow the root user to connect from the localhost. I found something weird for the first time: I tried looking at the mysql6 data directory and it says the following: total 28 drwxr-xr-x 3 nfsnobody nfsnobody 4096 May 10 23:57 . drwxrwxrwx 21 root root 4096 May 7 14:35 .. -rw-rw 1 nfsnobody nfsnobody 1009 May 10 23:57 mycomputer.webaddress.com.err drwxr-xr-x 2 nfsnobody nfsnobody 4096 Jan 24 20:07 mysql that is likely the way your distribution has designed the permission scheme for the mysql server. And when I try to change the ownership of the directory to mysql by [EMAIL PROTECTED] chown mysql ./mysql6 chown: changing ownership of `./mysql6': Operation not permitted this is probly because you dont have permission to make the change... you could do it via sudo, but i wouldnt recommend it. your distro has set it up this way on purpose. Just thought it might be related to the problem have you created any databases after installing mysql? you should create at least one, like test db or something, and its good practice to create a specific user to access the database through as well. instead of having php connect as root. thats like a hackers dream right there. -nathan
Re: [PHP] PHP-MYSQL Error: Can't connect to MySQL socket. Can someonehelp me out please?
Thanks. I just stopped mysql and when I try to start it again it throws another set of errors: chown: changing ownership of `/home-public/mysql6': Operation not permitted So I guess something is messed up completely. I wish I installed it better. Now the installing is messed up I guess with all sorts of bad files. I will try Google now... Thanks for the help... :) On Sun, May 11, 2008 at 12:17 AM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Sun, May 11, 2008 at 1:05 AM, Rahul [EMAIL PROTECTED] wrote: I have recorded both the errors by changing the variable: $host = mycomputer.webaddress.com PHP Warning: mysql_connect(): Lost connection to MySQL server during query in /export/home/rpo219/may/conf_global.php on line 18 Lost connection to MySQL server during query i have seen this before, but i cant recall, specifically what the problem could be. i recommend google ;) $host = localhost PHP Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111) in /export/home/rpo219/may/conf_global.php on line 18 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' i believe this is because the user root, does not have permission to connect to the datbase from host 'localhost', especially since you said this didnt work from the command line either. you will have to add a grant clause to allow the root user to connect from the localhost. I found something weird for the first time: I tried looking at the mysql6 data directory and it says the following: total 28 drwxr-xr-x 3 nfsnobody nfsnobody 4096 May 10 23:57 . drwxrwxrwx 21 root root 4096 May 7 14:35 .. -rw-rw 1 nfsnobody nfsnobody 1009 May 10 23:57 mycomputer.webaddress.com.err drwxr-xr-x 2 nfsnobody nfsnobody 4096 Jan 24 20:07 mysql that is likely the way your distribution has designed the permission scheme for the mysql server. And when I try to change the ownership of the directory to mysql by [EMAIL PROTECTED] chown mysql ./mysql6 chown: changing ownership of `./mysql6': Operation not permitted this is probly because you dont have permission to make the change... you could do it via sudo, but i wouldnt recommend it. your distro has set it up this way on purpose. Just thought it might be related to the problem have you created any databases after installing mysql? you should create at least one, like test db or something, and its good practice to create a specific user to access the database through as well. instead of having php connect as root. thats like a hackers dream right there. -nathan -- Rahul Computer Engineering and Systems Division. Department of Electrical Engineering and Computer Science Robert R. McCormick School of Engineering Northwestern University 2145 Sheridan Road, Evanston,IL60208. Administrator: The En?gma Project Website: http://www.enigmaportal.com
Re: [PHP] PHP-MYSQL Error: Can't connect to MySQL socket. Can someonehelp me out please?
On Sun, May 11, 2008 at 1:22 AM, Rahul P [EMAIL PROTECTED] wrote: Thanks. I just stopped mysql and when I try to start it again it throws another set of errors: chown: changing ownership of `/home-public/mysql6': Operation not permitted So I guess something is messed up completely. I wish I installed it better. Now the installing is messed up I guess with all sorts of bad files. I will try Google now... Thanks for the help... :) one benefit of package managers is that they let you uninstall and reinstall easily. are you using yum or apt-get ? in your first post you included both the commands.. anyway, id just uninstall and reinstall it; should take 10 minutes or so. -nathan
Re: [PHP] PHP-MYSQL Error: Can't connect to MySQL socket. Can someonehelp me out please?
Oh... This is the fourth time I'm doing that except that this time yum installed mysql6 instead of older versions... I don't see any way out other than reinstalling the OS itself... There are so many dependency failures I'm spending more time troubleshooting than actually coding something :) On Sun, May 11, 2008 at 12:27 AM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Sun, May 11, 2008 at 1:22 AM, Rahul P [EMAIL PROTECTED] wrote: Thanks. I just stopped mysql and when I try to start it again it throws another set of errors: chown: changing ownership of `/home-public/mysql6': Operation not permitted So I guess something is messed up completely. I wish I installed it better. Now the installing is messed up I guess with all sorts of bad files. I will try Google now... Thanks for the help... :) one benefit of package managers is that they let you uninstall and reinstall easily. are you using yum or apt-get ? in your first post you included both the commands.. anyway, id just uninstall and reinstall it; should take 10 minutes or so. -nathan -- Rahul Computer Engineering and Systems Division. Department of Electrical Engineering and Computer Science Robert R. McCormick School of Engineering Northwestern University 2145 Sheridan Road, Evanston,IL60208. Administrator: The En?gma Project Website: http://www.enigmaportal.com
Re: [PHP] PHP-MYSQL Error: Can't connect to MySQL socket. Can someonehelp me out please?
On Sun, May 11, 2008 at 1:29 AM, Rahul P [EMAIL PROTECTED] wrote: Oh... This is the fourth time I'm doing that except that this time yum installed mysql6 instead of older versions... I don't see any way out other than reinstalling the OS itself... There are so many dependency failures I'm spending more time troubleshooting than actually coding something :) i dont even think mysql6 is any where near ready for real usage (tho could be wrong). can you see if you could put 5 or 5.1 on there instead? os reinstall sounds painful =/ -nathan
Re: [PHP] PHP-MYSQL Error: Can't connect to MySQL socket. Can someonehelp me out please?
On Sun, May 11, 2008 at 12:42 AM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Sun, May 11, 2008 at 1:29 AM, Rahul P [EMAIL PROTECTED] wrote: Oh... This is the fourth time I'm doing that except that this time yum installed mysql6 instead of older versions... I don't see any way out other than reinstalling the OS itself... There are so many dependency failures I'm spending more time troubleshooting than actually coding something :) i dont even think mysql6 is any where near ready for real usage (tho could be wrong). can you see if you could put 5 or 5.1 on there instead? os reinstall sounds painful =/ -nathan -- Rahul Computer Engineering and Systems Division. Department of Electrical Engineering and Computer Science Robert R. McCormick School of Engineering Northwestern University 2145 Sheridan Road, Evanston,IL60208. Administrator: The En?gma Project Website: http://www.enigmaportal.com
Re: [PHP] PHP-MYSQL Error: Can't connect to MySQL socket. Can someonehelp me out please?
Ok I removed mysql using yum remove mysql. But is there a special way to tell yum to install that version of mysql? On Sun, May 11, 2008 at 12:44 AM, Rahul P [EMAIL PROTECTED] wrote: On Sun, May 11, 2008 at 12:42 AM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Sun, May 11, 2008 at 1:29 AM, Rahul P [EMAIL PROTECTED] wrote: Oh... This is the fourth time I'm doing that except that this time yum installed mysql6 instead of older versions... I don't see any way out other than reinstalling the OS itself... There are so many dependency failures I'm spending more time troubleshooting than actually coding something :) i dont even think mysql6 is any where near ready for real usage (tho could be wrong). can you see if you could put 5 or 5.1 on there instead? os reinstall sounds painful =/ -nathan -- Rahul Computer Engineering and Systems Division. Department of Electrical Engineering and Computer Science Robert R. McCormick School of Engineering Northwestern University 2145 Sheridan Road, Evanston,IL60208. Administrator: The En?gma Project Website: http://www.enigmaportal.com -- Rahul Computer Engineering and Systems Division. Department of Electrical Engineering and Computer Science Robert R. McCormick School of Engineering Northwestern University 2145 Sheridan Road, Evanston,IL60208. Administrator: The En?gma Project Website: http://www.enigmaportal.com
Re: [PHP] PHP-MYSQL Error: Can't connect to MySQL socket. Can someonehelp me out please?
On Sun, May 11, 2008 at 1:46 AM, Rahul P [EMAIL PROTECTED] wrote: Ok I removed mysql using yum remove mysql. But is there a special way to tell yum to install that version of mysql? ahh, this is where google comes in for sure. it looks like you could download an older rpm, like from mysql and use 'yum localinstall' or there is a way to search for older versions that are still in the yum repos. heres a quick link i found http://www.fedoraforum.org/forum/showthread.php?t=96684 -nathan
RE: [PHP] PHP MySQL Insert Syntax
Insert is for a new row Alter or Update is for an exsisting row /*I'm trying to insert values from an array into MySQL DB but the insert begins at the last record in the table and not at first record in the table. I have added the cellSuffixes column after I already populated 30 records in other columns*/ Code: foreach($list as $key=$value) { $query = INSERT INTO carriers (cellSuffixes) VALUES('$value'); mysql_query($query,$connex) or die(Query failed: . mysql_error($connex)); } echo done; mysql_close($connex); //I don't know what the sytax s/b to get the data to be inserted in the first row of the column. -- 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] PHP MySQL Insert Syntax
Thanks :-) [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Insert is for a new row Alter or Update is for an exsisting row /*I'm trying to insert values from an array into MySQL DB but the insert begins at the last record in the table and not at first record in the table. I have added the cellSuffixes column after I already populated 30 records in other columns*/ Code: foreach($list as $key=$value) { $query = INSERT INTO carriers (cellSuffixes) VALUES('$value'); mysql_query($query,$connex) or die(Query failed: . mysql_error($connex)); } echo done; mysql_close($connex); //I don't know what the sytax s/b to get the data to be inserted in the first row of the column. -- 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] PHP/mySQL dropping zeros after inserting number into record
On Sat, February 16, 2008 5:22 pm, Rob Gould wrote: I've got a PHP script that inserts 00012345678 into a record in a mySQL database (it's a barcode). Things work ok unless the number has preceding zeros, and then the zeros get cut off and all I get is 12345678. I have the mySQL database fieldtype set to bigint(14). If the maximum length a barcode can be is 14, is there a better fieldtype to use that will keep the zeros? (or some way for PHP to tell mySQL not to chop off the zeros?) I personally would have used char(14) for a barcode, since it's really a 14-character fixed-width thing. You could use formatting on the output to get the leading zeros: sprintf(%0,14d, $barcode); //or somesuch http://php.net/sprintf And comparisons within MySQL should type-juggle to int, and make things work out... So, really, the bigint(14) should be okay, once you format the output to look right -- 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/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] PHP/mySQL dropping zeros after inserting number into record
On Feb 16, 2008 6:22 PM, Rob Gould [EMAIL PROTECTED] wrote: I've got a PHP script that inserts 00012345678 into a record in a mySQL database (it's a barcode). Things work ok unless the number has preceding zeros, and then the zeros get cut off and all I get is 12345678. I have the mySQL database fieldtype set to bigint(14). If the maximum length a barcode can be is 14, is there a better fieldtype to use that will keep the zeros? (or some way for PHP to tell mySQL not to chop off the zeros?) Rob, A few years ago, I developed a full-on inventory management system (with barcode printing and assignment, as well as scanning) and found that with Code 39 I didn't have the issue, but when using UPC or some other format, I often had to convert the code to string(). Then insert the data into a CHAR or VARCHAR column, because to most systems, INT 001234 is equal to INT 1234, but with more overhead, which is then normally trimmed. -- /Dan Daniel P. Brown Senior Unix Geek ? while(1) { $me = $mind--; sleep(86400); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP/mySQL dropping zeros after inserting number into record
Daniel Brown wrote: On Feb 16, 2008 6:22 PM, Rob Gould [EMAIL PROTECTED] wrote: I've got a PHP script that inserts 00012345678 into a record in a mySQL database (it's a barcode). Things work ok unless the number has preceding zeros, and then the zeros get cut off and all I get is 12345678. I have the mySQL database fieldtype set to bigint(14). If the maximum length a barcode can be is 14, is there a better fieldtype to use that will keep the zeros? (or some way for PHP to tell mySQL not to chop off the zeros?) Rob, A few years ago, I developed a full-on inventory management system (with barcode printing and assignment, as well as scanning) and found that with Code 39 I didn't have the issue, but when using UPC or some other format, I often had to convert the code to string(). Then insert the data into a CHAR or VARCHAR column, because to most systems, INT 001234 is equal to INT 1234, but with more overhead, which is then normally trimmed. zerofill is the way - the stupid but works way is to store the barcodes backwards :D or indeed base convert them from 10 to 32.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP/mySQL dropping zeros after inserting number into record
char(14) is a better data type bastien Date: Sat, 16 Feb 2008 15:22:17 -0800 From: [EMAIL PROTECTED] To: php-general@lists.php.net Subject: [PHP] PHP/mySQL dropping zeros after inserting number into record I've got a PHP script that inserts 00012345678 into a record in a mySQL database (it's a barcode). Things work ok unless the number has preceding zeros, and then the zeros get cut off and all I get is 12345678. I have the mySQL database fieldtype set to bigint(14). If the maximum length a barcode can be is 14, is there a better fieldtype to use that will keep the zeros? (or some way for PHP to tell mySQL not to chop off the zeros?) -- 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] PHP/mySQL dropping zeros after inserting number into record
Rob Gould [EMAIL PROTECTED] writes: I've got a PHP script that inserts 00012345678 into a record in a mySQL database (it's a barcode). Things work ok unless the number has preceding zeros, and then the zeros get cut off and all I get is 12345678. I have the mySQL database fieldtype set to bigint(14). If the maximum length a barcode can be is 14, is there a better fieldtype to use that will keep the zeros? Use ZEROFILL, example: CREATE TABLE `db`.`table` ( `barcode` integer(14) ZEROFILL NOT NULL ) -- Emilio Astarita [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP/mySQL question about groups
You are correct, but that is what I meant by all columns (all those in the query, and therefore subject to the distinct). At this point different database engines work differently, without an order by, some will use the primary sequence, some will scan table space (in other words, without an order by [or group by], some engines will give you a performance hit). It's always good practice to write your queries to help your DB engine find an index. Warren -Original Message- From: Andrew Ballard [mailto:[EMAIL PROTECTED] Sent: Thursday, February 07, 2008 7:16 AM To: PHP General list Subject: Re: [PHP] PHP/mySQL question about groups On Feb 7, 2008 1:20 AM, Warren Vail [EMAIL PROTECTED] wrote: I did some looking into performance issues many years ago at company that developed and marketed another database server, comparing the query plan to the actual code, and a query plan usually shows the processes that consume the major amount of time, disk I/O, index or table searches and such, but doesn't show time consumed comparing, discriminating, and totaling, mostly because they are negligible. On the other hand distinct depends on comparison of all columns and will have no help in reducing row counts unless accompanied by an order by clause, where as group by implys an orderby and can be faster if indexes are available for use in row ordering, and while the same totaling occurs, comparison is limited to the columns specified in the group by. Does DISTINCT really compare all columns? I would think it would only compare the columns explicitly included in the SELECT clause. The biggest impact on one or the other would be a well placed index, but for the most part they should be about the same. Warren Vail I have seen discussions where in GROUP BY can be faster than DISTINCT depending on whether the query uses things like correlated subqueries, but this is not applicable in the current case. At any rate, I don't want to stray the conversation any further away than I already have. Andrew -- 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] PHP/mySQL question about groups
On Feb 7, 2008 1:20 AM, Warren Vail [EMAIL PROTECTED] wrote: I did some looking into performance issues many years ago at company that developed and marketed another database server, comparing the query plan to the actual code, and a query plan usually shows the processes that consume the major amount of time, disk I/O, index or table searches and such, but doesn't show time consumed comparing, discriminating, and totaling, mostly because they are negligible. On the other hand distinct depends on comparison of all columns and will have no help in reducing row counts unless accompanied by an order by clause, where as group by implys an orderby and can be faster if indexes are available for use in row ordering, and while the same totaling occurs, comparison is limited to the columns specified in the group by. Does DISTINCT really compare all columns? I would think it would only compare the columns explicitly included in the SELECT clause. The biggest impact on one or the other would be a well placed index, but for the most part they should be about the same. Warren Vail I have seen discussions where in GROUP BY can be faster than DISTINCT depending on whether the query uses things like correlated subqueries, but this is not applicable in the current case. At any rate, I don't want to stray the conversation any further away than I already have. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php