LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-18-2005, 03:49 PM   #1
SpiderIRE
Member
 
Registered: Jan 2005
Distribution: FC (Planet CCRMA Kernel)
Posts: 81

Rep: Reputation: 15
PHP/MySQL Problem!


I'm not sure if this is the right place to post this, but its the closet one i could fine! this is the code: (its out of a PHP/MySQL book i'm using)

PHP Code:
<?php
$link 
mysql_connect("localhost","user","pass") or die(mysql_error());
     
mysql_select_db("wiley") or die (mysql_error());

$query "SELECT
      movie_name,
     movie_director,
     movie_leadactor
     FROM
     movie"
;

     
$result mysql_query($query,$link) or die(mysql_error());
     
$num_movies mysql_num_rows($result);


$movie_header=<<<EOD
     <h2><center>Movie Review Database</center></h2>
     <table  width='70%' border='1' cellpadding='2'
      cellspacing='2' align='center'>
          <tr>
               <th>Movie Title</th>
               <th>Movie Director</th>
               <th>Movie Lead Actor</th>
          </tr>

EOD;

function 
get_director() {
     global 
$movie_director;
     global 
$director;

     
$query_d "SELECT people_fullname
          FROM people
          WHERE people_id='
$movie_director' ";
     
$results_d mysql_query($query_d) or die(mysql_error());
     
$row_d mysql_fetch_array($results_d);
     
extract ($row_d);
     
$director $people_fullname;
}

function 
get_leadactor() {
     global 
$movie_leadactor;
     global 
$leadactor;

     
$query_a "SELECT people_fullname
          FROM people
          WHERE people_id='
$movie_leadactor'";
     
$results_a mysql_query($query_a) or die(mysql_error());
     
$row_a mysql_fetch_array($results_a);
     
extract ($row_a);
     
$leadactor $people_fullname;
}

while(
$row mysql_fetch_array($result))
{
     
$movie_name $row['movie_name'];
     
$movie_director $row['movie_director'];
     
$movie_leadactor $row['movie_leadactor'];

     
//get director's name from people table
     
get_director($movie_director);

     
//get lead actor's name from people table
     
get_leadactor($movie_leadactor);

     
$movie_details .=<<<EOD
     <tr>
          <td>
$movie_name</td>
          <td>
$director</td>
          <td>
$leadactor</td>
     </tr>
EOD;
     }


$movie_details .=<<<EOD
<tr>
     <td>Total :
$num_movies Movies</td>
</tr>
EOD;

$movie_footer ="</table>";

$movie =<<<MOVIE
               $movie_header
               
$movie_details
               
$movie_footer
MOVIE;

     print 
"There are $num_movies movies in our database";
     print 
$movie;
?>
this doesn't work and doesn't give u any errors! i can't see the problem!! any help please????

Thanks
David

Last edited by SpiderIRE; 10-19-2005 at 10:13 AM.
 
Old 10-18-2005, 04:02 PM   #2
clb
Member
 
Registered: Sep 2004
Location: UK
Distribution: Ubuntu
Posts: 117

Rep: Reputation: 16
Couple of suggestions at this point:
1. Try adding various echo("xxx"); statements throughout your code, that will help you to diagnose where the problems are
eg
PHP Code:
//Open connection to database server
echo("Connected to database<br />");
//Select database
echo("Database selected<br />"); 
2. Check that there are records to be displayed.

Quick note, if you enclose your php code in [P H P]xxx[/P H P] tags, just remove the spaces between the letters. This will format and colour your PHP code correctly, and make it much easier to read (like above).

Chris
 
Old 10-19-2005, 10:14 AM   #3
SpiderIRE
Member
 
Registered: Jan 2005
Distribution: FC (Planet CCRMA Kernel)
Posts: 81

Original Poster
Rep: Reputation: 15
so i edited the code to show the 'colours'!! (i.e. the [p h p]xxxx[/p h p] tags)! anyone have any ideas as to what is wrong with it??

Cheers,
David

Last edited by SpiderIRE; 10-19-2005 at 10:16 AM.
 
Old 10-19-2005, 11:24 AM   #4
ftenario
Member
 
Registered: Jul 2003
Location: Camarillo, CA
Distribution: Debian
Posts: 48

Rep: Reputation: 15
Since you maybe running this on your local machine, check your php.ini configuration to report all errors. That way, you get an idea on what is going on if there are errors
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
php-mysql problem need help productive Linux - Software 1 04-28-2005 02:27 PM
Problem with PHP and MySQL eam Programming 2 08-24-2004 02:33 PM
Problem getting PHP to recognize MySQL, Using PHP 4.0 and MySQL 4.0.20 d2army Programming 4 06-27-2004 08:54 PM
MySQL / PHP problem jjd228 Linux - Software 5 03-15-2004 10:28 AM
problem with mysql and php nshoboul Linux - Software 3 11-07-2003 02:50 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration