You are here: Re: New Question about SQL with a variable « All PHP « IT news, forums, messages
Re: New Question about SQL with a variable

Posted by Tony Mays on 06/26/05 09:31

at first glance it appears that the mysql_query function is returning false.

try the following after the mysql_query function

if ($qresult)
echo "good result<br>";
else
echo "no result set<br>";

also

the select statement could be written as
$qresult = mysql_query("select * from ".$table." where d_thisfilm = '"
$var_film."'");

the select statement should translate to the following:
select * from films where d_thisfilm = 'filmbigfish'

hope this helps.

Tony


Kees Boer wrote:

> Hi, I've got a little bug, which I'm having a hard time debugging. It's
> probably in the syntax. This is the code:
>
> <?php
>
> $var_film = 'filmbigfish';
>
> // connect to mysql_server
> $mysqllink = mysql_connect( "localhost", "userid", "somepw" );
> // select database to use
> mysql_select_db( "kboer" );
>
> // primary table that directory uses
> $table = "films";
> $qresult = mysql_query( "SELECT * FROM `films` WHERE `d_thisfilm` =
> `$var_film` " );
>
> $row = mysql_fetch_assoc($qresult);
>
> ?>
>
> <html>
> <head>
> <title>Untitled Document</title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> </head>
>
> <body bgcolor="#FFFFFF" text="#000000">
>
> Everything works!
>
> </body>
> </html>
>
> I'm getting the following error.
>
> Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL
> result resource in
> /home/kboer/positive-entertainment.com/public_html/films/pages/resultlink.php
> on line 14
>
> What is the problem?
>
> Thanks!
>
> Kees

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация