call up another db and editing it

Started by Hot Rides, April 09, 2008, 09:22:45 AM

Previous topic - Next topic

Hot Rides

just tried on a fresh install of coppermine and smf with no mods at all and it did not work at all.

Hot Rides

I found the problem while trying to fix another problem!!!

your original code

if($user_settings['ID_MEMBER'] != 0)
{
$sql = "SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = " . (10000 + $user_settings['ID_MEMBER']);
$result = cpg_db_query($sql, $this->link_id);
if(mysql_num_rows($result) == 0)
{
$sql = "INSERT INTO {$CONFIG['TABLE_ALBUMS']} (title, category) VALUES ('My album', " . (10000 + $user_settings['ID_MEMBER']) . ")";
cpg_db_query($sql, $this->link_id);
}
mysql_free_result($result);
}


Replaced with my new code
if($user_settings['ID_MEMBER'] != 0)
{
$sql = "SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = " . (10000 + $user_settings['ID_MEMBER']);
$result = cpg_db_query($sql);
if(mysql_num_rows($result) == 0)
{
$sql = "INSERT INTO {$CONFIG['TABLE_ALBUMS']} (title, category) VALUES ('My album', " .(10000 + $user_settings['ID_MEMBER']) . ")";
cpg_db_query($sql);
}
mysql_free_result($result);
}


not much difference except I removed the $this->link_id from the db queries

So now it works on the test site, we will see if it works on the live site.

Hot Rides

Mark this thread as solved!

by the way, rsw686, what was the purpose of the $this->link_id ???

rsw686

Quote from: Hot Rides on April 17, 2008, 05:43:22 PM
by the way, rsw686, what was the purpose of the $this->link_id ???

The link_id is the mySQL resource to use for the database query. If you don't specify it, it will use the last open database connection. Technically the bridge should initialize that value for its class. I'm not sure why that is not happening on your system. If it works then I wouldn't worry too much about it.
The Reptile File
Everything reptile for anyone reptile friendly

Aquaria Talk
Community for freshwater and saltwater aquariums enthusiasts

Advertisement: