Re: [PHP] mysql help (sorry, a bit OT)
Hello Gary, Actually, what I do here is the following: I create a subdomain called beta.mysite.com (for me it's http://beta.oire.org/ and http://beta.gviragon.org/ :-)). There I have a copy of my database and all of my files. The only difference is the mysql_select_db in the connect.php file. There I can easily test everything I need (including PHP files and MySql queries) without any danger to crash the main release). -- With best regards from Ukraine, Andre Skype: Francophile Twitter: http://twitter.com/m_elensule Facebook: http://facebook.com/menelion - Original message - From: Gary To: php-general@lists.php.net Date: Tuesday, November 16, 2010, 3:35:12 PM Subject: [PHP] mysql help (sorry, a bit OT) Is there a way to check the syntax of a query, short of running it? I've got an insert to do (but of course it's a valid question for any query that changes the db contents) and would like to know that the sql I am generating (in php - see! not so off-topic!) is correct. What I don't want to do is run it for testing (live system *sigh*) and find out it is correct (it will change the db), but... I have to test it to check that the syntax (at least) *is* correct. -- 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] mysql help (sorry, a bit OT)
> -Original Message- > From: Gary [mailto:php-gene...@garydjones.name] > Sent: Tuesday, November 16, 2010 5:35 AM > To: php-general@lists.php.net > Subject: [PHP] mysql help (sorry, a bit OT) > > Is there a way to check the syntax of a query, short of running it? I've got an > insert to do (but of course it's a valid question for any query that changes > the db contents) and would like to know that the sql I am generating (in php > - see! not so off-topic!) is correct. > > What I don't want to do is run it for testing (live system *sigh*) and find out > it is correct (it will change the db), but... I have to test it to check that the > syntax (at least) *is* correct. > Gary, If you use a current version of the MySQL workbench, the tool can send complete SELECT, UPDATE, INSERT, DELETE statement, with all the fields, to the query window for the selected table. That way you'll know that you have the proper field (name and quoted with `). Add that to what Ash suggested of having a local copy of the database, you'll have little or no chance of breakage in the app because of a silly SQL syntax error ;) Regards, Tommy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql help (sorry, a bit OT)
It's always best practice to have a staging server for testing these sorts of things. If in doubt, run it in a transaction, but don't commit it, I.e. roll it back. That way you'll see if it would run but nothing actually changes. Thanks, Ash http://www.ashleysheridan.co.uk - Reply message - From: "Gary" Date: Tue, Nov 16, 2010 13:35 Subject: [PHP] mysql help (sorry, a bit OT) To: Is there a way to check the syntax of a query, short of running it? I've got an insert to do (but of course it's a valid question for any query that changes the db contents) and would like to know that the sql I am generating (in php - see! not so off-topic!) is correct. What I don't want to do is run it for testing (live system *sigh*) and find out it is correct (it will change the db), but... I have to test it to check that the syntax (at least) *is* correct. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql help..
Hi, Saturday, February 25, 2006, 5:53:23 AM, you wrote: gu> Hi all, gu> I installed a opensource php project, and now is working fine for me. gu> Now that project has some 40-50 MySQL tables.. gu> now I want to change something in that but the I am not able to get the DB gu> flow.. gu> Is any body knows any tool by which we can create/make the relationship gu> diagram like we are doing in SQLserver or Access.. gu> To understand the DB is very tough... any body knows how I can create the gu> relationship diagram from that .SQL file... gu> thnx to alll... Try DbDesigner4, it will reverse engineer an existing database as much as it can. http://fabforce.net/ -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql help..
Ask the open-source project for help. They will be able to answer your questions better than we can. On 2/25/06, ganu ullu <[EMAIL PROTECTED]> wrote: > > Hi all, > > I installed a opensource php project, and now is working fine for me. > Now that project has some 40-50 MySQL tables.. > > now I want to change something in that but the I am not able to get the DB > flow.. > Is any body knows any tool by which we can create/make the relationship > diagram like we are doing in SQLserver or Access.. > > To understand the DB is very tough... any body knows how I can create the > relationship diagram from that .SQL file... > > thnx to alll... > >
Re: [PHP] mysql help..
ganu ullu wrote: Hi all, I installed a opensource php project, and now is working fine for me. Now that project has some 40-50 MySQL tables.. now I want to change something in that but the I am not able to get the DB flow.. Is any body knows any tool by which we can create/make the relationship diagram like we are doing in SQLserver or Access.. To understand the DB is very tough... any body knows how I can create the relationship diagram from that .SQL file... thnx to alll... I built my web site in php, can anyone hold my hand and find me a tool to analyze my server logs? -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySql Help
At 12:31 PM -0600 9/11/01, Jared Mashburn wrote: > >I am tring to run a query On the First Column and place the data into an >array. The problem that I am running into >Is that there are doubles, triples, and sometimes more of the same name >in that column. Each name represents something differnet in the >"Second" and "Third" and when I run a simple query (select "first" from >"table") I get (expectedly) all of the names in the Column "doubles" and >all. My question is , is there a way to select from a database and only >select one of each name from the column? > SELECT DISTINCT field1 FROM table1 ORDER BY field1 Alnisa -- . Alnisa Allgood Executive Director Nonprofit Tech (ph) 415.337.7412 (fx) 415.337.7927 (url) http://www.nonprofit-techworld.org (url) http://www.nonprofit-tech.org (url) http://www.tech-library.org . Nonprofit Tech E-Update mailto:[EMAIL PROTECTED] . applying technology to transform . -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Mysql help
On Mon, 10 Sep 2001 16:33, Roman wrote: > In mysql database i have 5 tables, their names are : > > db > user > host > tables_priv > columns_priv > > I know which information are in tables (db,user,tables_priv, > columns_priv) and I know for what serve this tables but i don't know > some information about table host ? Please send me some information > about this table. > > > Thank you. > > roman This is a mysql problem, not PHP. Try http://www.mysql.com/documentation/mysql/bychapter/manual_MySQL_Database_Administration.html#User_Account_Management -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA He who places head in sand, will get kicked in the end! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] MySql help #1
the structur is like: id, item name, items in stock , frogserialnumber, status 1, frog, 7, 002121, Reserved 2, frog, 7, 101011, Free 1, frog, 7, 212001, Free that's why I want to mark only N entries "Reserved", "Lawrence Sheed" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED] ... > Have you thought about your database design carefully? > > You might want to create a column for item count > > eg > > id, item name, items in stock > 1, frog, 7 > > if, say a customer orders 3 frogs, decrement the items in stock by 3. > > Just an idea... > > Do you know about database normalization? How is the database designed? > > > > -Original Message- > From: elias [mailto:[EMAIL PROTECTED]] > Sent: August 2, 2001 6:32 PM > To: [EMAIL PROTECTED] > Subject: Re: [PHP] MySql help #1 > > > Someone purchased items from my site let's say 3 items out of 5 total. All > items are the same. I just want to update 3 items status to "Reserved". > When he buy he just tell how many and not which ones. > > "Lawrence Sheed" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED] > .. > > Sounds like a strange request, what are you trying to do? > > > > I don't think you can do this directly in mysql, but you could build an > > array of results in php. > > > > eg something like (crappy code below) > > > > //Grab results > > $db = mysql_connect($db_domain, $db_user,$db_password); > > mysql_select_db($db_databasename,$db); > > $sqlquery="select ID from table1 where condition1"; > > $result = mysql_query ($sqlstring,$db); > > $count=0; > > while ($resultset = mysql_fetch_array ($result)) { > > $array[$count]=$resultset ["ID"]; > > $count++; > > } > > > > > > for ($count=0;$count<2;$count++){ > > "update table1 set field='VALUE' WHERE ID=".$array[$count]"; > > $result = mysql_query ($sqlstring,$db) or die (mysql_error()); > > } > > > > -Original Message- > > From: elias [mailto:[EMAIL PROTECTED]] > > Sent: August 2, 2001 4:30 PM > > To: [EMAIL PROTECTED] > > Subject: [PHP] MySql help #1 > > > > > > How can I update only N fields from the database? > > > > usually we do: > > > > UPDATE table1 SET field='VALUE' WHERE condition1 > > > > now I want to update fields with a certain condition but only X fields out > N > > total fields. > > > > ie: > > > > id value > > --- --- > > 1a > > 2b > > 3c > > 4d > > 5e > > > > how can i update such like: > > UPDATE table1 SET {only 2 records} value='aa' > > so I have any two fields now have the 'aa' value > > > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Mysql Help #2
Depends what is to happen to the array afterwards, but in general no. An interesting thing is to put timing method calls around a block of code in question, you will find something like this (depending upon size of db) takes somehting like 0.005 seconds. Timing things can be useful measures of a pages overhead (one page on a site I hvae currently takes almost 2 seconds on average to build...eek!) "elias" <[EMAIL PROTECTED]> wrote in message - Original Message - From: "elias" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, August 02, 2001 9:31 AM Subject: [PHP] Mysql Help #2 > Hi again. > > $result = mysql_query("SELECT id FROM table"); > $id_array = array(); > > while ($r = mysql_fetch_array($result)) >$id_array[] = $r["id"]; > > // now $id_array[] is an array of IDs that was grabbed from the database. > > Any faster and/or better approache to build the $id_array? > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] MySql help #1
Come on, you're pushing SQL in directions it's not supposed to go! It is set oriented after all. So it's experimentation time. I've never tried, but as LIMIT works on a SELECT, try it on an update. And let us know what happened. Miles At 10:30 AM 8/2/01 +0200, elias wrote: >How can I update only N fields from the database? > >usually we do: > >UPDATE table1 SET field='VALUE' WHERE condition1 > >now I want to update fields with a certain condition but only X fields out N >total fields. > >ie: > >id value >--- --- >1a >2b >3c >4d >5e > >how can i update such like: >UPDATE table1 SET {only 2 records} value='aa' >so I have any two fields now have the 'aa' value > > > > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] MySql help #1
Miles, The LIMIT works great with UPDATE too. "Miles Thompson" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > Come on, you're pushing SQL in directions it's not supposed to go! It is > set oriented after all. > So it's experimentation time. I've never tried, but as LIMIT works on a > SELECT, try it on an update. And let us know what happened. > Miles > > At 10:30 AM 8/2/01 +0200, elias wrote: > >How can I update only N fields from the database? > > > >usually we do: > > > >UPDATE table1 SET field='VALUE' WHERE condition1 > > > >now I want to update fields with a certain condition but only X fields out N > >total fields. > > > >ie: > > > >id value > >--- --- > >1a > >2b > >3c > >4d > >5e > > > >how can i update such like: > >UPDATE table1 SET {only 2 records} value='aa' > >so I have any two fields now have the 'aa' value > > > > > > > > > > > >-- > >PHP General Mailing List (http://www.php.net/) > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > >To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Mysql Help #2
Looks fine to me Miles At 10:31 AM 8/2/01 +0200, elias wrote: >Hi again. > >$result = mysql_query("SELECT id FROM table"); >$id_array = array(); > >while ($r = mysql_fetch_array($result)) >$id_array[] = $r["id"]; > >// now $id_array[] is an array of IDs that was grabbed from the database. > >Any faster and/or better approache to build the $id_array? > > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] MySql help #1
Have you thought about your database design carefully? You might want to create a column for item count eg id, item name, items in stock 1, frog, 7 if, say a customer orders 3 frogs, decrement the items in stock by 3. Just an idea... Do you know about database normalization? How is the database designed? -Original Message- From: elias [mailto:[EMAIL PROTECTED]] Sent: August 2, 2001 6:32 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] MySql help #1 Someone purchased items from my site let's say 3 items out of 5 total. All items are the same. I just want to update 3 items status to "Reserved". When he buy he just tell how many and not which ones. "Lawrence Sheed" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED] ... > Sounds like a strange request, what are you trying to do? > > I don't think you can do this directly in mysql, but you could build an > array of results in php. > > eg something like (crappy code below) > > //Grab results > $db = mysql_connect($db_domain, $db_user,$db_password); > mysql_select_db($db_databasename,$db); > $sqlquery="select ID from table1 where condition1"; > $result = mysql_query ($sqlstring,$db); > $count=0; > while ($resultset = mysql_fetch_array ($result)) { > $array[$count]=$resultset ["ID"]; > $count++; > } > > > for ($count=0;$count<2;$count++){ > "update table1 set field='VALUE' WHERE ID=".$array[$count]"; > $result = mysql_query ($sqlstring,$db) or die (mysql_error()); > } > > -Original Message- > From: elias [mailto:[EMAIL PROTECTED]] > Sent: August 2, 2001 4:30 PM > To: [EMAIL PROTECTED] > Subject: [PHP] MySql help #1 > > > How can I update only N fields from the database? > > usually we do: > > UPDATE table1 SET field='VALUE' WHERE condition1 > > now I want to update fields with a certain condition but only X fields out N > total fields. > > ie: > > id value > --- --- > 1a > 2b > 3c > 4d > 5e > > how can i update such like: > UPDATE table1 SET {only 2 records} value='aa' > so I have any two fields now have the 'aa' value > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] MySql help #1
Someone purchased items from my site let's say 3 items out of 5 total. All items are the same. I just want to update 3 items status to "Reserved". When he buy he just tell how many and not which ones. "Lawrence Sheed" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED] ... > Sounds like a strange request, what are you trying to do? > > I don't think you can do this directly in mysql, but you could build an > array of results in php. > > eg something like (crappy code below) > > //Grab results > $db = mysql_connect($db_domain, $db_user,$db_password); > mysql_select_db($db_databasename,$db); > $sqlquery="select ID from table1 where condition1"; > $result = mysql_query ($sqlstring,$db); > $count=0; > while ($resultset = mysql_fetch_array ($result)) { > $array[$count]=$resultset ["ID"]; > $count++; > } > > > for ($count=0;$count<2;$count++){ > "update table1 set field='VALUE' WHERE ID=".$array[$count]"; > $result = mysql_query ($sqlstring,$db) or die (mysql_error()); > } > > -Original Message- > From: elias [mailto:[EMAIL PROTECTED]] > Sent: August 2, 2001 4:30 PM > To: [EMAIL PROTECTED] > Subject: [PHP] MySql help #1 > > > How can I update only N fields from the database? > > usually we do: > > UPDATE table1 SET field='VALUE' WHERE condition1 > > now I want to update fields with a certain condition but only X fields out N > total fields. > > ie: > > id value > --- --- > 1a > 2b > 3c > 4d > 5e > > how can i update such like: > UPDATE table1 SET {only 2 records} value='aa' > so I have any two fields now have the 'aa' value > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] MySql help #1
Sounds like a strange request, what are you trying to do? I don't think you can do this directly in mysql, but you could build an array of results in php. eg something like (crappy code below) //Grab results $db = mysql_connect($db_domain, $db_user,$db_password); mysql_select_db($db_databasename,$db); $sqlquery="select ID from table1 where condition1"; $result = mysql_query ($sqlstring,$db); $count=0; while ($resultset = mysql_fetch_array ($result)) { $array[$count]=$resultset ["ID"]; $count++; } for ($count=0;$count<2;$count++){ "update table1 set field='VALUE' WHERE ID=".$array[$count]"; $result = mysql_query ($sqlstring,$db) or die (mysql_error()); } -Original Message- From: elias [mailto:[EMAIL PROTECTED]] Sent: August 2, 2001 4:30 PM To: [EMAIL PROTECTED] Subject: [PHP] MySql help #1 How can I update only N fields from the database? usually we do: UPDATE table1 SET field='VALUE' WHERE condition1 now I want to update fields with a certain condition but only X fields out N total fields. ie: id value --- --- 1a 2b 3c 4d 5e how can i update such like: UPDATE table1 SET {only 2 records} value='aa' so I have any two fields now have the 'aa' value -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] mysql help!! urgent!
> Warning: Unable to jump to row 0 on MySQL result index 2 in > /home/sites/site3/web/showthumb on line 71 > > --here is my code Change it to look like this: > $connetion = mysql_connect("localhost","cel34243","s2343223") or die($php_errormsg); > $query = "select images from celeb where name=\"$dir.\" "; > $result = mysql_db_query("celebzone", $query) or die(mysql_error()); > $imagesnum= mysql_result($result, "images"); You are missing an argument there... You need a row number in front of "images". Also, you probably don't have any rows that matched your criteria, so asking for the first row (row 0) is bad. -- Visit the Zend Store at http://www.zend.com/store/ Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] MySQL help URGENT
On Thu, 8 Mar 2001 02:38, Deependra B. Tandukar wrote: > Greetings! > > I am trying to compile MySQL. what I did are: > tar -xvzf mysql-3.23.33.tar.gz > cd mysql-3.23.33 > ./configure --prefix=/usr/local/mysql > then it startx to work and inerrupt and says > testing gcc working: no > configure: error: installation or configure problem: c compiler can not > create executables > > what should I do? The mysql list would be a good place for mysql problems, no? But you a) may not have access to the c compiler or b) may not have permission to create files in the particular directory or -- David Robley| WEBMASTER & Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet| http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]