Gossamer Forum
Home : Products : Gossamer Links : PHP Front End :

Printer Friendly

Quote Reply
Printer Friendly
Hi All,

I try to run script below but i got an error message 'Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/username/public_html/database/detailed.php on line 14'

Code:
<?php

function connect(){
$link = @mysql_pconnect ("localhost", "username", "password");
if ($link && mysql_select_db("db_name"));
return ($link);
return (FALSE);
}

connect();

$query = "select * from table where id = '$link_id'";
$result = mysql_query($result);
$this = mysql_fetch_array($result);

?>

<html><head><title>Printer Friendly</title></head>
<body>

<?php
print "$this->title <p>";
print "$this->description";
?>

</body></html>

Please help, how to fix it?

Thanks
Quote Reply
Re: [reenee] Printer Friendly In reply to
What is the exact query you are using?

I'm no php expert but you should be using error catching code to find the problem.

Last edited by:

Paul: Jan 4, 2003, 11:38 AM
Quote Reply
Re: [Paul] Printer Friendly In reply to
Hi,

The query is something like printer.php?query=4554, what i need is to pull out the Title & Description on any ID.

Please tell me if i'm wrong, Thanks.
Quote Reply
Re: [reenee] Printer Friendly In reply to
No I mean the SQL query not the query string :)
Quote Reply
Re: [reenee] Printer Friendly In reply to
Try using this code to catch the error;

Code:
$query = "select * from table where id = '$link_id'";
$result = mysql_query($result);
$this = mysql_fetch_array($result);

// new part ...
$error = mysql_error();
if ($error) { echo $error; exit; }

Hope that helps :)

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

Andy: Jan 6, 2003, 8:09 AM
Quote Reply
Re: [Andy] Printer Friendly In reply to
Or just append it...

Code:
$result = mysql_query($result) or die(mysql_error());
Quote Reply
Re: [Paul] Printer Friendly In reply to
another thing....just after the '$query =' part, add the following to see what query is being run;

echo "Query being run: " . $query;

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Printer Friendly In reply to
Calling mysql_error() twice isn't probably the most efficient way. I noticed you edit your post. The way you had it originally was better.

Last edited by:

Paul: Jan 6, 2003, 8:08 AM