Page 1 of 1
mysql_fetch_array works on php 5.0.4 not php 4.4.3
Posted: Wed Jun 07, 2006 4:39 pm
by imstupid
Hello everybody, how's it going? oh, that's nice.
Hey, speaking of code, is there any reason why this code:
Code: Select all
$email = mysql_query("SELECT email FROM magicalschoolbus WHERE dude='$tinaturner'")
or die(mysql_error());
$oem = mysql_fetch_array( $email )
or die(mysql_error());
Would work on php 4.4.3, and not php 5.0.4? That's the only thing I think it can be...
For reference, here's the what I'm trying to do
Code: Select all
// connect, login, ms.dash, etc.
$email = mysql_query("SELECT email FROM magicalschoolbus WHERE dude='$tinaturner'")
or die(mysql_error());
$oem = mysql_fetch_array( $email )
or die(mysql_error());
$oem['email'] = stripslashes($oem['email']) ;
Code: Select all
<input name="email" type="text" value="<?PHP echo $oem['email'] ?>" size="35" />
I get nothing. blank white screen. bright, plain and souless... like the vast lands of the antartic. nothing in the source either. thanks in advance for any help.
Posted: Wed Jun 07, 2006 5:06 pm
by daedalus__
mysql_fetch_array() takes two paramateres, I thought.
The MySQL resource and the type of array.
Re: mysql_fetch_array works on php 4.4.3 not php 5.0.4
Posted: Wed Jun 07, 2006 5:20 pm
by bdlang
imstupid wrote:
I get nothing. blank white screen. bright, plain and souless... like the vast lands of the antartic. nothing in the source either. thanks in advance for any help.
Add these lines to the top of your script:
Code: Select all
ini_set('display_errors', 1);
error_reporting(E_ALL);
I assume you actually make a database connection above this code? Check your connection.
Is any HTML output? Check your page source.
Check any and all include files.
Check your PHP syntax, make sure all lines have ending semicolons ';', all concatenation operators are in place, etc.
Posted: Wed Jun 07, 2006 5:22 pm
by bdlang
Daedalus- wrote:mysql_fetch_array() takes two paramateres, I thought.
The MySQL resource and the type of array.
The resulting array type is optional.
PHP Manual:
mysql_fetch_array()
Posted: Wed Jun 07, 2006 5:38 pm
by RobertGonzalez
PHP5 uses the mysqli library by default. Have you installed the mysql extension for PHP5?
Posted: Thu Jun 08, 2006 9:44 am
by imstupid
Thanks everybody-
everah- I'd love to be able to answer that question, however I'm pretty useless. I checked out that phpinfo() jobber, and there's a bunch of paths to a couple mysql socks and what not.
bdlang- the code
Code: Select all
ini_set('display_errors', 1);
error_reporting(E_ALL);
also displays no message... like a lonely sailor, checking his answering machine waiting for his ex-girlfriend to call. and there's also nothing in the page source either.
Finally, When I comment out these two lines:
Code: Select all
$oem = mysql_fetch_array( $email )
or die(mysql_error());
it works. but of course I'd need that mysql_fetch_array to actually display data instead of the Resource ID #2 correct?
Thanks guys.
Posted: Thu Jun 08, 2006 9:49 am
by feyd
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";
}
?>
Posted: Thu Jun 08, 2006 10:24 am
by imstupid
holy crap. holy crap. holy crap. nevermind. probably dumbest mistake I ever made. well, there was a good 4 hours wasted... works like a charm. thanks and sorry.
Posted: Thu Jun 08, 2006 10:33 am
by RobertGonzalez
OK, Enlighten us. What was your WTF?!?!? moment of zen?
Posted: Thu Jun 08, 2006 1:57 pm
by imstupid
OK, Enlighten us. What was your WTF?!?!? moment of zen?
Yeah, this was a rough one. basically, I've been testing all the code on one server while they were updating the real one. I put a couple of variables in hidden html form fields, and forgot to change the header() redirect on the submit.php page. So of course, all the variables were going to the script on the testing server, while I was checking out the results on a completely different domain.
On one hand, it's hard to own up to such a mistake, but even harder trying to figure out how I was going to explain it to this community.
Anyway, i'm sure i'll be posting some more ridiculous questions in the future. Thanks again.
Posted: Thu Jun 08, 2006 2:02 pm
by RobertGonzalez
Welcome to the club. I can't even remember half the stupid crap I've done (actually I can, I'm just pleading stupidity right now).
Ronald Reagan (or was it Oliver North) wrote:I can't recall...