Archive for the ‘mysql’ Category

mysql_error() not displaying error

Friday, May 22nd, 2009 by dreamluverz

Error: mysql_error() not displaying error,
Solution:
possible cause is if u got 2 connections, u must supply the connection ur using





Which is best for monetary data: double, float, decimal

Friday, May 22nd, 2009 by dreamluverz




For floating-point data types, MySQL uses four bytes for single-precision values and eight bytes for double-precision values.

The FLOAT and DOUBLE data types are used to represent approximate numeric data values. For FLOAT the SQL standard allows an optional specification of the precision (but not the range of the exponent) in bits following the keyword FLOAT in parentheses. MySQL also supports this optional precision specification, but the precision value is used only to determine storage size. A precision from 0 to 23 results in a four-byte single-precision FLOAT column. A precision from 24 to 53 results in an eight-byte double-precision DOUBLE column.

MySQL allows a non-standard syntax: FLOAT(M,D) or REAL(M,D) or DOUBLE PRECISION(M,D). Here, “(M,D)” means than values can be stored with up to M digits in total, of which D digits may be after the decimal point. For example, a column defined as FLOAT(7,4) will look like -999.9999 when displayed. MySQL performs rounding when storing values, so if you insert 999.00009 into a FLOAT(7,4) column, the approximate result is 999.0001.

MySQL treats DOUBLE as a synonym for DOUBLE PRECISION (a non-standard extension). MySQL also treats REAL as a synonym for DOUBLE PRECISION (a non-standard variation), unless the REAL_AS_FLOAT SQL mode is enabled.

For maximum portability, code requiring storage of approximate numeric data values should use FLOAT or DOUBLE PRECISION with no specification of precision or number of digits.

The DECIMAL and NUMERIC data types are used to store exact numeric data values. In MySQL, NUMERIC is implemented as DECIMAL. These types are used to store values for which it is important to preserve exact precision, for example with monetary data.

As of MySQL 5.0.3, DECIMAL and NUMERIC values are stored in binary format. Previously, they were stored as strings, with one character used for each digit of the value, the decimal point (if the scale is greater than 0), and the “-” sign (for negative numbers). See Chapter 23, Precision Math.

When declaring a DECIMAL or NUMERIC column, the precision and scale can be (and usually is) specified; for example:

salary DECIMAL(5,2)

In this example, 5 is the precision and 2 is the scale. The precision represents the number of significant digits that are stored for values, and the scale represents the number of digits that can be stored following the decimal point. If the scale is 0, DECIMAL and NUMERIC values contain no decimal point or fractional part.

Standard SQL requires that the salary column be able to store any value with five digits and two decimals. In this case, therefore, the range of values that can be stored in the salary column is from -999.99 to 999.99. MySQL enforces this limit as of MySQL 5.0.3. Before 5.0.3, on the positive end of the range, the column could actually store numbers up to 9999.99. (For positive numbers, MySQL 5.0.2 and earlier used the byte reserved for the sign to extend the upper end of the range.)

In standard SQL, the syntax DECIMAL(M) is equivalent to DECIMAL(M,0). Similarly, the syntax DECIMAL is equivalent to DECIMAL(M,0), where the implementation is allowed to decide the value of M. MySQL supports both of these variant forms of the DECIMAL and NUMERIC syntax. The default value of M is 10.

The maximum number of digits for DECIMAL or NUMERIC is 65 (64 from MySQL 5.0.3 to 5.0.5). Before MySQL 5.0.3, the maximum range of DECIMAL and NUMERIC values is the same as for DOUBLE, but the actual range for a given DECIMAL or NUMERIC column can be constrained by the precision or scale for a given column. When such a column is assigned a value with more digits following the decimal point than are allowed by the specified scale, the value is converted to that scale. (The precise behavior is operating system-specific, but generally the effect is truncation to the allowable number of digits.)

source: http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html

Protected: dad

Tuesday, May 19th, 2009 by dreamluverz

This post is password protected. To view it please enter your password below:


Error installing apache,php on windows vista

Thursday, March 26th, 2009 by dreamluverz

I’ve done this before, I’ve installed it several times but how come this time it’s not working with the same settings that needed to be changed… a moment of confusion, annoyance and craziness flashed on my eyes. I’ve exerted every bit of energy left in my body, wasted every precious moment of my time, tried and checked every possible way to no luck at all!!!

What have I done wrong was all I can say. I can’t make Apache 2.2 and PHP 5.2 run on my notebook. A moment of silence…then I realized that whatever changes I’ve made on the php test file was not being reflected on the browser. I then again checked the path on the config files but everything was correct.

Btw, I was using php editor to modify the config files for I have read on some forums that you won’t be able to edit it with notepad in windows vista environment but you can with any php editors. Realizing that, I viewed the files using windows explorer if the changes I’ve made was reflected. Behold it’s not!!! Then I remembered another thing  mentioned on that thread that it’s because of the UAC (User Account Control) setting which you can find in Control Panel => User Accounts. Then right away I  turned it OFF, restarted the computer and re-opened the config files for apache(httpd.conf) and php(php.ini), applied the settings, saved it and problem solved!!! What a nightmare!!!

So first and foremost before installing apache or php always check your operating system if you’re running on windows vista environment which has some user settings that will make you CRAZY!!! :P

You can check the installation guide of apache 2.2, php 5.2 and mysql 5 for windows here. Goodluck! :P

Installing apache 2.2, php 5.2 and mysql 5 in windows vista

Thursday, March 26th, 2009 by dreamluverz

Here’s a quick guide for installing apache 2.2, php 5.2 and mysql 5 in windows vista.

Download needed files:
1. Apache – msi file
2. PHP – better choose the zip file than the msi installer
3. MYSQL – msi file
4. Create a folder on where you want your files to be placed. ie. C:\WEB

Before you proceed make you’re have turned off the UAC (User Account Control) setting  or else you’ll be on a big trouble.

A. Installing APACHE

Run the installer and just simply follow the instructions there and choose the option to run it as a service for your convenience. For the server name you can just put localhost. To make sure you’ve installed it properly open your browser and type http://localhost or http://your_computer_name and you will see a message saying IT WORKS!

B. Installing PHP

Unzip the files on the folder you’ve created on #4 which is C:\WEB. And that’s it.

C. Configuring APACHE and PHP settings

APACHE - Open httpd.conf on Apache Software Foundation/Apache2.2/conf/ and have the following settings below: TAKE NOTE OF THE FORWARD SLASH “/”.

1. Locate LoadModule and add these lines below:

  • LoadModule php5_module “C:/WEB/PHP/php5apache2_2.dll” - (Make sure you have the correct path and the name of the dll file or else you’ll encounter the error mentioned on the last part of this guide)
  • PHPIniDir “C:/WEB/PHP – (Location of your PHP mentioned on #4 )

2. Locate and uncomment the following:

  • ServerName localhost:80
  • LoadModule rewrite_module modules/mod_rewrite.so – optional, uncomment if you’ll be using mod_rewrite

3. Locate and change the path of the following lines to the folder you’ve created on #4.

  • DocumentRoot “C:/WEB”
  • <Directory “C:/WEB”>

4.  Locate and add the following

  • locate AddType and add  this line   AddType application/x-httpd-php .php
  • locate DirectoryIndex index.html  and index.php

5. Modify the following

  • Locate for <Directory “C:/WEB”> – the one you’ve just modified, the location of your files. Below it you will find Allowoverride None change it to Allowoverride All to be able to use htaccess file. - optional
  • Locate display_errors – Off  = You might want to turn this on, for debugging purposes. - optional

PHPOpen php.ini located in C:/WEB/PHP and have the following settings below: TAKE NOTE OF THE BACK SLASH “\”.

1. Locate and change the path to the folder you’ve created on #4.

  • doc_root = “C:\WEB”
  • extension_dir = “C:\WEB\PHP\ext”

2. Uncomment the following: Needed for mysql

  • extension=php_mysql.dll
  • extension=php_mysqli.dll

3. Optional. Locate and uncomment

  • short_open_tag = Off  – The default value is OFF change it to ON. You will need this if you use <? echo “hello”; ?> instead of <?php echo “hello”; ?>
  • E_ALL & ~E_NOTICE – Error reporting except for warnings and notices

D. Installing and configuring MYSQL

Just simply run the installer and follow the wizard configuration. Make sure apache is running.

Some errors you may encounter:

1. When starting the apache  you may encounter this error “...operation has failed “ – Just make sure you have the correct path for loadmodule mentioned on httpd.conf as well as other paths and if you still got the error open apache monitor click on connect and type your computer name and try starting apache again.

So that’s pretty much about it. Have fun!!!

SET SQL_BIG_SELECTS=1

Thursday, February 26th, 2009 by dreamluverz

I encountered this error on my query. I had the same query on my local computer, running without any problem but uploading it on the live site I got this error below:

The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay ….

According to some source it depends on the settings of the mysql, so my guess is my hosting provider set the limit of it, so in order to solve this on my site I followed the suggestion on the error msg.

So you can do it like this. Before executing your query execute this first
Example: mysql_query(‘SET SQL_BIG_SELECTS=1′) OR mysql_query(‘set SQL_MAX_JOIN_SIZE={NUMBER}’);
I used the 1st one and it works for me!