...

View Full Version : Multiple Error in code



golffor1
03-30-2010, 04:48 AM
I get the following error in the code below

"Connected successfully to tableconnected to database:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /hermes/bosweb/web251/b2510/ipw.cypressp/public_html/counter.php on line 28
Error creating database: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #3' at line 1
Warning: setcookie() expects parameter 2 to be string, resource given in /hermes/bosweb/web251/b2510/ipw.cypressp/public_html/counter.php on line 36
Array ( ) Welcome guest!"



<?php

// connect to mysql
$link = mysql_connect('localhost', 'db', 'password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
else {
echo 'Connected successfully to table';
}


// select database
$db_selected = mysql_select_db('table', $link);

if (!$db_selected)
{
die('Not connected : ' . mysql_error());
}
else
{
echo 'connected to database: ';
}
$query = mysql_query("SELECT counter FROM stats WHERE id=1, $link");
$results = mysql_query($query, $link);
echo $results;
if (mysql_query($link,$results))
{
echo "Database my_db created";
}
else
{
echo "Error creating database: " . mysql_error();
}
setcookie("TestCookie", $query, time()+3600); /* expire in 1 hour */

while($row=mysql_fetch_assoc($query)) {
$stats=$row['counter']; }

echo $counted;


// Print a cookie
echo $_COOKIE["testcookie"];

// A way to view all cookies
print_r($_COOKIE);

if (isset($_COOKIE["Testcookie"]))
echo "Welcome " . $_COOKIE["TestCookie"] . "!<br />";
else
echo "Welcome guest!<br />";
?>



Can you tell me if there is an error in my code

Fumigator
03-30-2010, 05:23 AM
Yes, I think it's safe to say there is an error in your code :p

golffor1
03-30-2010, 05:26 AM
Maybe I should clarify...can you tell me what the error means or how I can fix it?

Fumigator
03-30-2010, 06:46 AM
Search this forum for "valid mysql resource", you will find this question has been asked and answered a hundred times before.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum