[PHP/MSSQL] Conversion failure

⚠️
Self Deleted
Joined
Sep 8, 2007
Messages
202
Reaction score
24
I seem to be having issues selecting data from 1 table and inserting it into another

Code:
Warning:  mssql_query() [[URL="http://127.0.0.1:81/Panel/function.mssql-query"]function.mssql-query[/URL]]: message: Conversion failed when converting the varchar value 'Resource id #7' to data type int.

Somewhere between

PHP:
$user_idx = mssql_query("SELECT user_idx FROM game..TB_CHARACTER WHERE CHARACTER_NAME = '$character'");
 mssql_query("UPDATE member..chr_log_info SET UserLevel = '7' WHERE id_idx = '$user_idx'");

I have confirmed that the problem is with $user_idx.
Both data types are int in database.

Any help help would be greatly appreciated.


Thanks for your time and patience

Sincerely,
- xHalloweenx
 
You need to do something with the query first before you can insert it into the database again. So,

PHP:
$query = mssql_query("SELECT user_idx FROM game..TB_CHARACTER WHERE CHARACTER_NAME = '$character'");
$row = mssql_fetch_row($query);
mssql_query("UPDATE member..chr_log_info SET UserLevel = '7' WHERE id_idx = '$row[user_idx]'");
 
Gives me

Code:
Notice: Undefined index: user_idx
on line
Code:
mssql_query("UPDATE member..chr_log_info SET UserLevel = '7' WHERE id_idx = '$row[user_idx]'");
 
I don't always come to here for everything, iv just been stuck on mssql.
and i usually do research first.
I have the same thing you have posted.
 
I got $row to work, thanks to
your post about "print_r($row)"
-----------
$row[1];
could of swore i tried that before and it gave me a offset error.

Thanks for your help, and the nice function.
 
Back