Jump to content

Invalid link resource - CANT SEE WHY AND ITS REALLY BUGGING ME!


ukweb

Recommended Posts

Hi

 

I have a CMS system which I am slowly replacing with a new version which is basically coded better for speed improvements. One part just wont work though. this chunk of code is in a file called 'framework.php' and is required by 'index.php'.

 

As far as I can see its coded correctly, its code lifted straight from the old framework (which runs side by side with this one until the transition is complete. There are no code duplications as old code is removed as new code is added).

 

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /www/allturf.co.uk/admin/framework.php on line 194 is the error. heres the code at fault:

 

function new_page($title, $text, $short_text, $lang) {

global $date_time, $uni_gen;
$text = strip_html($text);

$insertSQL = sprintf("INSERT INTO pages (lang, p1, p2, title, uni_id, date_time) VALUES (%s, %s, %s, %s, %s, %s)",
	GetSQLValueString($lang, "text"),
	GetSQLValueString($short_text, "text"),
	GetSQLValueString($text, "text"),
	GetSQLValueString($title, "text"),
	GetSQLValueString($uni_gen, "text"),
	GetSQLValueString($date_time, "text"));

mysql_select_db($database_sql, $sql);
$result = mysql_query($insertSQL, $sql) or die(mysql_error());

if ($result) {
	return true;
}
}

Link to comment
Share on other sites

...That's further up in the 'framework.php' file;

 

$hostname_sql = "localhost";
$database_sql = "db26403_allt";
$username_sql = "root";
$password_sql = "root";
$sql = mysql_pconnect($hostname_sql, $username_sql, $password_sql) or trigger_error(mysql_error(),E_USER_ERROR); 

 

This is why I cant understand it, everything is there and it does appear to be coded correctly. No other scripts are having problems just this one...

Link to comment
Share on other sites

mysql_pconnect has to be used with caution when it comes to apachy/msql as it needs abit of fine tuneing due the fact that it can run out of connections, thus giving that error.

 

Try just using the normal mysql_connect, unless there is a reason you need the connection to stay active after your script ends.

Link to comment
Share on other sites

You called the function

mysql_select_db($database_sql, $sql);

 

inside a function and hence can't access the variables declared outside.

 

Either you have to pass the variables "$database_sql" and "$sql" to the function. (I guess you are not using classes)

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.