Using Mysql 5.0 Functions with PHP
Moderator: General Moderators
Using Mysql 5.0 Functions with PHP
I understand that In order to have MySql 5.0 functions available in PHP, I must compile PHP with support for the mysqli extension. Please, how I can do this?
Thanks!
Thanks!
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
There are no MySQL5 Functions, per se. MySQLi is a different, object oriented, set of functions for interacting with MySQL. These functions have been available to PHP since PHP 4 I believe. But there is nothing keeping you from hitting MySQL5 with the standard mysql_* functions.
Keep in mind too that PHP5 comes with neither the mysql nor mysqli extension enabled by default. You have to turn either or both of them on yourself.
Keep in mind too that PHP5 comes with neither the mysql nor mysqli extension enabled by default. You have to turn either or both of them on yourself.
feyd | Please use
Thanks in advanced.
Note: PHPmyAdmin neither work with this config:
Everah | Please do not post the login credentials for your database connection/selection.
feyd | Please use
Code: Select all
,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]
Thanks. I'm absolute new to PHP/mySql. I have installed PHP 4.3 and mySql 5.0 because my server (1planhos) don't accept for now PHP 5.0.
My problem is that any MSQL function work. To try an example I need to use the ODBC functions. Please you can tell me what I can do?
This is the code that don't work. Don't send any error but don't process nothing:Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Pruebas</title>
<link rel="stylesheet" type="text/css" href="lib.css">
</head>
<body bgcolor="#FFFFFF" text="#996600" link="#996600" vlink="#996600" alink="#996600">
<table width="90%" border="1" align=center bgcolor="#FFFFFF">
<tr>
<td>
<?php
$con = mysql_connect("localhost", "****", "****");
mysql_select_db("****");
$sql = "select id,tema,ritmo, archivo,fecha from temas order by tema";
$queryexe = mysql_query($sql);
print($queryexe);
while(mysql_fetch_row($queryexe))
{
$id = mysql_result($queryexe, 1); //Puede ser $id= odbc_result($queryexe, "id");
$tema = mysql_result($queryexe, 2);
$ritmo = mysql_result($queryexe, 3);
$archivo = mysql_result($queryexe, 4);
$fecha = mysql_result($queryexe, 5);
?>
<tr>
<td class="listas" bgcolor="#f7efde"> <?php print ("$tema"); ?></td>
<td class="listas" bgcolor="#f7efde"> <?php print ("$ritmo"); ?></td>
<td class="listas" bgcolor="#f7efde"> <?php print ("$archivo"); ?></td>
<td class="listas" bgcolor="#f7efde"> <?php print ("$fecha"); ?></td>
</tr>
<?php }?>
</td>
</tr>
</table>
</body>
</html>Note: PHPmyAdmin neither work with this config:
Code: Select all
<?php
$i=0;
$i++;
$cfg['PmaAbsoluteUri'] = 'http://localhost/phpMyAdmin';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['auth_type'] = 'http';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'mypassword';
?>feyd | Please use
Code: Select all
,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]- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Run the following in a new file and tell us the results please.
Code: Select all
<?php
$neg = array(0, false, '', null, 'off');
$ve = phpversion();
$os = PHP_OS;
$er = intval(error_reporting());
$rg = (in_array(strtolower(ini_get('register_globals')), $neg) ? 'Off' : 'On');
$de = (in_array(strtolower(ini_get('display_errors')), $neg) ? 'Off' : 'On');
$so = (in_array(strtolower(ini_get('short_open_tag')), $neg) ? 'Off' : 'On');
$le = '';
$cli = (php_sapi_name() == 'cli');
$eol = ($cli ? "\n" : "<br />\n");
$gle = get_loaded_extensions();
$rows = array();
$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)) . "\n";
}
if ($cli)
{
$le = $eol . $le;
}
else
{
$le = '<pre>' . $le . '</pre>';
}
$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;
}
}
$er = $er . ' (' . implode(' | ', $e) . ')';
if (!$cli)
{
echo '<html><head><title>quick info</title></head><body>' . "\n";
}
echo 'PHP Version: ' . $ve . $eol;
echo 'PHP OS: ' . $os . $eol;
echo 'Error Reporting: ' . $er . $eol;
echo 'Register Globals: ' . $rg . $eol;
echo 'Short Tags: ' . $so . $eol;
echo 'Display Errors: ' . $de . $eol;
echo 'Loaded Extensions:' . $le . $eol;
if (!$cli)
{
echo '</body></html>' . "\n";
}
?>Unfortunately, don't work. The error:
' . $le . '
'; } $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; } } $er = $er . ' (' . implode(' | ', $e) . ')'; if (!$cli) { echo '' . "\n"; } echo 'PHP Version: ' . $ve . $eol; echo 'PHP OS: ' . $os . $eol; echo 'Error Reporting: ' . $er . $eol; echo 'Register Globals: ' . $rg . $eol; echo 'Short Tags: ' . $so . $eol; echo 'Display Errors: ' . $de . $eol; echo 'Loaded Extensions:' . $le . $eol; if (!$cli) { echo '' . "\n"; } ?>
The problem is from here:
SORRY!!!!! NO ERRORS IN THIS CODE!!!!!
Thanks...
' . $le . '
'; } $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; } } $er = $er . ' (' . implode(' | ', $e) . ')'; if (!$cli) { echo '' . "\n"; } echo 'PHP Version: ' . $ve . $eol; echo 'PHP OS: ' . $os . $eol; echo 'Error Reporting: ' . $er . $eol; echo 'Register Globals: ' . $rg . $eol; echo 'Short Tags: ' . $so . $eol; echo 'Display Errors: ' . $de . $eol; echo 'Loaded Extensions:' . $le . $eol; if (!$cli) { echo '' . "\n"; } ?>
The problem is from here:
Code: Select all
$le = '<pre>' . $le . '</pre>';
}
$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;
}
}
$er = $er . ' (' . implode(' | ', $e) . ')';
if (!$cli)
{
echo '<html><head><title>quick info</title></head><body>' . "\n";
}
echo 'PHP Version: ' . $ve . $eol;
echo 'PHP OS: ' . $os . $eol;
echo 'Error Reporting: ' . $er . $eol;
echo 'Register Globals: ' . $rg . $eol;
echo 'Short Tags: ' . $so . $eol;
echo 'Display Errors: ' . $de . $eol;
echo 'Loaded Extensions:' . $le . $eol;
if (!$cli)
{
echo '</body></html>' . "\n";
}
?>Thanks...
Last edited by jeva39 on Sat Sep 09, 2006 9:13 pm, edited 1 time in total.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
I'm sorry. Was a problem created by my editor (NuSphere PhpED). I run in another editor and report this:
PHP Version: 4.4.3
PHP OS: WINNT
Error Reporting: 2047 (E_ALL)
Register Globals: Off
Short Tags: On
Display Errors: Off
Loaded Extensions:
standard bcmath calendar ctype
com ftp mysql odbc
overload pcre session tokenizer
xml wddx zlib
Thanks...
PHP Version: 4.4.3
PHP OS: WINNT
Error Reporting: 2047 (E_ALL)
Register Globals: Off
Short Tags: On
Display Errors: Off
Loaded Extensions:
standard bcmath calendar ctype
com ftp mysql odbc
overload pcre session tokenizer
xml wddx zlib
Thanks...
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
You are not using any error reporting in your code. The problem, I would venture to say, is some form of syntax error in your code. If you are getting a blank page it is because display_errors is off and you have an ERROR level message being thrown by PHP. Make sure you are matching all braces, paranthesis and brackets, and that you are ending all of your lines with semicolons.
Really I appreciate very much your help and your time. Sincerely I don't encounter a logical explanation to this problem and I think that there is some problem of configuration in my machine or bad installation of mySql/PHP programs.
I have reviewed the code often and there is no error. In addition, NuSphere (the editor I use) does not allow any syntax error so that, if it exists, it indicates in red like Visual Studio 2005 Editor and don't permit run the code. For example when it was generated the error in your code I discovered that involuntarily I erase one quotation mark.
Again, thanks and I will continue looking for the error. Regards.
I have reviewed the code often and there is no error. In addition, NuSphere (the editor I use) does not allow any syntax error so that, if it exists, it indicates in red like Visual Studio 2005 Editor and don't permit run the code. For example when it was generated the error in your code I discovered that involuntarily I erase one quotation mark.
Again, thanks and I will continue looking for the error. Regards.
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact:
he means try adding mysql error reporting function mysql_error to end of every mysql_* function to get to know which one is the culprit.Everah wrote:You are not using any error reporting in your code.
like f.e.
Code: Select all
$con = mysql_connect("localhost", "****", "****") or die('MySQL Connect Error: '.mysql_error());- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Another thing to do is, at the beginning of the script, add the following lines:
If the page is still blank after adding these lines then you have a fatal error in your code (syntax) somewhere that needs to be dealt with.
Code: Select all
<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
?>This is the result:
Warning: mysql_connect() [function.mysql-connect]: Client does not support authentication protocol requested by server; consider upgrading MySQL client in C:\Inetpub\wwwroot\PHP\Function_DB_mySQL.php on line 14
MySQL Connect Error: Client does not support authentication protocol requested by server; consider upgrading MySQL client
Thanks...
Warning: mysql_connect() [function.mysql-connect]: Client does not support authentication protocol requested by server; consider upgrading MySQL client in C:\Inetpub\wwwroot\PHP\Function_DB_mySQL.php on line 14
MySQL Connect Error: Client does not support authentication protocol requested by server; consider upgrading MySQL client
Thanks...