Link to home
Start Free TrialLog in
Avatar of Elucidate-Technologies
Elucidate-TechnologiesFlag for Puerto Rico

asked on

INSERT query inserting Resource id #5 in MySQL table

I am trying to insert a value from a variable to a mySQL table, but instead of the value, it is inserting Resource id #5. I can`t find the problem.

$query = "SELECT categorias.desc from categorias where categorias.id = '".$_SESSION['clasificacion']."'";
$cat_descrip = mysql_query($query);

Open in new window


$query2 = "INSERT INTO `profile_test` (clasificacion) VALUES ('$cat_descrip')";
mysql_query($query2);

Open in new window


profile_test.clasificacion is getting "Resource id #5"
ASKER CERTIFIED SOLUTION
Avatar of Marco Gasi
Marco Gasi
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Elucidate-Technologies

ASKER

Thanks. That did it :)
Thanks for point!

Just a note:
mysql_query "For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error." (see Php manual: http://it1.php.net/mysql_query).
So you have to 'convert' this resource in radable and usable data using 'fetch' functions:

mysql_fetch_array (http://it1.php.net/manual/en/function.mysql-fetch-array.php)
mysql_fetch_assoc(http://it1.php.net/manual/en/function.mysql-fetch-assoc.php)
mysql_fetch_object(http://it1.php.net/manual/en/function.mysql-fetch-object.php)

Keep in mind that the use of all these functions is discouraged: you should move on to mysqli od PDO.

Cheers