Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP 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 June 7th, 2004, 03:26 AM
Authorized User
 
Join Date: Jun 2003
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default unable to pass values from include file

i need help with this page.
i got this from a book and was trying to make it work as i have to hand in a project.
the scripting was partially completed.

after successful login, it will come to the membersmenu.php but once it reach there it was being diverted back to the login page again.

the page relies on session values.
the values(userid,password) will be pass into the super global variables.

i have tried to echo out all the variables and found that i was not able to pass the $result from the include files out to the other function calls.

there is no value return from the getRow function call(dblib.inc) to the checkuser funtion(clublib.inc)

Any one knows why? i was stuck here the whoel day thinking abt it. PLEASE HELP!

i have highlighted in black in the membersmenu.php the code that makes the calling into the include file.

thanks.

membersmenu.php
===============
<?php
    include("dblib.inc");
    include("clublib.inc");

$club_row = checkUser(); // function call to clublib.inc
?>

   <html>
   <head>
   <title>Welcome</title>
   </head>

   <body>
   <?php include("publicnav.inc"); ?>

   <h1>Members menu</h1>
   <a href="updateclub.php?<?php print SID ?>">Review your club details</a><br>
   <a href="reviewevents.php?<?php print SID ?>">Review your events</a><br>
   <a href="updateevent.php?<?php print SID ?>">New event</a><br>

</body>
   </html>


dblib.inc
=========
<?php
$link;

connectToDB();
function connectToDB()
    {
    global $link;
    $Name = "Organizer";
    $link = mysql_connect( "localhost");
    if ( ! $link )
        die( "Couldn't connect to MySQL" );
    mysql_select_db( $Name, $link )
        or die ( "Couldn't open organizer: ".mysql_error() );
    }

function getRow( $table, $fnm, $fval )
    {
    global $link;
    $result = mysql_query( "SELECT * FROM $table WHERE $fnm='$fval'", $link );
    if ( ! $result )
        die ( "getRow fatal error: ".mysql_error() );
    return mysql_fetch_array( $result );
    }
?>


clublib.inc
=========
<?
session_start();
session_register( "session" );

function cleanMemberSession( $id, $login, $pass )
    {
    global $session;
    $_SESSION['id'] = $id;
    $_SESSION['login'] = $login;
    $_SESSION['password'] = $pass;
    $_SESSION['logged_in'] = true;
    }

function checkUser( )
    {
    global $session, $logged_in;
    $_SESSION['logged_in'] = false;
    $club_row = getRow( "clubs", "id", $_SESSION['id'] );

    if (! $club_row || $club_row['login'] != $_SESSION['login'] || $club_row['password'] != $_SESSION['password'])
        {
     header( "Location: login.php" );
     exit;
    }
    return $club_row;
    }
?>
 
Old June 8th, 2004, 10:46 PM
Authorized User
 
Join Date: Jun 2003
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi all,

thank you for looking into my problems.
i have fix it thou.

turn out that the database that was created was all in uppercase.
that explains why there is not return values from some of the queries.

it actually helps to have a clear mind and a nice cup of hot coffee... :)





Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ Unable to open include file. Allen_T 08 C++ Programming 4 July 7th, 2016 01:43 PM
how to pass values from javascript to xml file satish_sgk Javascript How-To 1 November 24th, 2007 07:27 PM
Unable to pass Query to report at run time jdaulagar VB Databases Basics 0 November 14th, 2006 08:07 PM
unable to pass parameters to crystal report ukumawat Crystal Reports 1 May 6th, 2006 09:08 AM
difference between include file & include virtual crmpicco Classic ASP Basics 2 January 23rd, 2006 11:50 AM





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