Jump to content

Error Help


Kevin-J

Recommended Posts

I get this error when I try to use click.php

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/darkness/public_html/forums/clicks.php on line 26

No database selected

 

Here is the code:

 

<?php
setcookie("newclick", "1", time()+10);
define("VALID", "true");
require("includes/config.php");
require("functions/bfunc.php");
require("functions/vfunc.php");
$dbh=mysql_connect ("localhost", "myusernamehere", "mypasswordhere") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("vb3key");
if ($_GET[type] == 'aff') {
$affs = mysql_fetch_array(mysql_query("SELECT * FROM " . $prefix . "affiliates WHERE id = '$_GET[aid]'")) or die(mysql_error());
$new = $affs[clicks] + 1;
mysql_query("UPDATE " . $prefix . "affiliates SET clicks='$new' WHERE id='$affs[id]'") or die(mysql_error()); 
header("Location: $affs[url]");
} if (!isset($_GET[click]) and !isset($_GET[frame])) { 
error($em = "A critical error has occured.");
} elseif ($_GET[frame] == "true") {
process_frame($sitetitle, $_GET[urll], $tdir, $_GET[tut]);
} else {
$clicks = mysql_fetch_array(mysql_query("SELECT * FROM " . $prefix . "tutorials WHERE id = '$_GET[click]'")) or die(mysql_error());
$new = $clicks[clicks] + 1;
mysql_query("UPDATE " . $prefix . "tutorials SET clicks='$new' WHERE id='$_GET[click]'") or die(mysql_error()); 
echo "
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />
<title>$clicks[name] [$clicks[wname]]</title>
</head>
<frameset rows=\"90,*\" framespacing=\"0\" frameborder=\"yes\" border=\"0\">
<frame src=\"clicks.php?frame=true&urll=" . $clicks[url] . "&tut=$clicks[id]\" scrolling=\"no\" name=\"top\" />
<frame src=\"$clicks[url]\" name=\"main\" />
</frameset>
<noframes>
<body>
<center>Sorry you do not have frames enabled. Here is the link of the tutorial:<br />
<a href=\"$clicks[url]\">$clicks[url]</a></center>
</body>
</noframes>
</html>
";
}
?>

 

Whats going on?

Link to comment
https://forums.phpfreaks.com/topic/41056-error-help/
Share on other sites

There is something wrong with this query:

 

$clicks = mysql_fetch_array(mysql_query("SELECT * FROM " . $prefix . "tutorials WHERE id = '$_GET[click]'")) or die(mysql_error());

 

Why not just do it like this? Paste this code over the above one and tell us what error you get:

 

<?php

$clicks = mysql_query("SELECT * FROM " . $prefix . "tutorials WHERE id = '$_GET[click]'");
$result = mysql_fetch_array($clicks);

?>

 

Also you can check if the query is coming out right:

 

<?php

$clicks = "SELECT * FROM " . $prefix . "tutorials WHERE id = '$_GET[click]'";

echo $clicks;

?>

Link to comment
https://forums.phpfreaks.com/topic/41056-error-help/#findComment-198857
Share on other sites

u should add like a

 

echo of the query your trying to pass to sqlserver to see if its okay

 

like

 

mysql_query("UPDATE " . $prefix . "tutorials SET clicks='$new' WHERE id='$_GET[click]'") or die(mysql_error());

 

to

 

echo "UPDATE " . $prefix . "tutorials SET clicks='$new' WHERE id='$_GET[click]'";

//mysql_query("UPDATE " . $prefix . "tutorials SET clicks='$new' WHERE id='$_GET[click]'") or die(mysql_error());

 

to just debug your error

Link to comment
https://forums.phpfreaks.com/topic/41056-error-help/#findComment-198859
Share on other sites

There is something wrong with this query:

 

$clicks = mysql_fetch_array(mysql_query("SELECT * FROM " . $prefix . "tutorials WHERE id = '$_GET[click]'")) or die(mysql_error());

 

Why not just do it like this? Paste this code over the above one and tell us what error you get:

 

<?php

$clicks = mysql_query("SELECT * FROM " . $prefix . "tutorials WHERE id = '$_GET[click]'");
$result = mysql_fetch_array($clicks);

?>

 

Also you can check if the query is coming out right:

 

<?php

$clicks = "SELECT * FROM " . $prefix . "tutorials WHERE id = '$_GET[click]'";

echo $clicks;

?>

 

Error:

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/darkness/public_html/forums/clicks.php on line 27

SELECT * FROM tutorials WHERE id = '1'No database selected

Link to comment
https://forums.phpfreaks.com/topic/41056-error-help/#findComment-198861
Share on other sites

than u have a $prefix  problem

 

Well I in my config file its

 

$config[prefix]

 

so I changed it to that after what you said..but it still doesnt work. I do get a lil diffrent error though.

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/darkness/public_html/forums/clicks.php on line 27

SELECT * FROM tut_tutorials WHERE id = '1'No database selected

Link to comment
https://forums.phpfreaks.com/topic/41056-error-help/#findComment-198865
Share on other sites

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.