Jump to content

Getting Resource id #11 while trying to connect..


mike12255

Recommended Posts

So i tried using "DEFINE" for the first time and im using the variables i defined to connect but it reports back this error:

 

Warning: mysql_query(): 11 is not a valid MySQL-Link resource in /home/content/p/p/f/ppffffpp/html/avalancheatblue.com/nc-cms/system/modules/storage/mysql.php on line 25

 

Can anyone look at the function and find out why this is?

 

<?php

function nc_save_content ($name, $data)
{	

$nc_db_link = mysql_connect(NC_DB_HOST, NC_DB_USER, NC_DB_PASSWORD);
$nc_db_link = nc_db_link($nc_db_link, NC_DB_DATABASE);

$x=3;
while($x != 0){
nc_check_content($name.$x, "Edit Me History" . $x);//line 9-14 making sure the history exists (if not creates it)[function is internal]
$x--;
}

//Now start backwards and work from 2-0 moving files for history
$x=2;
$z=1;
while($x != 0){
$temp2 = $name.$x;
$get = "SELECT content FROM " .NC_DB_PREFIX."content WHERE name ='".$temp2."'";
$res = mysql_query($get,$nc_db_link) or die (mysql_error());
$row = mysql_fetch_assoc($res);

$temp = $x + 1;
$insert = "UPDATE ".NC_DB_PREFIX."content SET content='".$row['content']."' WHERE name='".$name.$temp."'";
$res2 = mysql_query($insert,$nc_db_link) or die (mysql_error());
$x--;
}

//one last thing move the current entry to 1 before we overwrite it!!!
$sql = mysql_query("SELECT content  FROM " .NC_DB_PREFIX."content WHERE name ='".$name."'",$nc_db_link) or die (mysql_error());
$row = mysql_fetch_assoc($sql);

$insert = mysql_query ("UPDATE ".NC_DB_PREFIX."content SET content='".$row['content']."' WHERE name='".$name."1"."'",$nc_db_link) or die (mysql_error());



nc_check_content ($name, "Edit Me!"); // Make sure database entry exists
$nc_db_result = mysql_query("UPDATE ".NC_DB_PREFIX."content SET content='".nc_db_escape($data)."' WHERE name='".$name."'", $nc_db_link);

if(!$nc_db_result) // Check for query errors
{
	nc_report_error("MySQL reported: ".mysql_error());
	exit();
}

mysql_close($nc_db_link); // Close connection
}
?>

Link to comment
Share on other sites

here is the nc_db_link function

 

<?php

function nc_db_link ($link, $_database)
{
if ($link)
{
	if (mysql_select_db($_database, $link))
		return $link;
	else
	{
		nc_report_error("MySQL reported: ".mysql_error());
		exit();
	}
}
else
{
	nc_report_error("MySQL reported: ".mysql_error());
	exit();
}
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.