Home > Backend Development > PHP Tutorial > Database related issues_PHP tutorial

Database related issues_PHP tutorial

WBOY
Release: 2016-07-21 16:11:01
Original
750 people have browsed it


Database Related Issues
This section will discuss the most common issues between PHP and databases. It is an exaggeration to say that PHP can operate almost all databases on the market today.
1. I heard that PHP can operate Microsoft SQL Server. What should I do?
2. Can I operate Microsoft Access database?
3. I upgraded to PHP 4, and now my mysql always Tell me: "Warning: MySQL: Unable to save result set in ...". What's going on?
4. After installing shared mysql support, Apache dumps core as soon as libphp4.so is installed. This problem Can it be fixed?
5. Why do I always get error messages like this: : "Warning: 0 is not a MySQL result index in on line " or "Warning: Supplied argument is not a valid MySQL result resource in on line ?
1. I heard that PHP can operate Microsoft's SQL Server. What should I do?
On the Windows platform, you just need to use the package. The included ODBC driver is sufficient.
Under the Unix platform, you can use the Sybase-CT driver to operate Microsoft SQL Servers because their protocols (at least most products) are fully compatible. Sybase has A free version for Linux systems. For other Unix systems, you may need to contact Sybase to get the correct library files. You can also refer to the answers to some questions below
2. Can I operate a Microsoft Access database? ?
Yes. If you are running under Windows 9x/Me, or NT/2000, you already have all the necessary tools.
You can use ODBC and Microsoft's ODBC drivers for Microsoft Access databases. If you are running PHP under Unix and want to communicate with MS Access under Windows, you need Unix ODBC drivers. OpenLink Software provides a Unix-based ODBC driver. You can download a trial (not expired) pilot program and a commercial version. The price is set at $675
Another way is to use SQL server with Windows ODBC driver to store the data, and then you can use Microsoft Access (ODBC) and PHP (built-in SQL Server driver) to operate this library. Or use another file format that both Access and PHP can open, such as operating system files or dBase databases. Tim Hayes of OpenLink software wrote the following about this: It's not a good idea to use another library as middleware in a database that you can use PHP to directly manipulate.
--For example, use OpenLink's driver. If you really need a middleware library, OpenLink has now released Virtuoso (virtual database engine), which can run on NT, Linux and other unix platforms.
Please refer to the website for free download.


Another successful example is to use Mysql under Windows (via mysql ODBC) to synchronize Access databases. Steve Lawrence wrote:

Follow the Mysql instructions to install your Mysql under the platform. The latest version can be obtained from http://www.mysql.com/ (from your nearest mirror point!). No other special configuration is required except setting up a Mysql database. To set up user accounts, you should Set the user's host domain to "%", confirm your server name, database name, etc.
Search the Mysql website for the Mysql ODBC driver. The latest version should be myodbc-2_50_19-win95.zip (NT). Install it on your Windows machine. You can test whether the installation was successful using the tools in the toolkit.
Create a user and system dsn in your ODBC Manager (in Control Panel). Create a DSN name, enter your host name, user name (mysql), password, port number, and other data you set in the first step.
Completely install Access. This step allows you to install the necessary tool drivers. At least you need to manage the connected database tables.
Now the most interesting thing happens! Create a new Access database. Right-click in the table and select "link Tables", or under the "File" menu, select "Get External Data" and then "Link Tables". When the dialog box opens, Select the file type: ODBC. Select the system DSN, the DSN name you created in step 3. Then select the table to be linked. Press "OK", oh! You can now open this table in your MySQL manager and add/edit/delete data! You can also create queries, import/export tables to MySQL, create forms and reports, etc.

Tips and Tricks:

You can create an Access table, export it to MySQL, or link it back. It will make creating the table faster.
When you create a table in Access , a primary key must be set. Similarly, when connecting to access in Mysql, there must also be a primary key.
If you select a table in MySQL, you have to relink it in Access. Go to >add-ins>Linked Table Manager

3. I upgraded to PHP 4, and now my mysql always tells me: "Warning: MySQL: Unable to save result set in ...". What is going on?
Most of these problems are due to the PHP 4 compilation option '--with-mysql' The path to your Mysql is not indicated. This way PHP will use its built-in MySQL library. If your system runs on such a platform, PHP 3 as the Apache module, or auth-mysql, which uses another version of the MySQL driver, so that two different versions of MySQL There will be conflicts on the client driver.
Recompile PHP 4, add Mysql path information, '--with-mysql=/your/path/to/mysql' can usually solve this problem.
4. After installing shared mysql support, Apache dumps core as soon as libphp4.so is loaded. Can this problem be fixed?
This will happen if your Mysql is connected using pthreads. Please use ldd. If used, grab the MySQL tarball and recompile, or compile from source rpm and remove the switch that enables threaded client code in the relevant files. If the above two methods cannot fix this error, then recompile the new PHP library to support the new Mysql.
5. Why do I always get this error message: : "Warning: 0 is not a MySQL result index in on line " or "Warning: Supplied argument is not a valid MySQL result resource in on line ?
You The result set variable value being used is 0. 0 means that your query failed for some reason. Before you get the result set, you must check the reason why the submitted query failed. The correct way to write it is as follows: $result = mysql_query( "SELECT * FROM tables_priv");
if (!$result) {
echo mysql_error();
exit;
}

or $result = mysql_query("SELECT * FROM tables_priv")
or die("Bad query: ".mysql_error());

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/314064.htmlTechArticleDatabase related issues This section will discuss the most common issues between PHP and databases. It is an exaggeration to say that PHP can operate almost all databases on the market today. 1. I heard that PHP can be used...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template