[PHP-DB] Multiple result sets with a prepared statement in mysqli
I am trying to use mysqli's prepared statements to execute a stored procedure that returns multiple result sets. I've been struggling with this for some time now. I have created a short example test script that demonstrates the problem. The script can be found here: http://pastebin.com/YZtDCNMF This code is how I expect mysqli to handle this scenario. However, I get a warning on line 31 that the number of bind variables doesn't match the number of fields in the prepared statement. This means that the second result was not fetched by the call on line 29. Any help on this issue would be greatly appreciated! Also, I'm using the packaged version of PHP that comes on Ubuntu 10.04 (5.3.2). Thanks, Ken -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Recommended web developers
I'm a little surprised no one else has commented on this, but for a website that complicated, 10k is way too low. I've done work on websites that do almost all of those things separately, but not combined and I can tell you to have a high quality website that does just one of the things you mention will cost you about 10k. This is very much a guess because something like Blogging can be done very simply (cheaply). But it will not have even close to the feature set of the major blogging sites. In fact, I just wrapped up a project that was a simple business directory last month for 5k. Again, that site was *simple* and no where near as flexible as the code you see from yahoo or google. There is a reason those companies pay hundreds of developers 80k a year... Sorry to rain on your parade. Hopefully you just left out a 0 or two... Ken On Tue, Jun 24, 2008 at 10:00 AM, A. Joseph [EMAIL PROTECTED] wrote: Which company in India or USA can you recommend to design a complex website for my company. The site will be a social site, will include, Blog, Articles, Shops, Music, Movie, Directory, Pre-paid card system, Culture and Tourism, downloads, file upload and sharing The site is just like yahoo, but no email service. Advert method will be like Google Ads PHP 5 MySql, Smarty, SOAP Service, Ajax, Javascript, div based, Apache with mod_rewrite Admin Area, Users area, front end Full detail will be available Planned amount is $1 Max -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Naturally, the common people don't want war, but they can always be brought to the bidding of the leaders. Tell them they are being attacked, and denounce the pacifists for lack of patriotism and endangering the country. It works the same in every country. --- Herman Goering, Hitler's Reichsmarschall, At the Nuremberg Trials -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] PHP to MS SQL Package
Alice, make sure the php-mssql package is installed. # yum install php-mssql You shouldn't have to compile php or freetds as there are packages available to do what you want... Ken On Thu, Jun 12, 2008 at 11:14 AM, Wei, Alice J. [EMAIL PROTECTED] wrote: Hi, I am currently using a Linux box with Fedora 9.0 and I am trying to connect PHP to a MS SQL database. All the permissions on the MS SQL database is up to date and accurate, but I consistently get errors that say PHP Fatal error: Call to undefined function mssql_connect() in /usr/local/apache/htdocs/create_new_entry_master.php on line 20 I have looked into the options of using FreeBSD, as suggested on the http://us3.php.net/manual/en/function.mssql-connect.php#83196, but I am not sure if I could use it since I don't use a Windows Machine to run my PHP. Does anyone have any suggestions? Alice == Alice Wei MIS 2009 School of Library and Information Science Indiana University Bloomington [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Naturally, the common people don't want war, but they can always be brought to the bidding of the leaders. Tell them they are being attacked, and denounce the pacifists for lack of patriotism and endangering the country. It works the same in every country. --- Herman Goering, Hitler's Reichsmarschall, At the Nuremberg Trials -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] PHP to MS SQL Package
Make sure some where in your php.ini you have a line that looks like this and is not commented out: extension=mssql.so I haven't used a fedora box as a php webserver in over a year, so my memory of their config file layout is pretty rusty. However, I'm pretty sure they consolidate everything into a single .ini file. I always add a phpinfo.php file to my project so I can run it and see which .ini file apache is using to configure php. All you have to put in the phpinfo.php file is this line: ?php phpinfo(); ? If you visit that page and look around, it will tell you where the php.ini file is. Also, once you have mssql enabled, there will be a section in the phpinfo.php page with all the mssql options. So, looking at the phpinfo.php file is another good way to tell if you have mssql installed properly. Good luck! Ken On Thu, Jun 12, 2008 at 12:58 PM, Wei, Alice J. [EMAIL PROTECTED] wrote: From: Ken Keefe [EMAIL PROTECTED] Sent: Thursday, June 12, 2008 1:44 PM To: Wei, Alice J. Cc: php-db@lists.php.net Subject: Re: [PHP-DB] PHP to MS SQL Package Alice, make sure the php-mssql package is installed. # yum install php-mssql You shouldn't have to compile php or freetds as there are packages available to do what you want... I have just installed this gadget as you have listed, and then I have . The problem is that this does not get rid of what I had in my errors previously. PHP Fatal error: Call to undefined function mssql_connect() in /usr/local/apache/htdocs/create_new_entry_master.php on line 20 Code snippet: // connection to the database $dbhandle= mssql_connect($myServer, $myUser, $myPass) or die(Couldn't connect to SQL Server on $myServer); Ken On Thu, Jun 12, 2008 at 11:14 AM, Wei, Alice J. [EMAIL PROTECTED] wrote: Hi, I am currently using a Linux box with Fedora 9.0 and I am trying to connect PHP to a MS SQL database. All the permissions on the MS SQL database is up to date and accurate, but I consistently get errors that say PHP Fatal error: Call to undefined function mssql_connect() in /usr/local/apache/htdocs/create_new_entry_master.php on line 20 I have looked into the options of using FreeBSD, as suggested on the http://us3.php.net/manual/en/function.mssql-connect.php#83196, but I am not sure if I could use it since I don't use a Windows Machine to run my PHP. Does anyone have any suggestions? Alice == Alice Wei MIS 2009 School of Library and Information Science Indiana University Bloomington [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Naturally, the common people don't want war, but they can always be brought to the bidding of the leaders. Tell them they are being attacked, and denounce the pacifists for lack of patriotism and endangering the country. It works the same in every country. --- Herman Goering, Hitler's Reichsmarschall, At the Nuremberg Trials -- Naturally, the common people don't want war, but they can always be brought to the bidding of the leaders. Tell them they are being attacked, and denounce the pacifists for lack of patriotism and endangering the country. It works the same in every country. --- Herman Goering, Hitler's Reichsmarschall, At the Nuremberg Trials -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] PHP to MS SQL Package
That error message tells you that you are getting closer. Next step would be to make sure you have a connection to that system: $ ping 192.168.10.128 Next thing I would do is see if that port is open on the server: $ telnet 192.168.10.128 1433 If it says something about Escape character is ... then the SQL server is listening and no firewalls or anything are getting in the way. Finally, you probably need to add an entry at the bottom of your /etc/freetds/freetds.conf file that looks like this: [SomeNameForTheServer] host = 192.168.10.128 port = 1433 tds version = 8.0 Then, in your php code, use the name you give (SomeNameForTheServer) as the host instead of the IP address. Good luck. Ken On Thu, Jun 12, 2008 at 3:53 PM, Wei, Alice J. [EMAIL PROTECTED] wrote: Hi, I hope this would allow me to address this problem to a step further now. After getting FreeTDS installed, my error has now moved away from the undefined function level. I have looked through the PHP help from http://us3.php.net/manual/en/function.mssql-connect.php, and configured according to what has been listed in the user commentsThis is my error now: PHP Warning: mssql_connect(): Unable to connect to server: 192.168.10.128 in /usr/local/apache/htdocs/test.php on line 22 As some of you suggested, I find it surprising that after installing FreeTDS and referencing it when I was installing it using --with-sybase=/usr/local/freetds option when I installed the PHP, it kept on bringing me back errors saying that it cannot find it. I am not sure if it is the cause of why I still cannot connect. As for my php.info, I tried to run the search to find mssql values, but I cannot find any. Is this the reason why I still cannot connect to a different machine to its MS SQL using PHP? Have I missed something in my setup or something? Note: The setup for the database is accessible by another computer using the same server passwords, etc. I welcome any suggestions on t his. Alice == Alice Wei MIS 2009 School of Library and Information Science Indiana University Bloomington [EMAIL PROTECTED] From: Olavi ivask [EMAIL PROTECTED] Sent: Thursday, June 12, 2008 2:20 PM To: Wei, Alice J. Cc: php-db@lists.php.net Subject: RE: [PHP-DB] PHP to MS SQL Package Hello, Here is a good article about ms-sql PHP on Linux (http://www.devarticles.com/index2.php?option=contenttask=viewid=667pop=1page=0hide_js=1) Olavi Ivask On Thu, 2008-06-12 at 13:43 -0400, Wei, Alice J. wrote: Hi, After stopping the Apache server, I reinstalled PHP by adding the line you had below, and then restarted Apache. ./configure --with-apxs2=/usr/local/apache/bin/apxs \ --with-sybase=/usr/local/freetds --prefix=/usr/local/apache/php \ make make install After this has been completed, I am still getting the same error about how the function is not defined. Fatal error: Call to undefined function mssql_connect() in /usr/local/apache/htdocs/create_new_entry_master.php on line 20 Could there be other options? Or, am I missing something here? Alice == Alice Wei MIS 2009 School of Library and Information Science Indiana University Bloomington [EMAIL PROTECTED] From: Olavi ivask [EMAIL PROTECTED] Sent: Thursday, June 12, 2008 12:57 PM To: Wei, Alice J. Cc: php-db@lists.php.net Subject: Re: [PHP-DB] PHP to MS SQL Package Hi, you need to install freetds before compiling php. compile php: ./configure [--with-apxs --with-mysql...] --with-sybase=/usr/local/freetds make make install Olavi Ivask On Thu, 2008-06-12 at 12:14 -0400, Wei, Alice J. wrote: Hi, I am currently using a Linux box with Fedora 9.0 and I am trying to connect PHP to a MS SQL database. All the permissions on the MS SQL database is up to date and accurate, but I consistently get errors that say PHP Fatal error: Call to undefined function mssql_connect() in /usr/local/apache/htdocs/create_new_entry_master.php on line 20 I have looked into the options of using FreeBSD, as suggested on the http://us3.php.net/manual/en/function.mssql-connect.php#83196, but I am not sure if I could use it since I don't use a Windows Machine to run my PHP. Does anyone have any suggestions? Alice == Alice Wei MIS 2009 School of Library and Information Science Indiana University Bloomington [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Naturally, the common people don't want war, but they can always be brought to the bidding of the leaders. Tell them they are being attacked, and denounce the pacifists for lack of patriotism and
Re: [PHP-DB] Question on PHP connect MS SQL 2005
I know the package you need is called php-sybase in ubuntu. It's probably something similar in Fedora. Know that this package will only let you do a subset of the mssql function calls. If you are just connecting and doing a normal query, it will suffice. If you need to do prepared statements for stored procedures, you will likely have to compile a php-mssql package manually. I just did this last night on my ubuntu server to get some stored procedures working. Hope that helps. Ken On Wed, Jun 11, 2008 at 8:52 AM, Wei, Alice J. [EMAIL PROTECTED] wrote: Hi, This may sound really stupid, but I installed Fedora and checked on the box for web development to allow PHP and other web scripts on the platform. Therefore, I could run PHP scripts fine, and the mentioning of this file, would you be able to offer me suggestions on where it might be? Thanks for your help. Alice == Alice Wei MIS 2009 School of Library and Information Science Indiana University Bloomington [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Naturally, the common people don't want war, but they can always be brought to the bidding of the leaders. Tell them they are being attacked, and denounce the pacifists for lack of patriotism and endangering the country. It works the same in every country. --- Herman Goering, Hitler's Reichsmarschall, At the Nuremberg Trials -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Alternative for MySQL Admin tools
Unfortunately it is windows only (written with .NET). When I was stuck on a windows box, it was a very nice tool. I'd use it now if it existed on other platforms... Ken On Thu, May 1, 2008 at 9:30 AM, Yves Sucaet [EMAIL PROTECTED] wrote: Just like to point out http://www.sqlyog.com, an alternative stand-alone desktop tool to manage you MySQL servers. The free community edition is very good! I've been using it for 3 years now and never had to need to install anything else or additional. HTH, Yves -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Why $row is EMPTY
Try doing print_r($row); in your while loop and see what exactly is in that array. Ken On Tue, Apr 29, 2008 at 1:46 PM, Jon L. [EMAIL PROTECTED] wrote: I could be wrong, but I don't think table aliases continue to exist in PHP; only the column names. $g_name = $row[gigName]; $vname = $row[venueName]; $genre = $row[name]; You may also consider revising the query to only grab the columns you need, using an alias for at least genre.name. $query = 'SELECT gig.gigName AS gig, venue.venueName AS venue, genre.name AS genre FROM `gig` LEFT JOIN genre ON gig.genreId=genre.genreId LEFT JOIN venue ON gig.venueID = venue.vid where gig.gigid = '.$gigDetail.' ORDER BY gig.gigid'; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array($result)) { echo Program is in While loop; $g_name = $row[gig]; $vname = $row[venue]; $genre = $row[genre]; echo(Gig Name: .$g_name); } - Jon L. On Tue, Apr 29, 2008 at 1:27 PM, Nasreen Laghari [EMAIL PROTECTED] wrote: Hi, Why my program is not going in while loop? When I run the same query in SQL cmd, it brings result but here when I print $result gives Resouce ID number means $result has data then why $row is empty. $query = 'SELECT * FROM `gig` LEFT JOIN genre ON gig.genreId=genre.genreId LEFT JOIN venue ON gig.venueID = venue.vid where gig.gigid = '.$gigDetail.' ORDER BY gig.gigid'; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array($result)) { echo Program is in While loop; $g_name = $row[gig.gigName]; $vname = $row[venue.venueName]; $genre = $row[genre.name]; echo(Gig Name: .$g_name); } Regards Nasreen Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Multiple prepared statements and preparing a stored procedure...
Is it possible to have multiple prepared statements associated with a single mysqli object at one time? For example: $db = new mysqli($sqlServer, $sqlUser, $sqlPass, $sqlDB); $query1 = $db-prepare($sql1); $query2 = $db-prepare($sql2); foreach ($arr as $key = $val) if($val) { $query1-bind_param(s, $key); $query1-execute(); } else { $query2-bind_param(s, $key); $query2-execute(); } $query1-close(); $query2-close(); Also, is there any benefit to using a prepared statement to call a stored procedure? If so, how do I prepare another statement after the stored procedure? I keep getting an error about being out of sync... Thanks, Ken -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php