My IT course work...

M

Mr. 47

Guest
well... i just uploaded the near working code for my IT courese work, but I need help.

http://mooses.34sp.com/mncc

as you can seethe db access code is propper broke... help, please

http://www.php.net sugested removing ;s from some lines, the query, but this only caused parse errors..
 
M

Mr. 47

Guest
PS only the gallery and home pages have anything in...
 
J

Jonty

Guest
Hi Mr.47

If at all possible could you post the PHP source?, since it's very hard to guide you without.

Kind Regards

Jonty

P.S. Are you allowed help? :p
 
S

Shocko

Guest
Warning: Supplied argument is not a valid MySQL result resource in /usr/local/psa/home/vhosts/mooses.34sp.com/httpdocs/MNCC/index.php on line 104
That tells you exactly what's wrong :p
 
J

Jonty

Guest
Indeed it does, but such results are not always easy to interpret if you're unfamiliar with the languages involved, which I'm guessing is the case since Mr.47 is learning.

Kind Regards
 
M

Mr. 47

Guest
i'm not ment to be using PHP/ MySQL but I am... they insisted on the use of FrontPage and Access.. but I refuced

I've been learning MySQL on and off fr about 3 months.. and have been using basic PHP for years but only recentally came accross this error after addopting php.net's method for MySQL stuff
Code:
<?PHP

if($page !== "home" and $page !== "gallery" and $page !== "trip" and $page !== "canoeing" and $page !== "links"){
    $page = "home";
}

$db_name = "moosdb";

$connection = mysql_connect('localhost', '#####', '#####') or die($db_error = "Data-Base Connection Error");

mysql_select_db($db_name);

$mysql_date = date(Y-m-d);

$normal_date = date("jS of F, Y");

?>

header

<?PHP
        
        if($db_error){
            print($db_error);
            exit;
        }
        
        if($page == "home"){
            print("<center>News / Events</center>
\n");
            
            $query_news = "select * from mncc_news order by news_date desc, news_id desc limit 0,6";
            $result_news = mysql_query($query_news);
            
            print("Welcome to the Malton and Norton Canoe Club Web Site...

\nNews:
\n");
            
            print("<table width=\"600\" borders=\"0\">\n");
            
            while($row  = mysql_fetch_array($result_news)){
                print("<tr>\n<td>Date: $row[news_date]</td>\n<td>$row[news_title]</td>\n</tr>\n<tr>\n<td colspan=\"2\">$row[news_story]</td>\n</tr>\n<tr>\n<td colspan=\"2\">By $row[news_author]</td>\n</tr>");
            }
            
            print("</table>\n");
            
            print("Showing $mysql_affected_rows News Article(s)
\n");
            
            print("
\nEvents:
\n");
            
            print("<table width=\"600\" borders=\"0\">\n");
            
            print("<tr>\n<td width=\"100\">Date: YYYY/MM/DD</td>\n<td width=\"100\">Name:</td>\n<td width=\"400\">Description:</td>\n</tr>");
            
            $query_event = "select * from mncc_events where event_date >= $mysql_date order by event_date desc, event_id desc limit 0,10";
            $result_event = mysql_query($query_event);
            
            while($row = mysql_fetch_array($result_event)){
                print("<tr>\n<td>$row[date]</td>\n<td>$row[title]</td>\n<td>$row[story]</td>\n</tr>");
            }
            
            print("</table>\n");
            
            print("Showing $mysql_affected_rows Event(s)\n");
        }
?>

footer...

as you can see its a mess...
 
J

Jonty

Guest
Just one thing I spotted, the line . . .

Code:
mysql_select_db($db_name);
. . . perhaps ought to be . . .
Code:
mysql_select_db($db_name,$connection);
. . . as the $connection database details are required in order to establish any form of connection. I think this alone may be what is causing the errors. If not, please do say and I'll have another look (it's hard checking code you don't write, since you have to stop yourself from picking up on things which are merely different, not necessarily wrong, to the way in which you yourself do things :)).

Kind Regards

Jonty

P.S. Be sure to check your project comes within the guidelines laid down by your course, as FrontPage and Access can be vastly different to 'pure' PHP and MySQL. I'd just hate to see your project be inadmissable due to such a change of direction :) Good luck!
 
M

Mr. 47

Guest
well I was told that I could use PHP & MySQL as long as I documented why... so I did.

I've never bothed to put $connection in the query function before... how odd. I'll try it when I get home...
 

Users who are viewing this thread

Top Bottom