Current location: Hot Scripts Forums » Programming Languages » PHP » Functions dont work... dont know why


Functions dont work... dont know why

Reply
  #1 (permalink)  
Old 02-06-04, 03:47 PM
Bobd314 Bobd314 is offline
New Member
 
Join Date: Feb 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Angry Functions dont work... dont know why

Aight I am trying to get this function to work everything in the function looks right but when I do for example TutorialDisplay( $_GET['id'],PHP ) it displays all the tutorials in the database when I only want it to display one type.. can any one help?


PHP Code:

function TutorialDisplay$id $type ) {

$db mysql_connect("localhost""USERNAME""PASSWORD");
mysql_select_db("DATABASE",$db);
// display individual record
if ($id) {
  
$result mysql_query("SELECT * FROM Tutorial WHERE id=$id AND Category=$type",$db);
   
$myrow mysql_fetch_array($result);
   
printf("<b>%s\n<br></b>"$myrow["Title"]);
   
printf("<p align=\"center\">%s</p>"$myrow["Tutorial"]);
} else {
    
// show employee list
   
$result mysql_query("SELECT * FROM Tutorial",$db);
    if (
$myrow mysql_fetch_array($result)) {
      
// display list if there are records to display
      
do {
        
printf("<a href=\"%s?id=%s\">%s</a><br>\n"$PHP_SELF$myrow["id"], $myrow["Title"]);
      } while (
$myrow mysql_fetch_array($result));
    } else {
      
// no records to display
      
echo "Sorry, no records were found!";
    }
}

Reply With Quote
  #2 (permalink)  
Old 02-06-04, 10:03 PM
tltran tltran is offline
Newbie Coder
 
Join Date: Jan 2004
Location: Montreal
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
First what I suggest is to make a debug

are you sure that your that you have an Id ?

you can try a debug mode like:

if($id){
echo "id= $id";
} else {
echo "No id";
}

then try step by step to debug your script I have read your SQL query and everything seem to be good.

To make sure that your function work well is to do some debug mode.
__________________
Thanh Liem Tran
When You have to run, you have to run
http://www.irunsoft.com
Reply With Quote
  #3 (permalink)  
Old 02-07-04, 05:19 PM
Bobd314 Bobd314 is offline
New Member
 
Join Date: Feb 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
The whole thing works it's just that it displays all tutorials and the $type part dont work right.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
The Art Nexus seeking PHP programmers TheArtNexus Job Offers & Assistance 5 02-26-08 03:08 AM
Programmer looking for work nefariousphp Job Offers & Assistance 0 01-25-04 07:24 PM
delphi programmer looking for work Ugnius Job Offers & Assistance 0 01-02-04 08:38 AM
$GLOBALS["PHP_SELF"] doesn't work - Why? kevin PHP 7 07-17-03 07:48 AM
Site works in Mozilla but doesn't work in IE khibinite The Lounge 4 07-08-03 04:00 AM


All times are GMT -5. The time now is 08:43 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.