?

Search Help Board

PHP FAQ
PHP Articles
PHP Help
Bulletin Board

PHP Manual (NEW!)
First Time PHP'ers
Help with programming
Sql assignment help
PHP Homework Help


C# Help

?
?PHP funtion
Author:??(---.mis.prserv.net)
Date:???07-11-03 11:11

Hi.
My code have a problem. It is working on the NT. When I upload in hosting using linux . It is not working . my site is http://216.255.5.205/index.php
There are my code..index , funtion, show_cat.php
In the show_cat.php .they did not read $catid . it is the blank but it is read on my computer( NT).

Thanks you.
[email protected]
///////// show_cat.php ///////
include ('funtion.php');
// The shopping cart needs sessions, so start one
session_start();
session_register("get_categories()");

echo " nember is ";
echo "$catid";
$name = get_category_name($catid); ****?????***
// get the book info out from db
$book_array = get_books($catid);

display_books($book_array);

// if logged in as admin, show add, delete book links
if(session_is_registered("admin_user"))
{
display_button("index.php", "continue", "Continue Shopping");
display_button("admin.php", "admin-menu", "Admin Menu");
display_button("edit_category_form.php?catid=$catid", "edit-category", "Edit Category");
}
else
// display_button("index.php", "continue-shopping", "Continue Shopping");

//do_html_footer();
?>
/////////// funtion.php ////////

function db_connect()
{
$result = @mysql_pconnect("localhost", "book_sc", "password");
if (!$result)
return false;
if ([email protected]_select_db("book_sc"))
return false;
return $result;
}
function get_categories()
{
// query database for a list of categories
$conn = db_connect();
$query = "select catid, catname
from categories";
$result = @mysql_query($query);
if (!$result)
return false;
$num_cats = @mysql_num_rows($result);
if ($num_cats ==0)
return false;
$result = db_result_to_array($result);
echo "$num_cats ";
return $result;
}
function db_result_to_array($result)
{
$res_array = array();

for ($count=0; $row = @mysql_fetch_array($result); $count++)
$res_array[$count] = $row;

return $res_array;
}
function get_category_name($catid)
{
// query database for the name for a category id
echo " &&&&&&&&&& '$catid'";
$conn = db_connect();
$query = "select catname
from categories
where catid = $catid";
$result = @mysql_query($query);
if (!$result)
return false;
$num_cats = @mysql_num_rows($result);
if ($num_cats ==0)
return false;
$result = mysql_result($result, 0, "catname");
return $result;
}

function do_html_URL($url, $name)
{
// output URL as link and br
?>


}

function display_categories($cat_array)
{
if (!is_array($cat_array))
{
echo "No categories currently available
";
return;
}
echo "
    ";
    foreach ($cat_array as $row)
    {
    $url = "show_cat.php?catid=".($row["catid"]);
    $title = $row["catname"];
    echo "
  • ";
    do_html_url($url, $title);


    }
    echo "
";
echo "
";
}
function get_books($catid)
{
// query database for the books in a category
if (!$catid || $catid=="")
return false;

$conn = db_connect();
$query = "select * from books where catid='$catid'";
$result = @mysql_query($query);
if (!$result)
return false;
$num_books = @mysql_num_rows($result);
if ($num_books ==0)
return false;
$result = db_result_to_array($result);
return $result;
}
function display_books($book_array)
{
//display all books in the array passed in
if (!is_array($book_array))
{
echo "
No books currently available in this category
";
}
else
{
//create table
echo "";

//create a table row for each book
foreach ($book_array as $row)
{
$url = "show_book.php?isbn=".($row["isbn"]);
echo "";
}
echo "
";
if (@file_exists("images/".$row["isbn"].".jpg"))
{
$title = "";
do_html_url($url, $title);
}
else
{
echo "?";
}
echo "
";
$title = $row["title"]." by ".$row["author"];
do_html_url($url, $title);
echo "
";
}
echo "
";
}

?>
////////////// index.php ////////////////
include ('funtion.php');
// The shopping cart needs sessions, so start one
// session_start();
//session_register("$catid");
//do_html_header("Welcome to Book-O-Rama");
echo"";
echo "

Please choose a category:

";

// get categories out of database
$cat_array = get_categories();

// display as links to cat pages
display_categories($cat_array);

// if logged in as admin, show add, delete, edit cat links
if(session_is_registered("admin_user"))
{
display_button("admin.php", "admin-menu", "Admin Menu");
}

// do_html_footer();
?>

?Topics Author? Date
?PHP funtion??new
may 07-11-03 11:11?
Go to Top??|??Go to Topic??|??Flat View??|??Search?
??|??
New Topic
?Reply To This Message
?Your Name:
?Your Email:
?Subject:
Email replies to this thread, to the address above.
??wrote: > > Hi. > My code have a problem. It is working on the NT. When I > upload in hosting using linux . It is not working . my site > is http://216.255.5.205/index.php > There are my code..index , funtion, show_cat.php > In the show_cat.php .they did not read $catid . it is the > blank but it is read on my computer( NT). > > Thanks you. > [email protected] > ///////// show_cat.php /////// > include ('funtion.php'); > // The shopping cart needs sessions, so start one > session_start(); > session_register("get_categories()"); > > echo " nember is "; > echo "$catid"; > $name = get_category_name($catid); ****?????*** > // get the book info out from db > $book_array = get_books($catid); > > display_books($book_array); > > // if logged in as admin, show add, delete book links > if(session_is_registered("admin_user")) > { > display_button("index.php", "continue", "Continue > Shopping"); > display_button("admin.php", "admin-menu", "Admin Menu"); > display_button("edit_category_form.php?catid=$catid", > "edit-category", "Edit Category"); > } > else > // display_button("index.php", "continue-shopping", > "Continue Shopping"); > > //do_html_footer(); > ?> > /////////// funtion.php //////// > > function db_connect() > { > $result = @mysql_pconnect("localhost", "book_sc", > "password"); > if (!$result) > return false; > if ([email protected]_select_db("book_sc")) > return false; > return $result; > } > function get_categories() > { > // query database for a list of categories > $conn = db_connect(); > $query = "select catid, catname > from categories"; > $result = @mysql_query($query); > if (!$result) > return false; > $num_cats = @mysql_num_rows($result); > if ($num_cats ==0) > return false; > $result = db_result_to_array($result); > echo "$num_cats "; > return $result; > } > function db_result_to_array($result) > { > $res_array = array(); > > for ($count=0; $row = @mysql_fetch_array($result); $count++) > $res_array[$count] = $row; > > return $res_array; > } > function get_category_name($catid) > { > // query database for the name for a category id > echo " &&&&&&&&&& '$catid'"; > $conn = db_connect(); > $query = "select catname > from categories > where catid = $catid"; > $result = @mysql_query($query); > if (!$result) > return false; > $num_cats = @mysql_num_rows($result); > if ($num_cats ==0) > return false; > $result = mysql_result($result, 0, "catname"); > return $result; > } > > function do_html_URL($url, $name) > { > // output URL as link and br > ?> >
> } > > function display_categories($cat_array) > { > if (!is_array($cat_array)) > { > echo "No categories currently available
"; > return; > } > echo "
    "; > foreach ($cat_array as $row) > { > $url = "show_cat.php?catid=".($row["catid"]); > $title = $row["catname"]; > echo "
  • "; > do_html_url($url, $title); > > > } > echo "
"; > echo "
"; > } > function get_books($catid) > { > // query database for the books in a category > if (!$catid || $catid=="") > return false; > > $conn = db_connect(); > $query = "select * from books where catid='$catid'"; > $result = @mysql_query($query); > if (!$result) > return false; > $num_books = @mysql_num_rows($result); > if ($num_books ==0) > return false; > $result = db_result_to_array($result); > return $result; > } > function display_books($book_array) > { > //display all books in the array passed in > if (!is_array($book_array)) > { > echo "
No books currently available in this > category
"; > } > else > { > //create table > echo ""; > > //create a table row for each book > foreach ($book_array as $row) > { > $url = "show_book.php?isbn=".($row["isbn"]); > echo ""; > } > echo "
"; > if (@file_exists("images/".$row["isbn"].".jpg")) > { > $title = " border=0>"; > do_html_url($url, $title); > } > else > { > echo " "; > } > echo ""; > $title = $row["title"]." by ".$row["author"]; > do_html_url($url, $title); > echo "
"; > } > echo "
"; > } > > ?> > ////////////// index.php //////////////// > include ('funtion.php'); > // The shopping cart needs sessions, so start one > // session_start(); > //session_register("$catid"); > //do_html_header("Welcome to Book-O-Rama"); > echo""; > echo "

Please choose a category:

"; > > // get categories out of database > $cat_array = get_categories(); > > // display as links to cat pages > display_categories($cat_array); > > // if logged in as admin, show add, delete, edit cat links > if(session_is_registered("admin_user")) > { > display_button("admin.php", "admin-menu", "Admin Menu"); > } > > // do_html_footer(); > ?> ">??

Provided By
Phorum