By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,362 Members | 3,489 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,362 IT Pros & Developers. It's quick & easy.

Session_start generates Ilegal Instruction under php 4.3.11 Help?

P: n/a
I set up a server on an AMD 650 machine running gentoo linux.

I installed Apachie 2, MySQL 4.1 and PHP 4.3.11

I use another computer on my local net (192.168.0.x) to access the server as a client.

MySQL works perfectly. I have created and queried databases with no problem.

Apachie 2 appears to work with no problem. I can call up web pages in the expected maner.

I created a set of php scripts which I found in Larry Ullman's book "PHP and MySQL For Dynamic Web Sites." For those of you with that book, I used Script 7.7 and replaced all the constants with my own values.

The script does the following things:
-) require_once() a script which opens MySQL and attaches the database.
-) Creates a form for the user to enter their username and password.
-) Handles the form.
-) If all input was provided, query the database for the username/password pair.
-) If username/password are in the database, then

session_start();
$_SESSION['authenticated'] = TRUE;
header ("Location: main-admin.php");
exit();

Everything appears to work untill I hit the session_start(). If I leave any fields blank or give a bad password, the script catches it and generates the error responce.

But if I give a good responce, the script just yields a perfectly blank HTML doc. Not even a title.

If I go to the server and run
# php index.php
it comes back with "Illegal Instruction." but with no explanation.

If I comment out the session_start(); then everything works perfectly, including the header().

If I move session_start(); to the very beginning of the script, it still dies and with the same symptoms. And since the script is generating a form on its first pass, the header() function is not encountered.

So why does php 4.3.11 concidder session_open to be an illegal instruction?

I have read the php manual, but have found nothing there.

php.ini has session auto start set to 0. I did not see anything else in php.ini which seemed to be related.

Thanks for any help or suggestions you can give.

I have coppied the entire script below for those who are interested.

Bob W.


<?php # /home/justadventure/html/admin/index.php

# This is the Index page for Admins.
# Admins must enter by this page. It is the only page which authenticates.
# It also starts a session.
# Every other admin page will check for authentication, via a session variable.
# If that variable is unavailable, then access is denied.
#
# This page both prompts for authentication via a form and also handles the form.
# It verifies that the user is allowed to continue and then passes control to the Main page.
#
# If authentication fails, then an explaination is displayed.
#
# Version 1.0 10-MAY-2005

# First, check if the form was submitted and we are now to handle it.
if (isset($_POST['submit'])) {
require_once ('../../secret/mysql-admin-main.php');
function escape_data ($data) {
global $dbc;
if (ini_get('magic_quotes_gpc')) {
$data = stripslashes($data);
}
return mysql_real_escape_string($data, $dbc);
}
$message = NULL;
if (empty($_POST['username'])) {
$u = FALSE;
$message .= '<p>You forgot to enter your username!</p>';
} else {
$u = escape_data($_POST['username']);
}
if (empty($_POST['password'])) {
$p = FALSE;
$message .= '<p>You forgot to enter your password!</p>';
} else {
$p = escape_data($_POST['password']);
}

if ($u && $p) { // If everything's OK.
$query = "SELECT adm_usrname FROM admins WHERE adm_usrname='$u' and adm_password=PASSWORD('$p')";
$result = @mysql_query ($query);
$row = mysql_fetch_array ($result, MYSQL_NUM);
if ($row) {

// Start the session, register the values & redirect.
session_start();
$_SESSION['authenticated'] = TRUE;
header ("Location: main-admin.php");
exit();

} else {
$message = '<p>The username and password entered do not match those on file.</p>';
}
mysql_close();
} else {
$message .= '<p>Please try again.</p>';
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>JustAdventure Administers Login Page</title>
</head>
<body>
<?php
if (isset($message)) {
echo '<font color="red">', $message, '</font>';
}
# Create the form and designate this script as the handler.
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset><legend>Enter your information in the form below:</legend>
<p><b>User Name:</b> <input type="text" name="username" size="10" maxlength="20" value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>" /></p>
<p><b>Password:</b> <input type="password" name="password" size="20" maxlength="20" /></p>
<div align="center"><input type="submit" name="submit" value="Login" /></div>
</fieldset></form><!-- End of Form -->
</body>
</html>

--------------= Posted using GrabIt =----------------
------= Binary Usenet downloading made easy =---------
-= Get GrabIt for free from http://www.shemes.com/ =-
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Trogdor wrote:
I set up a server on an AMD 650 machine running gentoo linux.

I installed Apachie 2, MySQL 4.1 and PHP 4.3.11

I use another computer on my local net (192.168.0.x) to access the server as a client.

MySQL works perfectly. I have created and queried databases with no problem.

Apachie 2 appears to work with no problem. I can call up web pages in the expected maner.

I created a set of php scripts which I found in Larry Ullman's book "PHP and MySQL For Dynamic Web Sites." For those of you with that book, I used Script 7.7 and replaced all the constants with my own values.

The script does the following things:
-) require_once() a script which opens MySQL and attaches the database.
-) Creates a form for the user to enter their username and password.
-) Handles the form.
-) If all input was provided, query the database for the username/password pair.
-) If username/password are in the database, then

session_start();
$_SESSION['authenticated'] = TRUE;
header ("Location: main-admin.php");
exit();

Everything appears to work untill I hit the session_start(). If I leave any fields blank or give a bad password, the script catches it and generates the error responce.

But if I give a good responce, the script just yields a perfectly blank HTML doc. Not even a title.

If I go to the server and run
# php index.php
it comes back with "Illegal Instruction." but with no explanation.

If I comment out the session_start(); then everything works perfectly, including the header().

If I move session_start(); to the very beginning of the script, it still dies and with the same symptoms. And since the script is generating a form on its first pass, the header() function is not encountered.

So why does php 4.3.11 concidder session_open to be an illegal instruction?

I have read the php manual, but have found nothing there.

php.ini has session auto start set to 0. I did not see anything else in php.ini which seemed to be related.

Thanks for any help or suggestions you can give.

I have coppied the entire script below for those who are interested.

Bob W.


<?php # /home/justadventure/html/admin/index.php

# This is the Index page for Admins.
# Admins must enter by this page. It is the only page which authenticates.
# It also starts a session.
# Every other admin page will check for authentication, via a session variable.
# If that variable is unavailable, then access is denied.
#
# This page both prompts for authentication via a form and also handles the form.
# It verifies that the user is allowed to continue and then passes control to the Main page.
#
# If authentication fails, then an explaination is displayed.
#
# Version 1.0 10-MAY-2005

# First, check if the form was submitted and we are now to handle it.
if (isset($_POST['submit'])) {
require_once ('../../secret/mysql-admin-main.php');
function escape_data ($data) {
global $dbc;
if (ini_get('magic_quotes_gpc')) {
$data = stripslashes($data);
}
return mysql_real_escape_string($data, $dbc);
}
$message = NULL;
if (empty($_POST['username'])) {
$u = FALSE;
$message .= '<p>You forgot to enter your username!</p>';
} else {
$u = escape_data($_POST['username']);
}
if (empty($_POST['password'])) {
$p = FALSE;
$message .= '<p>You forgot to enter your password!</p>';
} else {
$p = escape_data($_POST['password']);
}

if ($u && $p) { // If everything's OK.
$query = "SELECT adm_usrname FROM admins WHERE adm_usrname='$u' and adm_password=PASSWORD('$p')";
$result = @mysql_query ($query);
$row = mysql_fetch_array ($result, MYSQL_NUM);
if ($row) {

// Start the session, register the values & redirect.
session_start();
$_SESSION['authenticated'] = TRUE;
header ("Location: main-admin.php");
exit();

} else {
$message = '<p>The username and password entered do not match those on file.</p>';
}
mysql_close();
} else {
$message .= '<p>Please try again.</p>';
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>JustAdventure Administers Login Page</title>
</head>
<body>
<?php
if (isset($message)) {
echo '<font color="red">', $message, '</font>';
}
# Create the form and designate this script as the handler.
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset><legend>Enter your information in the form below:</legend>
<p><b>User Name:</b> <input type="text" name="username" size="10" maxlength="20" value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>" /></p>
<p><b>Password:</b> <input type="password" name="password" size="20" maxlength="20" /></p>
<div align="center"><input type="submit" name="submit" value="Login" /></div>
</fieldset></form><!-- End of Form -->
</body>
</html>

--------------= Posted using GrabIt =----------------
------= Binary Usenet downloading made easy =---------
-= Get GrabIt for free from http://www.shemes.com/ =-
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----


Trogdor,

I can see where running from the command line might cause a problem -
you aren't running with Apache and a browser, so you don't have sessions
available. But an illegal instruction seems a bit harsh.

As to the Apache problem - is there anything in your php.log? And have
you sent ANYTHING (even a blank line) before the header call?

I did see an entry in the php bugs database at http://www.php.net
(always a good thing to check!) where someone had a similar problem when
he installed 4.3.11 over 4.3.10 and ended up with mixed extensions.
Removing 4.3.10 completely (probably should remove everything) and
reinstalling 4.3.11 fixed his problem.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 17 '05 #2

P: n/a

Jerry Stuckle wrote:
Trogdor wrote:
I set up a server on an AMD 650 machine running gentoo linux.

I installed Apachie 2, MySQL 4.1 and PHP 4.3.11

I use another computer on my local net (192.168.0.x) to access the server as a client.
MySQL works perfectly. I have created and queried databases with no problem.
Apachie 2 appears to work with no problem. I can call up web pages in the expected maner.
I created a set of php scripts which I found in Larry Ullman's book "PHP and MySQL For Dynamic Web Sites." For those of you with that
book, I used Script 7.7 and replaced all the constants with my own
values.
The script does the following things:
-) require_once() a script which opens MySQL and attaches the database. -) Creates a form for the user to enter their username and password. -) Handles the form.
-) If all input was provided, query the database for the username/password pair. -) If username/password are in the database, then

session_start();
$_SESSION['authenticated'] = TRUE;
header ("Location: main-admin.php");
exit();

Everything appears to work untill I hit the session_start(). If I leave any fields blank or give a bad password, the script catches it
and generates the error responce.
But if I give a good responce, the script just yields a perfectly blank HTML doc. Not even a title.
If I go to the server and run
# php index.php
it comes back with "Illegal Instruction." but with no explanation.

If I comment out the session_start(); then everything works perfectly, including the header().
If I move session_start(); to the very beginning of the script, it still dies and with the same symptoms. And since the script is
generating a form on its first pass, the header() function is not
encountered.
So why does php 4.3.11 concidder session_open to be an illegal instruction?
I have read the php manual, but have found nothing there.

php.ini has session auto start set to 0. I did not see anything else in php.ini which seemed to be related.
Thanks for any help or suggestions you can give.

I have coppied the entire script below for those who are interested.
Bob W.


<?php # /home/justadventure/html/admin/index.php

# This is the Index page for Admins.
# Admins must enter by this page. It is the only page which authenticates. # It also starts a session.
# Every other admin page will check for authentication, via a session variable. # If that variable is unavailable, then access is denied.
#
# This page both prompts for authentication via a form and also handles the form. # It verifies that the user is allowed to continue and then passes control to the Main page. #
# If authentication fails, then an explaination is displayed.
#
# Version 1.0 10-MAY-2005

# First, check if the form was submitted and we are now to handle it. if (isset($_POST['submit'])) {
require_once ('../../secret/mysql-admin-main.php');
function escape_data ($data) {
global $dbc;
if (ini_get('magic_quotes_gpc')) {
$data = stripslashes($data);
}
return mysql_real_escape_string($data, $dbc);
}
$message = NULL;
if (empty($_POST['username'])) {
$u = FALSE;
$message .= '<p>You forgot to enter your username!</p>';
} else {
$u = escape_data($_POST['username']);
}
if (empty($_POST['password'])) {
$p = FALSE;
$message .= '<p>You forgot to enter your password!</p>';
} else {
$p = escape_data($_POST['password']);
}

if ($u && $p) { // If everything's OK.
$query = "SELECT adm_usrname FROM admins WHERE adm_usrname='$u' and adm_password=PASSWORD('$p')"; $result = @mysql_query ($query);
$row = mysql_fetch_array ($result, MYSQL_NUM);
if ($row) {

// Start the session, register the values & redirect.
session_start();
$_SESSION['authenticated'] = TRUE;
header ("Location: main-admin.php");
exit();

} else {
$message = '<p>The username and password entered do not match those on file.</p>'; }
mysql_close();
} else {
$message .= '<p>Please try again.</p>';
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>JustAdventure Administers Login Page</title>
</head>
<body>
<?php
if (isset($message)) {
echo '<font color="red">', $message, '</font>';
}
# Create the form and designate this script as the handler.
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset><legend>Enter your information in the form below:</legend> <p><b>User Name:</b> <input type="text" name="username" size="10" maxlength="20" value="<?php if (isset($_POST['username'])) echo
$_POST['username']; ?>" /></p> <p><b>Password:</b> <input type="password" name="password" size="20" maxlength="20" /></p> <div align="center"><input type="submit" name="submit" value="Login" /></div> </fieldset></form><!-- End of Form -->
</body>
</html>

--------------= Posted using GrabIt =----------------
------= Binary Usenet downloading made easy =---------
-= Get GrabIt for free from http://www.shemes.com/ =-
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups ----= East and West-Coast Server Farms - Total Privacy via
Encryption =----
Trogdor,

I can see where running from the command line might cause a problem - you aren't running with Apache and a browser, so you don't have sessions available. But an illegal instruction seems a bit harsh.

As to the Apache problem - is there anything in your php.log? And have you sent ANYTHING (even a blank line) before the header call?

I did see an entry in the php bugs database at http://www.php.net
(always a good thing to check!) where someone had a similar problem when he installed 4.3.11 over 4.3.10 and ended up with mixed extensions.
Removing 4.3.10 completely (probably should remove everything) and
reinstalling 4.3.11 fixed his problem.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================


I've just installed 4.3.11 and got an illegal instruction with
session_start() as well. Unfortunately i have no solution yet. I tried
PHP 5 and then went back to 4.3.10 & still got the same - with php and
mod_php under apache. Possibly when I changed version some stuff was
left behind but the standard 4.3.11 definitely had this problem. I've
got AMD Athlon 1000 processor.

boggins

Jul 17 '05 #3

P: n/a
> I've just installed 4.3.11 and got an illegal instruction with
session_start() as well. Unfortunately i have no solution yet. I tried
PHP 5 and then went back to 4.3.10 & still got the same - with php and
mod_php under apache. Possibly when I changed version some stuff was
left behind but the standard 4.3.11 definitely had this problem. I've
got AMD Athlon 1000 processor.


If you have the zend optimizer installed try upgrading it. If you do
not, make sure that any third party components are upgraded for that
version. Most of the time you have to recompile all extensions.

Also if that does not solve it. Completely reinstall PHP double check
that your config file points to the right spots and that PHP has
permission to access those areas.

Mike
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.