Re: [PHP-DB] mysql query
Ethan, It's hard to tell from the code formatting in your email what the exact problem might be, but a few reasons that this might fail in PHP rather than when sent to MySQL with hardcoded values: 1. var_dump/print_r $_POST to see what you're getting as input is what you expect (and sanitize!). 2. Check that the SQL statement concatenation in PHP is building the string you're expecting. It looks like you're joining 2 strings when defining $sql2 that doesn't leave a space between the close parentheses and values. Compare this against what you're sending on the command line. 3. Get rid of all single quotes... escape your double quotes where needed. This will avoid any variable-in-string interpolation errors and may help you find the issue with input data. Same with your echo $sql2 statement... that's not going to give you the same thing as the print_r below it. Thanks, Daniel Krook Software Engineer, Advanced Cloud Solutions, GTS IBM Senior Certified IT Specialist - L3 Thought Leader The Open Group Certified IT Specialist - L3 Distinguished Cloud, Java, PHP, BlackBerry, DB2 Solaris Certified Ethan Rosenberg erosenb...@hygeiabiomedical.com wrote on 08/21/2013 07:48:12 PM: From: Ethan Rosenberg erosenb...@hygeiabiomedical.com To: PHP Database List php-db@lists.php.net Date: 08/21/2013 07:48 PM Subject: [PHP-DB] mysql query Dear List - I can't figure this out mysql describe Inventory; +-+-+--+-+-+---+ | Field | Type| Null | Key | Default | Extra | +-+-+--+-+-+---+ | UPC | varchar(14) | YES | | NULL | | | quant | int(5) | NO | | NULL | | | manuf | varchar(20) | YES | | NULL | | | item| varchar(50) | YES | | NULL | | | orderpt | tinyint(4) | NO | | NULL | | | ordrpt_flag | tinyint(3) | YES | | NULL | | | stock | int(3) | YES | | NULL | | +-+-+--+-+-+---+ Here are code snippets - $upc = $_SESSION['UPC']; $qnt = $_POST['quant']; $mnf = $_POST['manuf']; $itm = $_POST['item']; $odrpt = $_POST['oderpt']; $opf = $_POST['ordrpt_flag']; $stk= $_POST['stock']; $sql2 = insert into Inventory (UPC, quant, manuf, item, orderpt, ordrpt_flag, stock) .values ('$upc', $qnt,'$mnf','$itm', odrpt, 0, $stk); $result2 = mysqli_query(cxn, $sql2); echo '$sql2br /'; print_r($sql2); echo br /$upc $qnt $mnf $itm $odrpt $opf $stkkbr /; if (!$result2) die('Could not enter data: ' . mysqli_error()); The mysql query fails. I cannot figure out why. It works from the command line. TIA Ethan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql query
Ethan, What about: $result2 = mysqli_query(cxn, $sql2); Doesn't look like you're sending it a connection link as a variable ($cxn) and that's passed through as a literal? Thanks, Daniel Krook Software Engineer, Advanced Cloud Solutions, GTS IBM Senior Certified IT Specialist - L3 Thought Leader The Open Group Certified IT Specialist - L3 Distinguished Cloud, Java, PHP, BlackBerry, DB2 Solaris Certified Ethan Rosenberg erosenb...@hygeiabiomedical.com wrote on 08/21/2013 11:59:19 PM: From: Ethan Rosenberg erosenb...@hygeiabiomedical.com To: Daniel Krook/White Plains/IBM@IBMUS Cc: PHP Database List php-db@lists.php.net Date: 08/21/2013 11:59 PM Subject: Re: [PHP-DB] mysql query On 08/21/2013 11:30 PM, Daniel Krook wrote: Ethan, It's hard to tell from the code formatting in your email what the exact problem might be, but a few reasons that this might fail in PHP rather than when sent to MySQL with hardcoded values: 1. var_dump/print_r $_POST to see what you're getting as input is what you expect (and sanitize!). 2. Check that the SQL statement concatenation in PHP is building the string you're expecting. It looks like you're joining 2 strings when defining $sql2 that doesn't leave a space between the close parentheses and values. Compare this against what you're sending on the command line. 3. Get rid of all single quotes... escape your double quotes where needed. This will avoid any variable-in-string interpolation errors and may help you find the issue with input data. Same with your echo $sql2 statement... that's not going to give you the same thing as the print_r below it. Thanks, Daniel Krook Software Engineer, Advanced Cloud Solutions, GTS IBM Senior Certified IT Specialist - L3 Thought Leader The Open Group Certified IT Specialist - L3 Distinguished Cloud, Java, PHP, BlackBerry, DB2 Solaris Certified Ethan Rosenberg erosenb...@hygeiabiomedical.com wrote on 08/21/ 2013 07:48:12 PM: From: Ethan Rosenberg erosenb...@hygeiabiomedical.com To: PHP Database List php-db@lists.php.net Date: 08/21/2013 07:48 PM Subject: [PHP-DB] mysql query Dear List - I can't figure this out mysql describe Inventory; +-+-+--+-+-+---+ | Field | Type| Null | Key | Default | Extra | +-+-+--+-+-+---+ | UPC | varchar(14) | YES | | NULL | | | quant | int(5) | NO | | NULL | | | manuf | varchar(20) | YES | | NULL | | | item| varchar(50) | YES | | NULL | | | orderpt | tinyint(4) | NO | | NULL | | | ordrpt_flag | tinyint(3) | YES | | NULL | | | stock | int(3) | YES | | NULL | | +-+-+--+-+-+---+ Here are code snippets - $upc = $_SESSION['UPC']; $qnt = $_POST['quant']; $mnf = $_POST['manuf']; $itm = $_POST['item']; $odrpt = $_POST['oderpt']; $opf = $_POST['ordrpt_flag']; $stk= $_POST['stock']; $sql2 = insert into Inventory (UPC, quant, manuf, item, orderpt, ordrpt_flag, stock) .values ('$upc', $qnt,'$mnf','$itm', odrpt, 0, $stk); $result2 = mysqli_query(cxn, $sql2); echo '$sql2br /'; print_r($sql2); echo br /$upc $qnt $mnf $itm $odrpt $opf $stkkbr /; if (!$result2) die('Could not enter data: ' . mysqli_error()); The mysql query fails. I cannot figure out why. It works from the command line. TIA Ethan Daniel - Thanks. Tried all your suggestions. Sorry, no luck. Ethan
Re: [PHP-DB] Installing IBM DB2 drivers onto an Apache Server under Fedora 16 x64 to access IBM POWER7 DB2 via PHP....
Hi Charles, So you just need to get the Apache on Fedora configured to connect to the DB2 servers on AIX? This is a good a list to ask as any :) Here are the steps I would take (some of which you might have already done... so it's up to you whether you want to start fresh or tweak my instructions). This is based on RHEL / CentOS using DB2 v9.7, so it might be slightly different for you. (Sorry for the top post, it's easier to write this all up front.) 1. Download the DB2 Runtime Client. Based on the specs you mention, it would be: IBM Data Server Runtime Client (Linux AMD64 and Intel EM64T) ibm_data_server_runtime_client_linuxx64_v10.1.tar.gz (613 MB) 2. Install and configure the DB2 RC (I use 9.7, so modify this for 10.1): tar -xzvf ibm_data_server_runtime_client_linuxx64_v9.7.tar.gz cd rtcl echo no rsp.txt ./db2_install rsp.txt groupadd db2iadm1 useradd db2inst1 -g db2iadm1 /opt/ibm/db2/V9.7/instance/db2icrt -s client db2inst1 echo '. /home/db2inst1/sqllib/db2profile' /etc/sysconfig/httpd # Assuming yum install of httpd... otherwise put it in apachectl 2. Then either download the PHP and IBM DB2 extension source (instructions here: http://us.php.net/manual/en/ibm-db2.installation.php), or use Zend Server (which I recommend if you want to manage everything with yum, including the DB2 drivers). http://www.zend.com/en/products/server/downloads Install, then add the php-5.3-ibmdb2-zend-server extra package (you could also install the PDO one). 3. Catalog the remote system (optional... you'd just use a lengthier connection string in step 4) . /home/db2inst1/sqllib/db2profile db2 catalog tcpip node aixbox1 remote db2.example.com server 5 remote_instance db2inst1 ostype aix db2 catalog database sample as sample at node aixbox1 4. Test your connection from /var/www/html/index.php. $conn_resource = db2_connect($db2_name, $db2_user, $db2_pass); if ($conn_resource) { echo 'Connection to database succeeded.'; db2_close($conn_resource); } else { echo 'Connection to database failed.br /'; echo 'SQLSTATE: ' . db2_conn_error() . 'br /'; echo 'Message: ' . db2_conn_errormsg(). 'br /'; } Hope that gets you on the right track. Thanks, -Dan Daniel Krook, IBM L2 Certified IT Specialist Software Engineer, Advanced Cloud Technology, GTS, IBM Cloud Architecture, Java EE, PHP, BlackBerry, DB2 Solaris Certified Charles W Buege cbu...@moreycorp.com wrote on 05/11/2012 09:48:08 AM: From: Charles W Buege cbu...@moreycorp.com To: php-db@lists.php.net Date: 05/11/2012 09:52 AM Subject: [PHP-DB] Installing IBM DB2 drivers onto an Apache Server under Fedora 16 x64 to access IBM POWER7 DB2 via PHP All - I know that this topic only vaguely relates to this mailing list, but I thought I'd start here. If anyone has a better location for me to look at for this information, please feel free to tell me. Okay, here's my scenario. We are an IBM POWER7 shop and have several instances of Apache running on our POWER7 for customer information lookup, part ordering, etc. What I am attempting to do is setup a web server as a virtual machine in Fedora 16 as a front- end to all of these servers to perform the following tasks: - centralized access to all of the sites - a table of contents/central portal - a server that, when the POWER7 is down for backup and/or maintenance, it can provide a 'Temporarily Out Of Service' message to any users attempting to access these sites with a message of 'The system is down for (whatever the reason). It will be back up by (time).' - Another development/deployment platform other than our POWER7 for testing/learning/etc. since setting up a virtual host on Apache under Linux means that it is something that I can do instead of involving our POWER7 administrator since he is as busy as I am Here is what I have done so far. I've got the Apache running on the Fedora 16 box no problem. I'm getting good phpinfo() results, so all good there. I'm trying to follow IBM's instructions for getting DB2 drivers using the following sites: Setting up the PHP environment on Linux or UNIX - http:// publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic=% 2Fcom.ibm.swg.im.dbclient.php.doc%2Fdoc%2Ft0011926.html which lead me to this page to get the IBM Data Server Driver Package mentioned in bullet point three Download initial Version 10.1 clients and drivers - http:// www-01.ibm.com/support/docview.wss?uid=swg21385217 which I did download and that page sent me to here: Installing IBM Data Server Driver Package (Linux and UNIX) - http:// publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic=% 2Fcom.ibm.swg.im.dbclient.install.doc%2Fdoc%2Ft0054799.html where, after reading this page, I attempted to run the installDSDriver which apparently requires ksh to be installed to run so I downloaded
Re: [PHP-DB] PHP with a XML database
Hello Ritesh, Ritesh Nadhani [EMAIL PROTECTED] wrote on 01/26/2007 05:48:27 PM: Writing our own parsing thing is out of question. The group has finalised to use a proper DB rather then writing our own code. Moreover, we believe that the code written by a good DB engine would be much more efficient then writing our own module and we are no database experts :) So now its a question of which XML DB to use. After Christophers mail, we would give Oracle a run in next weeks. Lets see pureXML in DB2 v9 may be an option to explore. It treats XML as a native data type. You could load in the benchmark data XML and query it with SQL to get your reports. Look for the free Express-C edition and use the new PECL extension ibm_db2 (not the odbc_* functions). DB2 9: pureXML Guide http://www.redbooks.ibm.com/redpieces/abstracts/sg247315.html DB2 XML (pureXML) wiki http://www.ibm.com/developerworks/wikis/display/db2xml/Home DB2 Express-C http://www.ibm.com/software/data/db2/express/download.html Daniel Krook Content Tools Developer - SCSA, SCJP, SCWCD, ZCE Global Production Services - Tools, ibm.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] PDO prepared statement placeholders oddness (DB2)
Hello folks, I'm trying to pass an array of parameters to a statement I've prepared with '?' placeholders. For example (all columns are varchar 50): $sql = 'INSERT INTO SOME_TABLE (COL1, COL2, COL3) VALUES (?, ?, ?)' $params = array('val1', 'val2', 'val3'); I've achieved the results I want with other interfaces using the following code: Unified ODBC: $stmt = odbc_prepare($this-db, $sql); $result = odbc_execute($stmt, $params); The ibm_db2 extension: $stmt = db2_prepare($this-db, $sql); $result = db2_execute($stmt, $params); But I can't get either of the following to do the same with PDO: This fills all columns with 'val3': $stmt = $this-db-prepare($sql); $result = $stmt-execute($params); This fails with a segfault at bindValue (I can't be sure of the number of placeholders in $sql or how many values to manually bind from $params, so I do it in a loop (I've also tried a foreach)): $stmt = $this-db-prepare($sql); $size = count($params); for ($i = 0; $i $size; $i++) { echo $params[$i]; $stmt-bindValue($i + 1, $params[$i]); } $result = $stmt-execute(); This is PHP 5.1.2 on SLES 9. I don't see anything related in http://bugs.php.net/ Configure was ./configure --with-IBM_DB2 --with-pdo-odbc=ibm-db2,/home/db2inst1/sqllib --with-ibm-db2 --with-apxs2=/opt/IBMIHS/bin/apxs --enable-maintainer-zts Any thoughts? Thanks, -Dan Daniel Krook, Content Tools Developer Global Production Services - Tools, ibm.com http://bluepages.redirect.webahead.ibm.com/ http://blogpages.redirect.webahead.ibm.com/ http://bookmarks.redirect.webahead.ibm.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php