Wrox Programmer Forums
|
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0
This is the forum to discuss the Wrox book Beginning PHP5, Apache, and MySQL Web Development by Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz, Michael K. Glass; ISBN: 9780764579660
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 12th, 2005, 01:15 AM
Registered User
 
Join Date: Apr 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to preston2003
Default session_start issue (Chapter 12)

I built a authentication database with MySQL 5.0.3 and PHP 4.3.12 dev using Apache2 and when I get to login page and submit my user and pass the database sees my authentication, but then i am supposed to go to anoth session of the site. Instead the login session keeps looping back to login again. I need help...

Thanks

---------------------------------------------------------------
Index.php
---------
<?php
session_start();
if ((isset($_SESSION['admin_logged']) &&
$_SESSION['admin_logged'] != "") ||
(isset($_SESSION['admin_password']) &&
$_SESSION['admin_password'] != "")) {
include "logged_admin.php";
} else {
include "unlogged_admin.php";
}
?>
------------------------------
Conn.inc.php
-------------
<?php
$conn = mysql_connect("localhost", "some_user", "some_pass")
or die(mysql_error());
$db = mysql_select_db("some_db")
or die(mysql_error());
?>
------------------------------
Auth_admin.php
---------------
<?php
if ((isset($_SESSION['admin_logged']) &&
$_SESSION['admin_logged']) != "" ||
(isset($_SESSION['admin_password']) &&
$_SESSION['admin_password'] != "")) {
//Do Nothing!
} else {
$redirect = $_SERVER['PHP_SELF'];
header("Refresh: 5; URL=admin_login.php?redirect=$redirect");
echo "You are currently not logged in, we are redirecting you, " .
"be patient!<br>";
echo "(If your browser doesn't support this, " .
"<a href=\"admin_login.php?redirect\">Click here</a>";
die();
}
?>

:(
 
Old April 13th, 2005, 06:46 AM
Registered User
 
Join Date: Apr 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Are you doing this on a localhost and if so is the php.ini session.save_path set correctly (see p 16 of the book) - otherwise the session data wont get saved...(but can appear to be there initially when it is posted)?
 
Old April 13th, 2005, 09:32 AM
Registered User
 
Join Date: Apr 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to preston2003
Default

Yes. and after saving and restarting apache, it still loops to the login page. also should i leave the "N;c:\php\session" OR "c:\php\session" ? What's next if this doesn't work?


Quote:
quote:Originally posted by fastnet
 Are you doing this on a localhost and if so is the php.ini session.save_path set correctly (see p 16 of the book) - otherwise the session data wont get saved...(but can appear to be there initially when it is posted)?
 
Old April 13th, 2005, 09:59 AM
Registered User
 
Join Date: Apr 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to preston2003
Default

It worked...!! :) After I enabled and disable session.auto_start and restarted apache..

 
Old April 14th, 2005, 03:37 AM
Registered User
 
Join Date: Apr 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Glad to hear the problem is now sorted. Part of the problem seems to be the books/manuals are too large and you can easily miss a vital detail. I got to the bottom of it using print_r on each page for all the relevant arrays and it became clear the $_POST ones were working but the $_SESSION ones weren't...and from there it was a short step to realise why...

On top of that it seems to me these localhost set ups do a lot of what for want of a better word seems to be cacheing and so a restart often makes things run better.
 
Old April 14th, 2005, 08:50 AM
Registered User
 
Join Date: Apr 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to preston2003
Default

From Chapter 10 on the Comic Book Super Heroes database I get this error when I try to delete a character: Unknown table 'char_main' in MULTI DELETE

 
Old April 14th, 2005, 09:23 AM
Registered User
 
Join Date: Apr 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to preston2003
Default

Also from chapter 12 i get this error deleting an account:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'query_delete' at line 1

 
Old April 15th, 2005, 03:09 AM
Registered User
 
Join Date: Apr 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The MySQL error messages are cryptic and contain the useless "check the manual" guff (what manual???) BUT they do contain the clue. If you take out the guff the message reads

You have an error in your SQL syntax near 'query_delete' at line 1

Check your code near that point and you find and be able to correct the problem (often very small - misplaced colons and quotes for example). In this particular case I am no expert but I think the problem may be the 'query_delete' - this does not seem like valid PHP/MySQL - most functions start with mysql_ followed by the rest of the function name.








Similar Threads
Thread Thread Starter Forum Replies Last Post
chapter 12 loginin issue marcusth BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 2 December 27th, 2007 01:11 PM
Generics chapter 12 difficult chapter i found ...? Larryz C# 2005 1 July 4th, 2007 09:40 PM
Chapter 12 .MAttButler BOOK: Professional Web Parts and Custom Controls ASP.NET ISBN: 0-7645-7860-X 5 September 10th, 2006 08:31 PM
Errors on Chapter 12 example(12.8) sonnie ASP.NET 2.0 Professional 2 June 7th, 2006 10:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.