Pieter Lategan Posted July 3, 2011 Share Posted July 3, 2011 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> Link to comment https://forums.phpfreaks.com/topic/241015-mysql_query-supplied-argument-is-not-a-valid-mysql-link/ Share on other sites More sharing options...
Pikachu2000 Posted July 3, 2011 Share Posted July 3, 2011 Your connection is $connect, not $link. Link to comment https://forums.phpfreaks.com/topic/241015-mysql_query-supplied-argument-is-not-a-valid-mysql-link/#findComment-1237952 Share on other sites More sharing options...
Pieter Lategan Posted July 3, 2011 Author Share Posted July 3, 2011 Thank you that work but doenst give any data on my page , what do you think will the problem be? Link to comment https://forums.phpfreaks.com/topic/241015-mysql_query-supplied-argument-is-not-a-valid-mysql-link/#findComment-1237954 Share on other sites More sharing options...
mikesta707 Posted July 3, 2011 Share Posted July 3, 2011 Are you sure your database is populated with data? Is there a mysql error? Link to comment https://forums.phpfreaks.com/topic/241015-mysql_query-supplied-argument-is-not-a-valid-mysql-link/#findComment-1237956 Share on other sites More sharing options...
Pieter Lategan Posted July 3, 2011 Author Share Posted July 3, 2011 I got my problem it was a typing mistake. Thank you. Link to comment https://forums.phpfreaks.com/topic/241015-mysql_query-supplied-argument-is-not-a-valid-mysql-link/#findComment-1237958 Share on other sites More sharing options...
mikesta707 Posted July 3, 2011 Share Posted July 3, 2011 OK. marking your topic as solved Link to comment https://forums.phpfreaks.com/topic/241015-mysql_query-supplied-argument-is-not-a-valid-mysql-link/#findComment-1237961 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.