Jump to content

mysql_query(): supplied argument is not a valid MySQL-Link


Pieter Lategan

Recommended Posts


Hi I got this message       Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\xampp\htdocs\chapter2\table1.php on line 23


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<?php 

//connect to MySQL
$connect = mysql_connect ("localhost", "root","")
or die ("Hey loser, chech your server connection.");

// make sure we're using the right database
mysql_select_db ("moviesite")
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> Year of Release</th>
<th> Movie Director</th>
<th>Movie Lead Actor</th>
<th> Movie Type</th>
</tr>
</table>
EOD;

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

$movie_details .=<<<EOD
<tr>
<td> $movie_name</td>
<td> $movie_director</td>
<td> $movie_leadactor</td>
</tr>
EOD;
}

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


echo $movie_header;
?>
</body>
</html>



Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.