RE: [PHP-DB] INSERTing INTO Multiple Tables with MySQL PHP
Something like this, perhaps? ? // your INSERT to first table here. $insert_id = mysql_insert_id(); $sql = SELECT MAX(SecondID) FROM LookupTable WHERE FirstID = $insert_id; $result = mysql_query($sql); $row = mysql_fetch_array($result); $max_second_id = $row[0]; $sql = INSERT INTO LookupTable VALUES ($insert_id, $max_second_id + 1); $result = mysql_query($sql); ? Might be some errors in it, but you get the idea. Regards Joakim Andersson -Original Message- From: Graeme McLaren [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 03, 2002 5:42 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] INSERTing INTO Multiple Tables with MySQL PHP Hi there, I've been hunting thru the net trying to find some info on inserting data to multiple tables. I have two tables (LookupTable and MainTable): LookupTable( FirstID SecondID ) MainTable( ID Name Address etc etc ) Once I insert data into the MainTable I want to also insert the ID from the MainTable to the LookupTable as the FirstID. Then I want to check for the highest ID number in the SecondID field that is associated with the First ID then add one to the highest value and insert that to the SecondID. FirstID SecondID 1 1 1 2 1 3 1 4 In the above table I would want to insert 1 to the FirstID then find the highest number in the SecondID associated with the FirstID 1 then add one to it so that my next row in the table would be: FirstID SecondID 1 5 How would I go about doing this? I've been looking thru Kevin Yank's book Build Your Own Database Driven Website Using PHP MySQL, its pretty good on the whole but updating two tables simultaneously seems to be lacking detail. I hope I've made this clear enough, I may have repeated myself there but I was wanted to make sure that what I've written is cleary understood. Thank you in advance for any help - I'm lost! Graeme :) Public Sub House() On Error Resume drink If Pint.empty = True Then Pint.refill Else Pint.drink End if stomach.add Pint MsgBox I've had stomach.count Pints MsgBox VERY DRUNK End Sub -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] php - checkboxes - mysql
Try something like this: INPUT type=checkbox name=?php echo( $row['name'] ) ; ? value=1 ?php echo( $row['homeno'] == 0 ? : checked ) ; ? (value is a dummy value - HTML will POST the name=value pair only if checked.) HTH Ignatius - Original Message - From: Chris [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, September 09, 2002 11:03 PM Subject: [PHP-DB] php - checkboxes - mysql Greetings, I am just starting with php and need some help/code example for setting checkbox values from mysql. My setup is the following: The mysql database holds data and checkbox values in respective columes. For example name address phone homeno workno pagerno Chris 555-1212 1 0 0 1 = checkbox should be checked 0 = checkbox should not be checked On the webpage side I would have name, address and phone number textboxes, and then 3 checkboxes for the homeno, workno and pagerno. When the page loads I would like to have the checkboxes be automatically checked or left uncheck based on the mysql query to the db. I do not want to do any grouping or anything, just query mysql for the homeno value, set it, then check the workno value, set it, etc.. Any help is GREATLY appreciated. Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: assist with SORT array
Bartosz was correct in saying that you should use your query to sort, rather than sorting array. And the array is actually sorted, although it keeps its index. See the manual reference on arrays to see how they work. To iterate over sorted arrays, use the foreach() construct. Anyway, the better way to do it (using only 1 sql query), would be using the following code. $rest_IDs = implode(',', $restaurants); $sql = SELECT name FROM restaurants WHERE id IN ('$rest_IDs') ORDER BY name; $result = mysql_query($sql) or die($sql . mysql_error()); while($row=mysql_fetch_object($result)) { $rest_array[] = ucwords(stripslashes($row-name)); } And its sorted!!! If you want to check what values an array holds, use a combination of header(Content-Type: text/plain); and print_r($rest_array); Have fun! Adam I have a head scratcher.. prob just a glitch on my side, but somehow I am confused with the results. I have a php script pulling from a mysql database for id/names which is getting choices through a check box form. All of that works just fine, but I wanted to display the results sorted by title. My snippet of code is: // $restaurants = array() of ids back from form for($i=0;$isizeof($restaurants);$i++) { $rest_id = $restaurants[$i]; $sql=select name from restaurants where id=$rest_id; $result=mysql_query($sql) or die($sql . mysql_error()); while($row=mysql_fetch_object($result)) { $rest_name .= ucwords(stripslashes($row-name)) . ;; } } $rest_array=explode(;,$rest_name); $rest_sort=sort($rest_array); // -- the problem line die(checking: $rest_namebrbr size = .sizeof($rest_array) . sorted: . sizeof($rest_sort)); the results come back with 6 in the $rest_array but only 1 in the $rest_sort array! How is that?? checking: Hi-Ho Tavern;Village Inn;Speak Easy;Duane's House Of Pizza;Atomic Coffee; size = 6 sorted: 1 What I am trying to accomplish is an array('Atomic Coffee', 'Duane's House Of Pizza','Hi-Ho Tavern','Speak Easy','Village Inn') Help?? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Conversion from access to mysql
Hey there all This is more than likely a common question, anyone have any guidelines, do's or dont's about converting an access db to mysql db... Regards Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
SV: [PHP-DB] Conversion from access to mysql
Hi, Check out MyAccess at http://www.accessmysql.com/. It works for me. The manual points out some things to keep in mind when converting. /Dann -Oprindelig meddelelse- Fra: Chris Grigor [mailto:[EMAIL PROTECTED]] Sendt: 10. september 2002 11:48 Til: [EMAIL PROTECTED] Emne: [PHP-DB] Conversion from access to mysql Hey there all This is more than likely a common question, anyone have any guidelines, do's or dont's about converting an access db to mysql db... Regards Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Conversion from access to mysql
also http://www.dbtools.com.br this will work both ways accessmysql also supports excel , dbf, csv etc etc Steven - Original Message - From: Chris Grigor [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, September 10, 2002 10:47 AM Subject: [PHP-DB] Conversion from access to mysql Hey there all This is more than likely a common question, anyone have any guidelines, do's or dont's about converting an access db to mysql db... Regards Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Conversion from access to mysql
both tools don't work okay for me, i'm just using the export tool in MsAccess then convert database to xml, and thanks to PHP, i convert that to mysql queries. Just one problem when i want to convert binary data (pict or others), still haven't find a suitable solution for that. Best regards, Hatem - Original Message - From: Steven Dowd [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, September 10, 2002 12:54 PM Subject: Re: [PHP-DB] Conversion from access to mysql also http://www.dbtools.com.br this will work both ways accessmysql also supports excel , dbf, csv etc etc Steven - Original Message - From: Chris Grigor [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, September 10, 2002 10:47 AM Subject: [PHP-DB] Conversion from access to mysql Hey there all This is more than likely a common question, anyone have any guidelines, do's or dont's about converting an access db to mysql db... Regards Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fw: [PHP-DB] Conversion from access to mysql
Untitled Document --- - Qbit Web developer tel.: 0108256721 - 0108256722 fax: 0108256712 email: [EMAIL PROTECTED] http://www.qbit.gr - Original Message - From: nikos [EMAIL PROTECTED] To: Chris Grigor [EMAIL PROTECTED] Sent: Tuesday, September 10, 2002 2:46 PM Subject: Re: [PHP-DB] Conversion from access to mysql You should install MyQDBC. Then use it to export the Access tables in MySQL Nikos -- -- -- - Original Message - From: Chris Grigor [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, September 10, 2002 12:47 PM Subject: [PHP-DB] Conversion from access to mysql Hey there all This is more than likely a common question, anyone have any guidelines, do's or dont's about converting an access db to mysql db... Regards Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fw: [PHP-DB] Conversion from access to mysql
You should install MyQDBC. Then use it to export the Access tables in MySQL Nikos -- -- -- - Original Message - From: Chris Grigor [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, September 10, 2002 12:47 PM Subject: [PHP-DB] Conversion from access to mysql Hey there all This is more than likely a common question, anyone have any guidelines, do's or dont's about converting an access db to mysql db... Regards Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fw: [PHP-DB] Conversion from access to mysql
You should install MyQDBC. Then use it to export the Access tables in MySQL Nikos -- -- -- - Original Message - From: Chris Grigor [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, September 10, 2002 12:47 PM Subject: [PHP-DB] Conversion from access to mysql Hey there all This is more than likely a common question, anyone have any guidelines, do's or dont's about converting an access db to mysql db... Regards Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fw: [PHP-DB] php - checkboxes - mysql
You should first check if checkbox value stored in the databese is 1 or 0. After use an if clause: if ($checkbox==1) { echo input type=\checkbox\ name=\checkbox\ value=\1\ checked } elseif ($checkbox==0) { input type=\checkbox\ name=\checkbox\ value=\0\ } Nikos -- -- --- - Original Message - From: Chris [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, September 10, 2002 12:03 AM Subject: [PHP-DB] php - checkboxes - mysql Greetings, I am just starting with php and need some help/code example for setting checkbox values from mysql. My setup is the following: The mysql database holds data and checkbox values in respective columes. For example name address phone homeno workno pagerno Chris 555-1212 1 0 0 1 = checkbox should be checked 0 = checkbox should not be checked On the webpage side I would have name, address and phone number textboxes, and then 3 checkboxes for the homeno, workno and pagerno. When the page loads I would like to have the checkboxes be automatically checked or left uncheck based on the mysql query to the db. I do not want to do any grouping or anything, just query mysql for the homeno value, set it, then check the workno value, set it, etc.. Any help is GREATLY appreciated. Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fw: [PHP-DB] whats wrong with my sql insert statement?
Try remove (;) at the end of the expresion, before quote (): VALUES ('$first_name','$location','$phone', '$blabla')...(;)... - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, September 10, 2002 4:38 AM Subject: Re: [PHP-DB] whats wrong with my sql insert statement? Thanks for your suggestions. first my /etc/php.ini register_globals = on second i made the change as you suggested and i added a [$blabla = truly random;] when the input.php is excuated, 'blabla' value is inserted into the table. '$first_name' is still left blank. this leads me to believe that '$first_name' is blank to start with! somehow the input.html gives input.php blank $first_name , $location . care to look at my input.html ? thanks alot. # ?php $db_name =cheese_catalog; $table_name = user; $blabla = bla bla; $connection = @mysql_connect(localhost,test,new0pass) or die(Couldn't Connect.); $db = @mysql_select_db($db_name, $connection) or die(Couldn't select database.); if (none_required==none_required) { $sql = INSERT INTO $table_name (first_name,location,phone,messages) VALUES ('$first_name','$location','$phone', '$blabla');; $result = @mysql_query($sql, $connection) or die(Error #. mysql_errno() . : . mysql_error()); include(input_added.html); } ? # Michael Hazelden wrote: Hi there, Two things: (a) in my experience - you should use single quotes in your query to surround the values and so you don't need to escape them either (e.g. '$first_name') and (b) Make sure register_globals is on - otherwise you need to use $_POST[first_name] Cheers, Michael. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: 10 September 2002 01:15 To: [EMAIL PROTECTED] Subject: [PHP-DB] whats wrong with my sql insert statement? Hi I am using redhat 7.3 with mysql-3.23.49-3 php-4.1.2-7.3.4 apache-1.3.23-11. I want to insert few values into a mysql table. This input.php sort works. it will add a new entray to the table but with blank values. What did I do wrong? # # # file name input.php ?php $db_name =cheese_catalog; $table_name = user; $connection = @mysql_connect(localhost,test,test) or die(Couldn't Connect.); $db = @mysql_select_db($db_name, $connection) or die(Couldn't select database.); if (none_required==none_required) { $sql = INSERT INTO $table_name (first_name,location,phone,messages) VALUES (\$first_name\,\$location\,\$phone\, \$messages\);; $result = @mysql_query($sql, $connection) or die(Error #. mysql_errno() . : . mysql_error()); include(input_added.html); } ? # # file name input.html # html head titleNew Record/title /head body pPlease fill out the following information:/p form method=post action=input.php enctype=multipart/form-data table width=100% border=0 cellspacing=3 cellpadding=3 tr td width=25%first_name:/td td width=75%input name=first_name type=text size=40 maxlength=255 value=/td /tr tr td width=25%location:/td td width=75%input name=location type=text size=40 maxlength=255 value=/td /tr tr td width=25%phone:/td td width=75%input name=phone type=text size=40 maxlength=255 value=/td /tr tr td width=25%messages:/td td width=75%input name=messages type=text size=40 maxlength=255 value=/td /tr tr td width=25%nbsp;/td td width=75% align=leftinput type=submit name=submit value=Enternbspinput type=reset name=reset/td /tr /table /form /body /html # # -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] php - checkboxes - mysql
Also check the archives for the php-db list. Questions very similar to this get asked just about every week and you might be able to find more information there. Rich -Original Message- From: nikos [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 10, 2002 7:51 AM To: PHP-mailist Subject: Fw: [PHP-DB] php - checkboxes - mysql You should first check if checkbox value stored in the databese is 1 or 0. After use an if clause: if ($checkbox==1) { echo input type=\checkbox\ name=\checkbox\ value=\1\ checked } elseif ($checkbox==0) { input type=\checkbox\ name=\checkbox\ value=\0\ } Nikos -- -- --- - Original Message - From: Chris [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, September 10, 2002 12:03 AM Subject: [PHP-DB] php - checkboxes - mysql Greetings, I am just starting with php and need some help/code example for setting checkbox values from mysql. My setup is the following: The mysql database holds data and checkbox values in respective columes. For example name address phone homeno workno pagerno Chris 555-1212 1 0 0 1 = checkbox should be checked 0 = checkbox should not be checked On the webpage side I would have name, address and phone number textboxes, and then 3 checkboxes for the homeno, workno and pagerno. When the page loads I would like to have the checkboxes be automatically checked or left uncheck based on the mysql query to the db. I do not want to do any grouping or anything, just query mysql for the homeno value, set it, then check the workno value, set it, etc.. Any help is GREATLY appreciated. Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] previous and next with postgresql
Hi I am trying to have previous and next links in my php script wich i make a select from a table. I am using postgresql anybody has a link for a tutorial or a sample code doing this? Ângelo Marcos Rigo Webmaster Colégio Anchieta http://www.colegioanchieta.g12.br -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] previous and next with postgresql
Hello, Angelo. Try pn.class.php at www.phpclasses.org AMR I am trying to have previous and next links in my php script AMR wich i make a select from a table. I am using postgresql AMR anybody has a link for a tutorial or a sample code doing this? www.pskov.ru -- Best Regards, Andrey mailto:[EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] FW: Php database support
David, You will be pleased with OpenLink Software's ODBC Drivers. This requires setting up PHP --with-iodbc, as per the HOWTO's on http://www.iodbc.org and the ODBC drivers are available as a free 30-day download from our site. Please let me know if you have any questions. Best regards, Andrew Hill Director of Technology Evangelism OpenLink Software http://www.openlinksw.com Universal Data Access Virtuoso Universal Server -Original Message- From: Walgamotte, David [mailto:[EMAIL PROTECTED]] Sent: Monday, September 09, 2002 8:16 AM To: '[EMAIL PROTECTED]' Subject: [PHP-DB] FW: Php database support Hello All !!! We use PHP in a production e-commerce web environment with a mysql database server. The higher ups have decided they want to move to Microsoft SQL. I'm now tasked to convert our Unix Apache PHP environment to use a remote Microsoft SQL server. I've researched and used TDS the Sybase connector to Microsoft SQL. It works but is very slow. Has anyone completed such a migration ? Can anyone recommend a solid connector between UNIX PHP and Microsoft SQL DB and a place to go for setup procedures ? Thanks You very much ? DW -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Problem with SQL
Most likely the datatype you are using for the id field is tinyint, auto increment. The tinyint datatype only goes to 127, so once you get to 127, it tries to assign the same value for the next one. Try changing your id datatype to int. HTH Maureen Brtosz Matosiuk [EMAIL PROTECTED] said: Hi all SQL gives me a strange error and I can't find any info about it. Mayby someone of you could give me a clue what is wrong. The error is : 'Duplicate entry '127' for key 1' Thanks for any help -- -= MAdSiuK ([EMAIL PROTECTED]) =- (...) jestesmy nihilistami, w nic nie wierzymy, doslownie w nic(...) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Multiple Sorts??
Is there a way that I can sort data twice when it is being pulled from the DB? Here is a sample line of my code: $result = mysql_query(SELECT * FROM pfiles WHERE cdate = '2002-07-01' ORDER BY 'cdate' DESC, $link); I would like to be able to sort this data FIRST by 'cdate' then by 'vendor' Is this possible? Thanks! Chase -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] PHP in a javascript function with DB calls.
Hi All, I HOPE this is the right place for this.. if not I am sorry!!! I'm hoping someone can put me on a clear path of how to do what I am asking here. I Have a shopping cart... and in this shopping cart I want to feature some items in a pop_up window when the user is ready to check out - if they are not already selected. For example.. Someone buy a Hockey Stick but don't buy hockey tape.. when when they go to check out.. I want a pop_up to be launched asking the user if they want to add Hockey tape to their order for onlu $$$. For this to happen I need to have an onLoad on the checkout page that calls a javascript function that has PHP code to find out IF a paritcular product is selected to see if the other has been selected too, if it's NOT selected then launch the pop_up. Does ANYONE have any idea's as to how this can be accomplished?? Anyhelp is appreciated thanks all. Aaron
Re: [PHP-DB] PHP in a javascript function with DB calls.
Umm, the body tag in HTML has an onLoad parameter. So: body bgcolor=black onload=javascript:window.new('url'); That code for the window.new is probably wrong, but that will do it. Adam Voigt [EMAIL PROTECTED] On Tue, 2002-09-10 at 11:20, Aaron Wolski wrote: Hi All, I HOPE this is the right place for this.. if not I am sorry!!! I'm hoping someone can put me on a clear path of how to do what I am asking here. I Have a shopping cart... and in this shopping cart I want to feature some items in a pop_up window when the user is ready to check out - if they are not already selected. For example.. Someone buy a Hockey Stick but don't buy hockey tape.. when when they go to check out.. I want a pop_up to be launched asking the user if they want to add Hockey tape to their order for onlu $$$. For this to happen I need to have an onLoad on the checkout page that calls a javascript function that has PHP code to find out IF a paritcular product is selected to see if the other has been selected too, if it's NOT selected then launch the pop_up. Does ANYONE have any idea's as to how this can be accomplished?? Anyhelp is appreciated thanks all. Aaron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Multiple Sorts??
$result = mysql_query(SELECT * FROM pfiles WHERE cdate = '2002-07-01' ORDER BY 'cdate' DESC, $link); I would like to be able to sort this data FIRST by 'cdate' then by 'vendor' Is this possible? Yes. Just add another sort criterium to your query like this: $result = mysql_query(SELECT * FROM pfiles WHERE cdate = '2002-07-01' ORDER BY 'cdate' DESC, 'vendor' DESC, $link); Petr. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] PHP in a javascript function with DB calls.
Hi. You cannot call PHP script from JavaScript in any simple way. It can be possibly done by including JavaScript code generated by PHP script through script src=script.php..., but it is too complicated. I think it will be better to do this like this: user have selected some items and goes to check out - his browser requests new page with check out form for example checkout.php - your checkout.php can look like this: html head /head body !-- test for related items (hockey stick - hockey tape) -- !-- your checkout code here -- /body /html in part 'test for pop-up' you will check for items related to currently selected items, and if your script find some items then you can echo JavaScript code to open new window with additional items to buy or show these items on the top of page before the checkout form. I hope this helps. Petr. On Tue, 2002-09-10 at 17:20, Aaron Wolski wrote: Hi All, I HOPE this is the right place for this.. if not I am sorry!!! I'm hoping someone can put me on a clear path of how to do what I am asking here. I Have a shopping cart... and in this shopping cart I want to feature some items in a pop_up window when the user is ready to check out - if they are not already selected. For example.. Someone buy a Hockey Stick but don't buy hockey tape.. when when they go to check out.. I want a pop_up to be launched asking the user if they want to add Hockey tape to their order for onlu $$$. For this to happen I need to have an onLoad on the checkout page that calls a javascript function that has PHP code to find out IF a paritcular product is selected to see if the other has been selected too, if it's NOT selected then launch the pop_up. Does ANYONE have any idea's as to how this can be accomplished?? Anyhelp is appreciated thanks all. Aaron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] PHP in a javascript function with DB calls.
A bit of a strange way would be to always pop the window and at that point have the PHP decide what to put in there. If there is not offer you want to include you could simply thank them, or you could even produce an inline window.close(); javascript call. The only problem with that is that some browsers pop a message saying that the script is trying to close the window. I'd expect you to know upon hitting the checkout screen what you'd want to do so you could do the processing there and have the code decide whether to even pop the window. Hope it's worth a cent or 2... :-) Ryan -Original Message- From: Petr Tomenendál [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 10, 2002 10:58 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] PHP in a javascript function with DB calls. Hi. You cannot call PHP script from JavaScript in any simple way. It can be possibly done by including JavaScript code generated by PHP script through script src=script.php..., but it is too complicated. I think it will be better to do this like this: user have selected some items and goes to check out - his browser requests new page with check out form for example checkout.php - your checkout.php can look like this: html head /head body !-- test for related items (hockey stick - hockey tape) -- !-- your checkout code here -- /body /html in part 'test for pop-up' you will check for items related to currently selected items, and if your script find some items then you can echo JavaScript code to open new window with additional items to buy or show these items on the top of page before the checkout form. I hope this helps. Petr. On Tue, 2002-09-10 at 17:20, Aaron Wolski wrote: Hi All, I HOPE this is the right place for this.. if not I am sorry!!! I'm hoping someone can put me on a clear path of how to do what I am asking here. I Have a shopping cart... and in this shopping cart I want to feature some items in a pop_up window when the user is ready to check out - if they are not already selected. For example.. Someone buy a Hockey Stick but don't buy hockey tape.. when when they go to check out.. I want a pop_up to be launched asking the user if they want to add Hockey tape to their order for onlu $$$. For this to happen I need to have an onLoad on the checkout page that calls a javascript function that has PHP code to find out IF a paritcular product is selected to see if the other has been selected too, if it's NOT selected then launch the pop_up. Does ANYONE have any idea's as to how this can be accomplished?? Anyhelp is appreciated thanks all. Aaron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] update db problem
I am making a web form for entering/editing/deleting items from a database, the entering and deleting parts work fine. The editing part is giving me some problems - Here's the code - ? include connect; if ($submit) { // if no ID then we're adding a new rma, else we're editing an existing rma if ($id) { $sql = UPDATE rma SET rma_no='$rma_no',rma_name='$rma_name',rec_date ='$rec_date',rma_status='$rma_status' WHERE id='$id'; } else { $sql = INSERT INTO rma (rma_no,rma_name,rec_date,rma_status) VALUES ('$rma_no','$rma_name','$rec_date','$rma_status'); } // run SQL against the DB $result = mysql_query($sql); echo Record updated/edited!p a href=\rma_input.php\List RMA's/a; } elseif ($delete) { // delete a record $sql = DELETE FROM rma WHERE id=$id; $result = mysql_query($sql); echo Deleted!pa href=\rma_input.php\List RMA's/a/p; } else { // this part happens if we don't press submit if (!$id) { // print the list if there is not editing $result = mysql_query(SELECT * FROM rma,$db); while ($myrow = mysql_fetch_array($result)) { printf(a href=\%s?id=%s\%s %s/a \n, $PHP_SELF, $myrow[id], $myrow[rma_no], $myrow[rma_name], $myrow[rec_date], $myrow [rma_status]); printf(a href=\%s?id=%sdelete=yes\(DELETE)/abr, $PHP_SELF, $myrow[id]); } } if ($id) { // editing so select a record $sql = SELECT * FROM rma WHERE id=$id; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); $id = $myrow[id]; $rma_no = $myrow[rma_no]; $rma_name = $myrow[rma_name]; $rec_date = $myrow[rec_date]; $rma_status = $myrow[rma_status]; // print the id for editi ? input type=hidden name=id value=?php echo $id ? ? } } ? What is happening is when I click on an item on the list it will display all the fields except rma_status (a textarea form field). When I make any changes and press submit, the changes to fields other than rma_status, those fields are updated or left as is, but the rma_status textarea is wiped out. Also, instead of updating the current item in the db, it is submitting another row into the database, giving multiple rows of the same rma, but with each one showing it's edits over time. This would be fine for historical purposes, but not what I want. What am I doing wrong? -- Chip Wiegand Computer Services Simrad, Inc www.simradusa.com [EMAIL PROTECTED] There is no reason anyone would want a computer in their home. --Ken Olson, president, chairman and founder of Digital Equipment Corporation, 1977 (They why do I have 9? Somebody help me!) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] ODBC text driver problem
Hello, I'm having trouble connecting via ODBC using the Microsoft text driver on a win2k box. I read the KB article at http://support.microsoft.com/default.aspx?scid=kb;en-us;Q178717 and it seems to suggest that I should be able to select data from a text source. Here is what I have so far: odbc_close_all(); $odbc = odbc_connect(cvalcoinput,,) OR die(There is an error connecting to the CSV file.); $result = odbc_tables($odbc); odbc_fetch_into($result, $fields) print_r($fields); - unset($fields); $result = odbc_exec($odbc,SELECT * from inputfile.txt); odbc_fetch_into($result, $fields) print_r($fields); The connection and following tables commands work great, but when I actually select data via the odbc_exec command, I get the following error: Warning: SQL error: [Microsoft][ODBC Text Driver] The Microsoft Jet database engine \ cannot open the file '(unknown)'. It is already opened exclusively by another user, \ or you need permission to view its data., SQL state S1000 in SQLExecDirect in \ ***:\***\***\***\basecsv2.html on line 53 Any ideas? -Ethan, Modulus, LLC -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
AW: [PHP-DB] PHP in a javascript function with DB calls.
Hi, I had a similar problem to this shopping cart some time ago, and I handled it that way: Within a form the user (it's made for salesmen) can add lines of articles, text etc to build up an offer. The price for the added articles can be choosen from different pricelists given in a database. Within this form offer a double-click on the field articlenumber calls the JavaScript function NeuPreisl() with a parameter $pos to reflect the selected line. This Javascript function opens a Popup window, where the user then can select the price for this article which in a further step is passed back to the form offer where all action started. ... echo input type=text name='artnr' size='15' maxlength=20 value='' readonly style='background-color:$bgcolor3;' onDblClick=\NeuPreisl('$pos')\ title='Doppelklicken fuuml;r Preisliste'; ... The JavaScript function Neupreisl() looks like this, where at the beginning I build up the URI in uristr, the selected articlenumber which is already in the form (but not returned to and known by PHP and the Server at this moment!!) is stored in an array artikelnummer[] with the passed argument $pos as index. A new window in the browser is opened and the arguments articlenumber and some other are returned to the serverside PHP-Script script.php (which afterwards makes a DB-query and populates the new window with some data). The variable $mode is used to control the action within script.php. function NeuPreisl(posnr) { // Pricelist var artikelnummer= this.document.frm['artikelnummer'+posnr]; // reading the artikelnummer of this line var artnr= artikelnummer.value; // getting the value var uristr= ../script.php?PHPSESSID=$PHPSESSIDmode=searchprlartikelnummer=+artnr; SuchePreisl = window.open(uristr, Suchfenster, dependent=yes,width=500,height=200,scrollbars); SuchePreisl.focus(); } Hope this helps a little bit Franz -Ursprüngliche Nachricht- Von: Aaron Wolski [mailto:[EMAIL PROTECTED]] Gesendet: Dienstag, 10. September 2002 17:20 An: [EMAIL PROTECTED] Betreff: [PHP-DB] PHP in a javascript function with DB calls. Hi All, I HOPE this is the right place for this.. if not I am sorry!!! I'm hoping someone can put me on a clear path of how to do what I am asking here. I Have a shopping cart... and in this shopping cart I want to feature some items in a pop_up window when the user is ready to check out - if they are not already selected. For example.. Someone buy a Hockey Stick but don't buy hockey tape.. when when they go to check out.. I want a pop_up to be launched asking the user if they want to add Hockey tape to their order for onlu $$$. For this to happen I need to have an onLoad on the checkout page that calls a javascript function that has PHP code to find out IF a paritcular product is selected to see if the other has been selected too, if it's NOT selected then launch the pop_up. Does ANYONE have any idea's as to how this can be accomplished?? Anyhelp is appreciated thanks all. Aaron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] RFC: ODBC and PHP
To Whom It May Concern, I've been working for the last few months (delayed often, but mostly the last few weeks) on what I've been tenatively calling ODBC2. Basically this is what I'd like to see PHP v 5 have as it's default ODBC system. Some general notes about it: - It will break BC. I have tried to conform and keep things the same, but I'm not making any promises to keep BC at this time. - It will support ODBC v 3.0 and greater only. With the needs of many DBs to include larger typesets (like TEXT, NTEXT, IMAGE, etc) and UNICODE, I see this as being a necessity. Some implementation notes: - So far my testing is being done using iODBC, unixODBC, and Windows ODBC drivers. I have no way of checking any of the others... help on this front would be appriciated. Some of the features already added to it: - Ability to control the ODBC environment handles before and after a connection is created. - Ability to specify a CURSOR for use in statements. - More strongly enforced safe_mode restrictions. - The ability to connect to data sources without being defined locally. - A user can force the PHP system to create a new connection now. - An attempt to make the ODBC API look more like the MySQL/PostgreSQL APIs feature setwise. - An option for the user to turn on which can allow dynamic sizing of a result set text field (currently it's static). - Use of the default_user, default_db, and default_passwd in the php.ini. - Hopefully more detailed error messages. - Native support for returning results from functions, and SQL based constructs (outside of SELECT statements). If you have any specific functionality you would like to see, please send it to me, and I will see what I can do about adding this in. I would like to add this into the current PHP system, to allow users to start playing with and testing as well. Well probably just as soon as I finish some more of the odbc2_exec/odbc2_execute() cleanups. This code is not optimized in any way, shape, or form. It's not even believed to work with a lot of systems. Because of this, I would like to hear back commentary back on any suggested recourse from those who've done this already. Hopefully this will prove to be a useful change, and people will be happy :) As always send your comments to me. --- Dan KalowskyI'll walk a thousand miles just http://www.deadmime.org/~dankto slip this skin. [EMAIL PROTECTED]- Streets of Philadelphia, [EMAIL PROTECTED]Bruce Springsteen -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP-DEV] RFC: ODBC and PHP
Hi Dan, On 11/09/02, Dan Kalowsky [EMAIL PROTECTED] wrote: - It will support ODBC v 3.0 and greater only. With the needs of many DBs ... I would like to add this into the current PHP system, to allow users to start playing with and testing as well. Well probably just as soon as I finish some more of the odbc2_exec/odbc2_execute() cleanups. This code is I know this probably isn't the kind of comment you want just now, but... If this is to support ODBC v3+, why not call the functions odbc3_xxx instead of odbc2_xxx? I think this could help prevent some head-scratching a little later down the track. --Wez. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP-DEV] RFC: ODBC and PHP
On Wed, 11 Sep 2002, Wez Furlong wrote: I know this probably isn't the kind of comment you want just now, but... If this is to support ODBC v3+, why not call the functions odbc3_xxx instead of odbc2_xxx? I think this could help prevent some head-scratching a little later down the track. Well technically it's to move PHP's ODBC support further along. I've just been calling it ODBC2 locally here to make life easier when I talk to other people (as in v2 of the PHP ODBC lib). What I'm thinking I'd really like to see is ODBC move to PECL or something like that, to allow me to keep it in a different release schedule (as ODBC standards don't change that rapidly). But I've heard some complaints against such ideas, so I haven't pushed it (yet). Anyways naming convention can be changed very easily. --- Dan KalowskyI'll walk a thousand miles just http://www.deadmime.org/~dankto slip this skin. [EMAIL PROTECTED]- Streets of Philadelphia, [EMAIL PROTECTED]Bruce Springstreen -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP-DEV] RFC: ODBC and PHP
Hmm, is there no way to make the functions work with both odbc versions? Have an odbc_set_version(int) function that can set the version of odbc to use. The default can be version 3. This way, with the addition of a single function call, scripts can provide BC. Shane Dan Kalowsky wrote: To Whom It May Concern, I've been working for the last few months (delayed often, but mostly the last few weeks) on what I've been tenatively calling ODBC2. Basically this is what I'd like to see PHP v 5 have as it's default ODBC system. Some general notes about it: - It will break BC. I have tried to conform and keep things the same, but I'm not making any promises to keep BC at this time. - It will support ODBC v 3.0 and greater only. With the needs of many DBs to include larger typesets (like TEXT, NTEXT, IMAGE, etc) and UNICODE, I see this as being a necessity. Some implementation notes: - So far my testing is being done using iODBC, unixODBC, and Windows ODBC drivers. I have no way of checking any of the others... help on this front would be appriciated. Some of the features already added to it: - Ability to control the ODBC environment handles before and after a connection is created. - Ability to specify a CURSOR for use in statements. - More strongly enforced safe_mode restrictions. - The ability to connect to data sources without being defined locally. - A user can force the PHP system to create a new connection now. - An attempt to make the ODBC API look more like the MySQL/PostgreSQL APIs feature setwise. - An option for the user to turn on which can allow dynamic sizing of a result set text field (currently it's static). - Use of the default_user, default_db, and default_passwd in the php.ini. - Hopefully more detailed error messages. - Native support for returning results from functions, and SQL based constructs (outside of SELECT statements). If you have any specific functionality you would like to see, please send it to me, and I will see what I can do about adding this in. I would like to add this into the current PHP system, to allow users to start playing with and testing as well. Well probably just as soon as I finish some more of the odbc2_exec/odbc2_execute() cleanups. This code is not optimized in any way, shape, or form. It's not even believed to work with a lot of systems. Because of this, I would like to hear back commentary back on any suggested recourse from those who've done this already. Hopefully this will prove to be a useful change, and people will be happy :) As always send your comments to me. --- Dan Kalowsky I'll walk a thousand miles just http://www.deadmime.org/~dank to slip this skin. [EMAIL PROTECTED] - Streets of Philadelphia, [EMAIL PROTECTED] Bruce Springsteen -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Fw: [PHP-DB] whats wrong with my sql insert statement?
my input.html has errors in it. wrong form method=post action=input.php enctype=multipart/form-data correct form method=POST action=input.php strange thing is it used to work. anyhow thanks for the help. Nikos wrote: Try remove (;) at the end of the expresion, before quote (): VALUES ('$first_name','$location','$phone', '$blabla')...(;)... - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, September 10, 2002 4:38 AM Subject: Re: [PHP-DB] whats wrong with my sql insert statement? Thanks for your suggestions. first my /etc/php.ini register_globals = on second i made the change as you suggested and i added a [$blabla = truly random;] when the input.php is excuated, 'blabla' value is inserted into the table. '$first_name' is still left blank. this leads me to believe that '$first_name' is blank to start with! somehow the input.html gives input.php blank $first_name , $location . care to look at my input.html ? thanks alot. # ?php $db_name =cheese_catalog; $table_name = user; $blabla = bla bla; $connection = @mysql_connect(localhost,test,new0pass) or die(Couldn't Connect.); $db = @mysql_select_db($db_name, $connection) or die(Couldn't select database.); if (none_required==none_required) { $sql = INSERT INTO $table_name (first_name,location,phone,messages) VALUES ('$first_name','$location','$phone', '$blabla');; $result = @mysql_query($sql, $connection) or die(Error #. mysql_errno() . : . mysql_error()); include(input_added.html); } ? # Michael Hazelden wrote: Hi there, Two things: (a) in my experience - you should use single quotes in your query to surround the values and so you don't need to escape them either (e.g. '$first_name') and (b) Make sure register_globals is on - otherwise you need to use $_POST[first_name] Cheers, Michael. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: 10 September 2002 01:15 To: [EMAIL PROTECTED] Subject: [PHP-DB] whats wrong with my sql insert statement? Hi I am using redhat 7.3 with mysql-3.23.49-3 php-4.1.2-7.3.4 apache-1.3.23-11. I want to insert few values into a mysql table. This input.php sort works. it will add a new entray to the table but with blank values. What did I do wrong? # # # file name input.php ?php $db_name =cheese_catalog; $table_name = user; $connection = @mysql_connect(localhost,test,test) or die(Couldn't Connect.); $db = @mysql_select_db($db_name, $connection) or die(Couldn't select database.); if (none_required==none_required) { $sql = INSERT INTO $table_name (first_name,location,phone,messages) VALUES (\$first_name\,\$location\,\$phone\, \$messages\);; $result = @mysql_query($sql, $connection) or die(Error #. mysql_errno() . : . mysql_error()); include(input_added.html); } ? # # file name input.html # html head titleNew Record/title /head body pPlease fill out the following information:/p form method=post action=input.php enctype=multipart/form-data table width=100% border=0 cellspacing=3 cellpadding=3 tr td width=25%first_name:/td td width=75%input name=first_name type=text size=40 maxlength=255 value=/td /tr tr td width=25%location:/td td width=75%input name=location type=text size=40 maxlength=255 value=/td /tr tr td width=25%phone:/td td width=75%input name=phone type=text size=40 maxlength=255 value=/td /tr tr td width=25%messages:/td td width=75%input name=messages type=text size=40 maxlength=255 value=/td /tr tr td width=25%nbsp;/td td width=75% align=leftinput type=submit name=submit value=Enternbspinput type=reset name=reset/td /tr /table /form /body /html # # -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP-DEV] RFC: ODBC and PHP
On Tue, 10 Sep 2002, Shane Caraveo wrote: Hmm, is there no way to make the functions work with both odbc versions? Have an odbc_set_version(int) function that can set the version of odbc to use. The default can be version 3. This way, with the addition of a single function call, scripts can provide BC. This is a tricky question really. Theoretically, yes it should be possible to allow this. You may run into issues with some of the result sets, but the connections should still be the same. You couldn't really do it with a function like odbc_set_version, as my understanding of ODBC states you must declare which version type you are using at compile time. If you have some documentation stating otherwise, I'd be interested in reading it. The reality is, I don't know. All ODBC3 drivers should be able to utilize the deprecated functionality just fine, but the mapping is an unknown and dependent upon vendor implementation. Going the other way, of course, is not going to work. But I don't see a reason to keep such BC at this point. The problem with the current system can be seen with bugs in the result sets. The one area specifically mentioned above. Users are still going to ask Why doesn't my select work? while using NTEXT or something non-compliant. The CURSOR type cannot be changed with the current system. This in itself leads to a slower implementation, a (unnecessarily) larger memory footprint, and in DB2 systems a memory leak. Hey at least I haven't gone as drastic as I originally thought, and asked to drop support specific for things like DB2, Solid, Empress, etc, and only support multi-driver systems (unixODBC, i-ODBC, and Windows ODBC). :) Although I still think that would make the most sense and be the easiest to support on our end of things. --- Dan KalowskyI'll walk a thousand miles just http://www.deadmime.org/~dankto slip this skin. [EMAIL PROTECTED]- Streets of Philadelphia, [EMAIL PROTECTED]Bruce Springsteen -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP-DEV] RFC: ODBC and PHP
Ok, then I would be for ODBC 3 for PHP 5 as the standard. An ODBC 2 extension can be shuttled out to PECL for those who may need it. But for BC issues, there is still the nameing convention. I would personaly prefer that the odbc functions stay odbc_*, rather than to start iterating through odbc2...odbc3 and so forth. Don't know an easy solution right now. Shane Dan Kalowsky wrote: On Tue, 10 Sep 2002, Shane Caraveo wrote: Hmm, is there no way to make the functions work with both odbc versions? Have an odbc_set_version(int) function that can set the version of odbc to use. The default can be version 3. This way, with the addition of a single function call, scripts can provide BC. This is a tricky question really. Theoretically, yes it should be possible to allow this. You may run into issues with some of the result sets, but the connections should still be the same. You couldn't really do it with a function like odbc_set_version, as my understanding of ODBC states you must declare which version type you are using at compile time. If you have some documentation stating otherwise, I'd be interested in reading it. The reality is, I don't know. All ODBC3 drivers should be able to utilize the deprecated functionality just fine, but the mapping is an unknown and dependent upon vendor implementation. Going the other way, of course, is not going to work. But I don't see a reason to keep such BC at this point. The problem with the current system can be seen with bugs in the result sets. The one area specifically mentioned above. Users are still going to ask Why doesn't my select work? while using NTEXT or something non-compliant. The CURSOR type cannot be changed with the current system. This in itself leads to a slower implementation, a (unnecessarily) larger memory footprint, and in DB2 systems a memory leak. Hey at least I haven't gone as drastic as I originally thought, and asked to drop support specific for things like DB2, Solid, Empress, etc, and only support multi-driver systems (unixODBC, i-ODBC, and Windows ODBC). :) Although I still think that would make the most sense and be the easiest to support on our end of things. --- Dan Kalowsky I'll walk a thousand miles just http://www.deadmime.org/~dank to slip this skin. [EMAIL PROTECTED] - Streets of Philadelphia, [EMAIL PROTECTED] Bruce Springsteen -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] php-db-unsubscribe@lists.php.net
[EMAIL PROTECTED] Sincerely, Robert -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
FW: [PHP-DB] php-db-unsubscribe@lists.php.net
-Original Message- From: rdelgar [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 10, 2002 9:07 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] [EMAIL PROTECTED] [EMAIL PROTECTED] Sincerely, Robert -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php