@echo off
setlocal
if "%1" == "" goto noArg
set fullpath=%~$PATH:1
if "%fullpath%" == "" goto notFound
echo Found in PATH: %fullpath%
goto end
:noArg
echo No Argument specified
goto end
:notFound
echo Argument "%1" not found in PATH
:end
endlocal
Monday, October 25, 2010
Bad Request in apache? Not able to start server?
After installing apache in windows, you may see problems like
Invalid request or Bad request..
This may be because of another program which already using port 80.
you can debug this kind of problems using a command which list
all ports currently in use and program names too
use this command to see which program is using which port
C:\>netstat -a -b -n -o
get PID from above program, and go to task manager to get program / application
name.
In my case svchost is using :http port by default. its may be virus. i terminated it
and you can also see hosts file in
C:\WINDOWS\system32\drivers\etc for any errors.
or if some know program is using 80 port (like tomcat, weblogic...etc) then you
can configure other port like 8888 in httpd.conf ( apache_home/conf)
Invalid request or Bad request..
This may be because of another program which already using port 80.
you can debug this kind of problems using a command which list
all ports currently in use and program names too
use this command to see which program is using which port
C:\>netstat -a -b -n -o
get PID from above program, and go to task manager to get program / application
name.
In my case svchost is using :http port by default. its may be virus. i terminated it
and you can also see hosts file in
C:\WINDOWS\system32\drivers\etc for any errors.
or if some know program is using 80 port (like tomcat, weblogic...etc) then you
can configure other port like 8888 in httpd.conf ( apache_home/conf)
pache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName
To fix it, we need to edit the /etc/apache2/httpd.conf
or /etc/apache2.conf
and add the following line:
ServerName nameofserver
Tuesday, October 19, 2010
Wednesday, October 6, 2010
PHP program to read a table from MYSQL?
\n";
echo"
student No
Student Name
Student fee
";
while($row = mysql_fetch_row($resultset)){
echo "\n";
foreach($row as $val){
echo "$val\n";
}
echo "\n";
}
echo "";
mysql_select_db($database_name);
mysql_close();
?>
echo"
student No
Student Name
Student fee
";
while($row = mysql_fetch_row($resultset)){
echo "\n";
foreach($row as $val){
echo "$val\n";
}
echo "\n";
}
echo "";
mysql_select_db($database_name);
mysql_close();
?>
Installing Apache, PHP,MYSQL?
Step 1:
===================================================
Install Apache http server to c:\Apache2.2.11
Run Apache and test http://localhost
we can configure http port, server root, document root...etc
in c:\Apache2.2.11\conf\httpd.conf
Step 2:
====================================================
install or unzip PHP 5 to c:\php5.2.6
create php.ini in c:\php5.2.6
make sure php5apache2_2.dll is in c:\php5.2.6
Step 3: Link Apache and PHP.
======================================================
Open httpd.conf in c:\Apache2.2.11\conf
add following three lines in LoadModules area
#Let apache where php DLL present to process php files
LoadModule php5_module "c:/php5.2.6/php5apache2_2.dll"
#Let apache know php can be handled
AddType application/x-httpd-php .php
# let Apache know path to php.ini
PHPIniDir "c:/php5.2.6"
You can test php configuration. create a php fiel phpinfo.php in htdocs of
apache server. then issue
http://localhost/phpinfo.php
phpinfo.php
------------
phpinfo();
?>
Step 4: Configure MySQL
===========================================
install MYSQL server to c:\mysql5.1
start mysql server from command prompt ( if you havent installed
mySQL as service. we can choose this option while installaiton)
cmd > mysqld (press enter)
Then log into mySQL
cmd> mysql -u root (press Enter) .you may need to enter password
using -p option (if you set root password in installaiton)
Now see list of databases
mysql> show databases;
To see list of existing users,
mysql> select user,host,password from mysql.user;
Here mysql is MYSQL server system database to keep system tables
to create new database
mysql> create database if not exists wp436;
to create new user
mysql> create user 'suresh'@'localhost' identified by 'suresh123';
Then to grant all privileges to wp436 to user suresh,
mysql>use wp436;
mysql> grant select,insert,update,delete,create,drop on wp436.* to 'suresh'
identified by 'suresh123';
Now user is ready for login;
cmd> mysql -u suresh -p (press enter.prompt for password)
now user can see list of databases having access
mysql>show databases;
Now create a table in wp436 database
user first select the database
mysql> use wp436;
mysql>create table student(sno integer(6),sname varchar(50),sfee double(8,2),primary key(sno));
Now insert data
mysql> insert into student values(100,'aaa',1000);
now commit,
mysql> commit;
Step 5: Connect PHP and MYSQL
====================================
modify php.ini to enable
extension=php_mysql.dll
extension=php_mysqli.dll
And copy the "php_mysql.dll" to c:\WINDOWS, and the "libmysql.dll" to the c:\WINDOWS\system32. You will find these dlls in the ext directory in the PHP installation directory.
we can do more changes in [MYSQL] section of php.ini
Note: irritation with beep sound provided by msql?
use cmd> net stop beep :)
Are you getting could not connect can't connect to mySQL server on localhost(10061)
Sol: Checl mysqld is running or not. if not run it
cmd>mysqld
Step 6: Sample PHP Program to test db connection:
=======================================================
call this php file using
http://localhost/dbtest.php
===================================================
Install Apache http server to c:\Apache2.2.11
Run Apache and test http://localhost
we can configure http port, server root, document root...etc
in c:\Apache2.2.11\conf\httpd.conf
Step 2:
====================================================
install or unzip PHP 5 to c:\php5.2.6
create php.ini in c:\php5.2.6
make sure php5apache2_2.dll is in c:\php5.2.6
Step 3: Link Apache and PHP.
======================================================
Open httpd.conf in c:\Apache2.2.11\conf
add following three lines in LoadModules area
#Let apache where php DLL present to process php files
LoadModule php5_module "c:/php5.2.6/php5apache2_2.dll"
#Let apache know php can be handled
AddType application/x-httpd-php .php
# let Apache know path to php.ini
PHPIniDir "c:/php5.2.6"
You can test php configuration. create a php fiel phpinfo.php in htdocs of
apache server. then issue
http://localhost/phpinfo.php
phpinfo.php
------------
phpinfo();
?>
Step 4: Configure MySQL
===========================================
install MYSQL server to c:\mysql5.1
start mysql server from command prompt ( if you havent installed
mySQL as service. we can choose this option while installaiton)
cmd > mysqld (press enter)
Then log into mySQL
cmd> mysql -u root (press Enter) .you may need to enter password
using -p option (if you set root password in installaiton)
Now see list of databases
mysql> show databases;
To see list of existing users,
mysql> select user,host,password from mysql.user;
Here mysql is MYSQL server system database to keep system tables
to create new database
mysql> create database if not exists wp436;
to create new user
mysql> create user 'suresh'@'localhost' identified by 'suresh123';
Then to grant all privileges to wp436 to user suresh,
mysql>use wp436;
mysql> grant select,insert,update,delete,create,drop on wp436.* to 'suresh'
identified by 'suresh123';
Now user is ready for login;
cmd> mysql -u suresh -p (press enter.prompt for password)
now user can see list of databases having access
mysql>show databases;
Now create a table in wp436 database
user first select the database
mysql> use wp436;
mysql>create table student(sno integer(6),sname varchar(50),sfee double(8,2),primary key(sno));
Now insert data
mysql> insert into student values(100,'aaa',1000);
now commit,
mysql> commit;
Step 5: Connect PHP and MYSQL
====================================
modify php.ini to enable
extension=php_mysql.dll
extension=php_mysqli.dll
And copy the "php_mysql.dll" to c:\WINDOWS, and the "libmysql.dll" to the c:\WINDOWS\system32. You will find these dlls in the ext directory in the PHP installation directory.
we can do more changes in [MYSQL] section of php.ini
Note: irritation with beep sound provided by msql?
use cmd> net stop beep :)
Are you getting could not connect can't connect to mySQL server on localhost(10061)
Sol: Checl mysqld is running or not. if not run it
cmd>mysqld
Step 6: Sample PHP Program to test db connection:
=======================================================
call this php file using
http://localhost/dbtest.php
Subscribe to:
Posts (Atom)