Wind River Support Network

HomeDefectsLIN5-5816
Fixed

LIN5-5816 : LAMP feature: php can not work with mysql

Created: Mar 27, 2013    Updated: Dec 19, 2017
Resolved Date: Apr 23, 2013
Found In Version: 5.0.1
Fix Version: 5.0.1.3
Severity: Severe
Applicable for: Wind River Linux 5
Component/s: Userspace

Description

The feature/LAMP includes:
mysql5 modphp phpmyadmin apache2 xdebug

But modphp doesn't work well with mysql:

1. browse http://192.168.201.15/php-mysql.php
php mysql testing
Fatal error: Call to undefined function mysqli_connect() in /usr/share/apache2/default-site/htdocs/php-my.php on line 4 

2. browse http://192.168.201.15/phpmyadmin/
phpMyAdmin - Error

The mysqli extension is missing. Please check your PHP configuration. <a href="Documentation.html#faqmysql" target="documentation"><img src="themes/dot.gif" title="Documentation" alt="Documentation" class="icon ic_b_help" /></a>

3. browse http://192.168.201.15/phpinfo.php
we get no section for Mysql, and the configure command:
Configure Command 	'/d_lamp_0326/bitbake_build/tmp/work/x86_64-wrs-linux/modphp-5.3.14-r4/php-5.3.14/configure' '--build=x86_64-linux' '--host=x86_64-wrs-linux' '--target=x86_64-wrs-linux' '--prefix=/usr' '--exec_prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--libexecdir=/usr/libexec' '--datadir=/usr/share' '--sysconfdir=/etc' '--sharedstatedir=/com' '--localstatedir=/var' '--libdir=/usr/lib64' '--includedir=/usr/include' '--oldincludedir=/usr/include' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--disable-silent-rules' '--disable-dependency-tracking' '--with-libtool-sysroot=/d_lamp_0326/bitbake_build/tmp/sysroots/qemux86-64' '--with-apxs2=/d_lamp_0326/bitbake_build/tmp/sysroots/qemux86-64/usr/bin/crossscripts/apxs' '--enable-maintainer-zts' '--without-mysql' '--enable-force-cgi-redirect' '--disable-cgi' '--disable-cli' '--disable-pdo' '--without-pear' '--without-iconv' '--disable-ipv6' '--disable-xml' '--disable-xmlreader' '--disable-xmlwriter' '--disable-simplexml' '--disable-libxml' '--disable-dom' '--disable-rpath' '--libdir=/usr/lib64/php5' '--with-zlib' '--with-zlib-dir=//d_lamp_0326/bitbake_build/tmp/sysroots/qemux86-64/usr' '--with-config-file-path=/etc/php/apache2-php5' '--without-pgsql' '--without-mysqli' 

Steps to Reproduce

1. configure with LAMP:
$ /git/wrlinux0727/wrlinux/configure --enable-board=qemux86-64 --enable-rootfs=glibc-std --enable-kernel=standard --enable-jobs=4 --enable-parallel-pkgbuilds=4 --enable-patchresolve=noop --with-template=feature/LAMP

2. $ make fs

3. start-target:
$ sudo make start-target TOPTS="-t -in 1"

4. start mysql and create example databas:
root@qemu1:~# /usr/bin/mysqld_safe --user=mysql &
[1] 1736
root@qemu1:~# 130401 02:44:06 mysqld_safe Logging to '/var/log/mysqld.err'.
130401 02:44:06 mysqld_safe Starting mysqld daemon with databases from /var/mysql

root@qemu1:~# /usr/bin/mysqladmin -u root password root
root@qemu1:~# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.40 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.02 sec)

mysql> create database mysql_test;
Query OK, 1 row affected (0.02 sec)

mysql> use mysql_test;
Database changed

mysql> create table shop
    ->           (article  INT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL, \
    ->           dealer CHAR(20) DEFAULT '' NOT NULL, \
    ->           price DOUBLE(16,2) DEFAULT '0.00' NOT NULL, \
    ->           PRIMARY KEY(article, dealer));
Query OK, 0 rows affected (0.03 sec)

mysql> INSERT INTO shop VALUES \
    ->         (1,'A',3.45),(1,'B',3.99),\
    ->          (2,'A',10.99),(3,'B',1.45),(3,'C',1.69),\
    ->         (3,'D',1.25),(4,'D',19.95);
Query OK, 7 rows affected (0.03 sec)
Records: 7  Duplicates: 0  Warnings: 0

mysql> select * from shop ;
+---------+--------+-------+
| article | dealer | price |
+---------+--------+-------+
|    0001 | A      |  3.45 |
|    0001 | B      |  3.99 |
|    0002 | A      | 10.99 |
|    0003 | B      |  1.45 |
|    0003 | C      |  1.69 |
|    0003 | D      |  1.25 |
|    0004 | D      | 19.95 |
+---------+--------+-------+
7 rows in set (0.00 sec)

mysql> \q
Bye

5. change in /etc/php/apache2-php5/php.ini
display_errors = On
display_startup_errors = On
track_errors = On
error_log = /var/log/apache2/logs/php_errors.log

6. Create php script with name phpinfo.php in /usr/share/apache2/default-site/htdocs/:
   <?php
    phpinfo();
   ?>
7. Create php script read data from MySQL database name php-mysql.php
<?php
 echo "<br>php mysql testing:<br>\n";
 // Connecting, selecting database
 $link = mysqli_connect('localhost', 'root', 'root');
 echo "Connected successfully<br><br>\n";
 mysqli_select_db($link, 'mysql_test') or die('Could not select database');

 // Performing SQL query
 $query = 'SELECT * FROM shop';
 $result = mysqli_query($link, $query) or die('Query failed: ' . mysqli_error());

 // Printing results in HTML
 echo "<table>\n";
 echo "\t<tr>\n";
 echo "\t\t<td>article</td>\n";
 echo "\t\t<td>dealer</td>\n";
 echo "\t</tr>\n";

 while ($line = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
     echo "\t<tr>\n";
     foreach ($line as $col_value) {
         echo "\t\t<td>$col_value</td>\n";
     }
     echo "\t</tr>\n";
 }
 echo "</table>\n";

 // Free resultset
 mysqli_free_result($result);

 // Closing connection
 mysqli_close($link);

?>

8. restart apache2:
# /etc/init.d/apache2 restart

9. in a browser:
http://192.168.201.15/php-mysql.php
http://192.168.201.15/phpmyadmin/  and use root/root to login
http://192.168.201.15/phpinfo.php

refer to the steps in:
http://git.wrs.com/cgi-bin/cgit.cgi/wrlinux-x/tree/Documentation.ND/Packages/apache-ssl-php-mysql_README_TESTING

Other Downloads


Live chat
Online