Return table from function

May 28th, 2008

Build the function for return table to the calling statement.

CREATE FUNCTION SearchModule(
)
RETURNS @AppendText TABLE (
modTest varchar(500)
) As
BEGIN
INSERT INto @AppendText (modTest)
SELECT m.HEADER FROM MODULE_INFORMATION m
WHERE m.PROJECT_ID = 1
RETURN
END

Call to undefined function mysql_connect

May 27th, 2008

To day I’m install php5 , apache and mysql, I dowload “php-5.2.6-Win32.zip”  installer packet and apache “apache_2.2.8-win32-x86-openssl-0.9.8g.msi” and then I’m download mysql server

1. Install apache  apache_2.2.8-win32-x86-openssl-0.9.8g.msi

2. Extract php-5.2.6-Win32.zip to c:\php\php5 ( I create new dir php5 contain php5 only).

3. Rename php.ini.dst to php.ini in c:\php\php5 then cut to c:\windows

4. Copy libmysql.dll in c:\php\php5 to c:windows\system32

5. Edit httpd.conf in  C:\apache2.2\conf\ add this line

# ==== Load Module PHP5 ======
LoadModule php5_module “C:/php5/php5apache2_2.dll”
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

6. Restart apache and create php.info() for test php installation.

7. Install Mysql Server and create file for test db.

<?php
$dbhost=”localhost”;
$dbuser=”root”;
$dbpassword=”1234″;
mysql_connect($dbhost,$dbuser,$dbpassword);
echo “Test MySQL”;
?>

After run this file error occur “Fatal error: Call to undefined function mysql_connect() in C:\apache2.2\htdocs\testDB.php on line 5

I’m back to php.ini and uncomment

extension=php_mysql.dll

You might also need to configure the extension_dir variable.

extension_dir = “C:\php\php5\ext”

Restart apache and run  execute file again

Hello jquery

May 23rd, 2008

<html>
<head>
<script type=”text/javascript” src=”jquery.js”></script>
<script type=”text/javascript”>
$(document).ready(function(){
$(”a”).click(function(){
alert(”Hello World!”);
});
});
</script>
</head>
<body>
<a href=”">Click Me</a>
</body>
</html>

This page just loads the jquery.js library this example I copy jquery.js to same directory.

How to enable mod_rewrite in apache server

May 23rd, 2008

I install appserv web server and I want to enable mod_rewrite on my local serve I open httpd.conf with text editor then find “LoadModule rewrite_module ” and uncomment save then restart apache.

How to strip html tag

May 22nd, 2008

To day I’m write php code for get content from ezinearticle.com and post it to my blogger via gmail. after I use file_get_contents I had a html code of content then I must strip html tag out and cut out some body I try to search for google and found at php.net can help me.

<?php
$text
= ‘<p>Test paragraph.</p><!– Comment –> <a href=”#fragment”>Other text</a>’;
echo
strip_tags($text);
echo
“\n”;

// Allow <p> and <a>
echo strip_tags($text, ‘<p><a>’);
?>

In function can strip another <p>, <a>.