Php/mysql queries are not processing
Moderator: General Moderators
Php/mysql queries are not processing
Hi,
The queries on one of my sites I look after stopped processing MySQL queries. The site is written in PHP and I have been over the code over and over again. No matter what i do it won't process the queries, nor will it give me an error. The php server is working because it will print out Echo statements but queries just leave everything blank. Even the HTML code after the query doesn't process. Its like the processing gets stuck on the query. What can I do? Thanks.
Frank
The queries on one of my sites I look after stopped processing MySQL queries. The site is written in PHP and I have been over the code over and over again. No matter what i do it won't process the queries, nor will it give me an error. The php server is working because it will print out Echo statements but queries just leave everything blank. Even the HTML code after the query doesn't process. Its like the processing gets stuck on the query. What can I do? Thanks.
Frank
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Weirdan | Please use
Here is version 2 (this is actually the original version)
Server is PHP 5 (not sure what other version info there is)
Not sure about settings either, as I didn't set this up, I only maintain the site and make minor adjustments.
The pages are empty past the point of where a query is made. For instance on the home page (http://www.insidedigitalmedia.com, hope its OK to put in urls) the top and left side of the page are fine, then the center of the page is blank is blank (except for 2 lines of text right before the first query). Usually there is a section that contains a message from the site's owner (source of the code above). Then below that is a section with links to interviews that is also pulled from the MySQL db.
Hopefully this is OK, thanks again for the help.
Frank
Weirdan | 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 for a quick reply here is version 1 (I rewrote existing code to see if it made a difference)Code: Select all
<? $connection = mysql_connect($host,$username,$password)
or die ("Couldn't connect to database");
$db= mysql_select_db($dbase, $connection)
or die ("Couldn't select database");
$query = "Select * from idm_message";
$result = mysql_query($query)
or die ("Couldn't execute query");
$row = mysql_fetch_array($result); ?>
<p class=title_text>a message from phil</p>
<? echo $row["title"]; ?></b> <? echo $row["message"]; ?>Code: Select all
<? $connection = mysql_connect($host,$username,$password);
if ($connection == false){
echo mysql_errno().": ".mysql_error()."<BR>";
//echo("Your username or password is not correct.");
exit; }
$select_success = mysql_select_db("dmn");
$db_message = mysql_query("SELECT * FROM idm_message");
$row = mysql_fetch_array($db_message);
?>
<? echo $row["title"]; ?></b> <? echo $row["message"]; ?></p>
<? mysql_close(); ?>Not sure about settings either, as I didn't set this up, I only maintain the site and make minor adjustments.
The pages are empty past the point of where a query is made. For instance on the home page (http://www.insidedigitalmedia.com, hope its OK to put in urls) the top and left side of the page are fine, then the center of the page is blank is blank (except for 2 lines of text right before the first query). Usually there is a section that contains a message from the site's owner (source of the code above). Then below that is a section with links to interviews that is also pulled from the MySQL db.
Hopefully this is OK, thanks again for the help.
Frank
Weirdan | 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]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";
}
?>- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
You may need to turn error_reporting on to see if there are errors being thrown that are not being displayed.
At the beginning of your page that has errors on it, add this line..
Run the page again and see if anything gets outputted that could help you out (and help us help you out).
At the beginning of your page that has errors on it, add this line..
Code: Select all
<?php
ini_set('display_errors', 1);
?>- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Hi again,
It seems my host is telling me that I am wrong. He insists that I have something incorrect in my code and reminded me that the MySQL server is sitting at 127.0.0.1. I inserted the code prescribed above to turn error reporting display on and here is the output.
Frank
It seems my host is telling me that I am wrong. He insists that I have something incorrect in my code and reminded me that the MySQL server is sitting at 127.0.0.1. I inserted the code prescribed above to turn error reporting display on and here is the output.
Is this saying that there is no such function as mysql_connect? I have checked the username, password, and host IP several times and they are correct. Thanks.Fatal error: Call to undefined function: mysql_connect() in /usr/local/www/data-dist/insidedigitalmedia/includes/featured_message.inc on line 1
Frank
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
The reason I posted this statement is becuase if the mysql extension is not enabled, PHP will not know what the heck function mysql_* will be. Since it is undefined (unknow) it throws an error. Tell your host to check your PHP info page to see which extensions are loaded. Also tell them they are full it if they think that they are right since your call to a function they say is enabled returned an error.Everah wrote:Man, I didn't even look that far. He seems to have a few extensions loaded. He should probably be getting all sorts of calls to undefined function errors.