Page 1 of 2
database vaues displaying using internet explorer
Posted: Mon Feb 19, 2007 3:31 am
by rekha_harnoor
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I am using php5 and using zend studio 5.5 as php IDE. I am using mysql database
following is the code. I able to view the result in the zend IDE but when I run from IE browser, nothing is displayed. Is it related to any setting or something?
for ex. http://localhost/test.php
Code: Select all
<html>
<head>
<title>php database connection test
</title>
</head>
<body>
<?php
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "roo";
$dbcnx = mysql_connect($dbhost, $dbuser, $dbpass) or
die ('Error connecting to mysql');
//$dbname = "hotdeals";
mysql_select_db("hotdeals", $dbcnx);
if (!@mysql_select_db("hotdeals"))
{
exit('<p> unable to locate the hotdeals <p>');
}
echo $dbcnx;
$userid = "abc";
$password = "xyz";
echo $userid;
echo $password;
$query=mysql_query("insert into signup(userid,password)
values('$userid','$password')");
echo $query;
?>
</body>
</html>
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
[quote="[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1"][b]3.[/b] Do not make multiple, identical posts. This is viewed as spam and will be deleted.[/quote]
Posted: Mon Feb 19, 2007 4:45 am
by dude81
try this
save it php_test.php and place it under the document root of web and access it as
http://localhost/php_test.php. This will say PHP is working normally on server or not
Posted: Mon Feb 19, 2007 7:31 am
by feyd
Have you installed a web server and PHP into it?
Posted: Mon Feb 19, 2007 1:40 pm
by rekha_harnoor
I have installed apache server. I am able to run other php programs but not this one.
Posted: Mon Feb 19, 2007 2:53 pm
by feyd
Did you turn on MySQL?
Posted: Mon Feb 19, 2007 5:28 pm
by rekha_harnoor
how to rurn on mysql? I have changes php.ini. apart from that I don't know what do you mean?
Posted: Mon Feb 19, 2007 9:55 pm
by feyd
Run the following in a new file and tell us the results please.
Code: Select all
<?php
$neg = array('off', 0, false, '', null);
$flags = array(
'Register Globals' => 'register_globals',
'Short Tags' => 'short_open_tag',
'Display Errors' => 'display_errors',
'Magic Quotes GPC' => 'magic_quotes_gpc',
'Magic Quotes Runtime' => 'magic_quotes_runtime',
'Magic Quotes Sybase' => 'magic_quotes_sybase',
);
$ve = phpversion();
$os = PHP_OS;
$er = intval(error_reporting());
foreach ($flags as $n => $v)
{
$flags[$n] = (in_array(strtolower(ini_get($v)), $neg) ? 'Off' : 'On');
}
$flags['Config file'] = get_cfg_var('cfg_file_path');
if (empty($flags['Config file']))
{
$flags['Config file'] = '-';
}
$cli = (php_sapi_name() == 'cli');
$eol = "\n";
$gle = get_loaded_extensions();
$rows = array();
$le = '';
$wide = 4;
$j = count($gle);
$pad = $wide - $j % $wide;
$len = max(array_map('strlen', $gle));
$func = create_function('$a', 'return str_pad($a, ' . intval($len) . ');');
$gle = array_map($func, $gle);
for($i = 0; $i < $j; $i += $wide)
{
$le .= ' ' . implode(' ', array_slice($gle, $i, $wide)) . $eol;
}
$ec = array(
'E_STRICT' => 2048, 'E_ALL' => 2047, 'E_USER_NOTICE' => 1024,
'E_USER_WARNING' => 512, 'E_USER_ERROR' => 256, 'E_COMPILE_WARNING' => 128,
'E_COMPILE_ERROR' => 64, 'E_CORE_WARNING' => 32, 'E_CORE_ERROR' => 16,
'E_NOTICE' => 8, 'E_PARSE' => 4, 'E_WARNING' => 2, 'E_ERROR' => 1,
);
$e = array();
$t = $er;
foreach ($ec as $n => $v)
{
if (($t & $v) == $v)
{
$e[] = $n;
$t ^= $v;
}
}
if (ceil(count($ec) / 2) + 1 < count($e))
{
$e2 = array();
foreach ($ec as $n => $v)
{
if (!in_array($n, $e) and $n != 'E_ALL')
{
$e2[] = $n;
}
}
$er = $er . ' ((E_ALL | E_STRICT) ^ ' . implode(' ^ ', $e2) . '))';
}
else
{
$er = $er . ' (' . implode(' | ', $e) . ')';
}
if (!$cli)
{
echo '<html><head><title>quick info</title></head><body><pre>', $eol;
}
echo 'PHP Version: ', $ve, $eol;
echo 'PHP OS: ', $os, $eol;
echo 'Error Reporting: ', $er, $eol;
foreach ($flags as $n => $v)
{
echo $n, ': ', $v, $eol;
}
echo 'Loaded Extensions:', $eol, $le, $eol;
if (!$cli)
{
echo '</pre></body></html>', $eol;
}
?>
Posted: Tue Feb 20, 2007 5:48 pm
by rekha_harnoor
I got the following output. Please tell me what to do next.
PHP Version: 5.1.6
PHP OS: WINNT
Error Reporting: 2047 (E_ALL)
Register Globals: Off
Short Tags: Off
Display Errors: Off
Magic Quotes GPC: Off
Magic Quotes Runtime: Off
Magic Quotes Sybase: Off
Config file: C:\php\php.ini
Loaded Extensions:
bcmath calendar com_dotnet ctype
date ftp hash iconv
odbc pcre Reflection session
libxml standard tokenizer zlib
SimpleXML dom SPL wddx
xml xmlreader xmlwriter apache2handler
Posted: Tue Feb 20, 2007 7:07 pm
by feyd
Did you edit C:\php\php.ini? If so, did you restart your web server?
Posted: Tue Feb 20, 2007 9:17 pm
by volka
Take a look at
http://de2.php.net/mysql , esp.
Installation on Windows Systems
[...]
PHP 5+
When you've successfully enabled the mysql extension feyd's script will list it under
Loaded Extensions:
bcmath calendar com_dotnet ctype
date ftp hash iconv
odbc pcre Reflection session
libxml standard tokenizer zlib
SimpleXML dom SPL wddx
xml xmlreader xmlwriter apache2handler
Posted: Wed Feb 21, 2007 2:40 am
by rekha_harnoor
I did everything but still it is not working!
Posted: Wed Feb 21, 2007 3:16 am
by rekha_harnoor
I somehow feel that there is no communication between apache and mysql. Because I am able to run other php programs on apache web server but when I include mysql database connection I am getting blank page.
How to correct it?
Posted: Wed Feb 21, 2007 8:22 am
by feyd
There is no communication between Apache and MySQL. PHP communicates with MySQL. We've already said how to correct it under normal circumstances.
It may be easiest/best to simply install a package such as Xampp.
Posted: Wed Feb 21, 2007 8:59 am
by volka
I second that.
http://www.apachefriends.org/en/xampp-windows.html
On the other hand I'm a bit curious. What does
Code: Select all
<?php
function fileperm($path) {
if ( !file_exists($path) ) {
echo '-no such file-';
}
else {
echo is_dir($path) ? 'd':'-';
echo is_readable($path) ? 'r':'-';
echo is_writable($path) ? 'w':'-';
echo is_executable($path) ? 'x':'-';
}
}
$phpini = trim(get_cfg_var('cfg_file_path'));
if ( 0==strlen($phpini) ) {
die('no php.ini');
}
echo 'ini: ', $phpini, ' perm: ', fileperm($phpini), "<br />\n";
echo "-- mysql extensions --<br />\n";
$config = file($phpini);
foreach($config as $l) {
if ( preg_match('!extension\s*=.*mysql!', $l) ) {
echo $l;
}
}
echo "-- PATH test --<br />\n";
$path = getenv('PATH');
echo ' path: ', $path, "<br />\n";
foreach( explode(';', $path) as $p) {
$p = str_replace('\\', '/', $p);
if ( '/'!=substr($p, -1, 1) ) {
$p .= '/';
}
$p .= 'libmysql.dll';
echo ' ', $p, ' perm: ', fileperm($p), "<br />\n";
}
print?
Posted: Thu Feb 22, 2007 1:42 am
by rekha_harnoor
ini: C:\php\php.ini perm: -rw-
-- mysql extensions --
extension=php_mysql.dll extension=php_mysqli.dll -- PATH test --
path: C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\bes\bin;c:\Program Files\java\jdk1.5.0_15\bin;C:\Program Files\MySQL\MySQL Server 4.1\bin;C:\php;c:\Program Files\Microsoft SQL Server\90\Tools\binn\
C:/WINDOWS/system32/libmysql.dll perm: -no such file-
C:/WINDOWS/libmysql.dll perm: -no such file-
C:/WINDOWS/System32/Wbem/libmysql.dll perm: -no such file-
C:/bes/bin/libmysql.dll perm: -no such file-
c:/Program Files/java/jdk1.5.0_15/bin/libmysql.dll perm: -no such file-
C:/Program Files/MySQL/MySQL Server 4.1/bin/libmysql.dll perm: -rw-
C:/php/libmysql.dll perm: -rw-
c:/Program Files/Microsoft SQL Server/90/Tools/binn/libmysql.dll perm: -no such file-
the output is as above.
Please suggest what to do next?