RE: [PHP-DB] Help in learning PHP and MySQL
Hi from php 5 onwards mysql is not enabled by default http://www.php.net/manual/en/ref.mysql.php Note: Windows users will need to enable php_mysql.dll inside of php.ini and either copy libmysql.dll into the Windows system directory, or make it available to the PATH. from memory... (To enable it, edit php.ini - find the reference to php_mysql.dll and remove the ; which comments it out ) Peter -Original Message- From: Novice Learner [mailto:[EMAIL PROTECTED] Sent: 31 December 2004 03:35 To: php-db@lists.php.net Subject: [PHP-DB] Help in learning PHP and MySQL I apologize if this is a very basic question. I just started learing PHP and MySQL, I am reading PHP and MySQL by Larry Ullman, I also have access to PHP 5 by Julie Meloni. I reached Chapter 6 of Ullman's book and got stuck. I have the following code: ?php //This file contains the database access information. This file also establishes a connection //to MYSQL and selects the database. //Set the database access information as constants define ('DB_USER', 'masud'); define ('DB_PASSWORD', 'masud'); define ('DB_HOST', 'localhost'); define ('DB_NAME', 'masud'); //Make the connection and then select the database $dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD); mysql_select_db(DB_NAME); ? I have a normal MySQL user as masud, whose password is also masud and a database also called masud. All this for learning purpose. I get the following error message: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\htdocs\CTA\mysql_connect.php on line 13 The books says: If you receive an error that claims mysql_connect() is an undefined function, it means that PHP has not been compiled with MySQL support. I have been running a test script with ? phpinfo(); ? and I get the results successfully. I am running Windows XP with Apache 2 server and PHP5 5.0.3 I would appreciate if you could help me in any way, including pointing me to resources that can help get going. Thank you, Masud - Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Help in learning PHP and MySQL
Janet and Peter, Thank you for your help. It worked and I was able to populate the database through the next script that was in the book. I am on my way to learning PHP and MySQL. I hope it also works on my web hosting servers in a few days time. Thank you again. My New Year is starting in a great way. Happy New Year to ALL. Masud Janet Valade [EMAIL PROTECTED] wrote: Novice Learner wrote: I apologize if this is a very basic question. I just started learing PHP and MySQL, I am reading PHP and MySQL by Larry Ullman, I also have access to PHP 5 by Julie Meloni. I reached Chapter 6 of Ullman's book and got stuck. I have the following code: //This file contains the database access information. This file also establishes a connection //to MYSQL and selects the database. //Set the database access information as constants define ('DB_USER', 'masud'); define ('DB_PASSWORD', 'masud'); define ('DB_HOST', 'localhost'); define ('DB_NAME', 'masud'); //Make the connection and then select the database $dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD); mysql_select_db(DB_NAME); ? I have a normal MySQL user as masud, whose password is also masud and a database also called masud. All this for learning purpose. I get the following error message: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\htdocs\CTA\mysql_connect.php on line 13 The books says: If you receive an error that claims mysql_connect() is an undefined function, it means that PHP has not been compiled with MySQL support. I have been running a test script with and I get the results successfully. This is correct. In your phpinfo output, look for MySQL support. If you find no mention of mysql in the output, it means mysql support is not activated. PHP support was included by default in PHP 4, but is not in PHP 5. I am running Windows XP with Apache 2 server and PHP5 5.0.3 With PHP 5, you have to activate it yourself. MySQL support is no longer supported by default. There are two steps: 1) In your php.ini file, you need to uncomment the extension line for mysql. If you are using MySQL 4.0 or older, uncomment the line for php_mysql.dll. If you are using MySQL 4.1 or higher, uncomment the line for php_mysqli.dll 2) PHP needs to be able to find two files: php_mysql.dll (or php_mysqli.dll) and libmysql.dll. If you installed from the zip file, you have both. If you installed using the installer, you need to download the zip file which contains these files. Copy both files into your System32 directory. Janet I would appreciate if you could help me in any way, including pointing me to resources that can help get going. Thank you, Masud - Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard. -- Janet Valade -- janet.valade.com - Do you Yahoo!? Jazz up your holiday email with celebrity designs. Learn more.
Re: [PHP-DB] Math and mySQL
Do you have the actual syntax for the SELECT command to retreive the last record? Ron - Original Message - From: Bastien Koert [EMAIL PROTECTED] To: [EMAIL PROTECTED]; php-db@lists.php.net Sent: Thursday, December 30, 2004 10:53 AM Subject: RE: [PHP-DB] Math and mySQL see intersperesed comments bastien From: Ron Piggott [EMAIL PROTECTED] To: PHP DB php-db@lists.php.net Subject: [PHP-DB] Math and mySQL Date: Thu, 30 Dec 2004 05:51:44 -0500 Is there any way of retreiving the last record of a mySQL table where I may specify one of the values in it? I know the SELECT command and just for example the field I know could be serial_number = 30612312-ABDEFG --- I have the serial_number field set as a varchar. yes, you can do a select on the table to get that record Part two of my question is how do you do math in PHP? I want to take the running_total (another field in the table) and add or subtract what the user has typed in. assign the value to a variable and simply add/substract/etc between the two values Ron -- 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