dannerz Posted March 2, 2014 Share Posted March 2, 2014 echo "you bought 1 archer"; $data = mysql_query("SELECT Vals FROM vals2 WHERE ValsN = 'archers'"); if ($data == false) exit("This has failed"); $msg = mysql_fetch_assoc($data); echo "<br />"; echo $msg;//this just says that it is an array echo "<br />"; echo $data; echo "<br />"; $msg2 = mysql_num_fields($data); echo $msg2; echo "<br />"; $msg3 = mysql_fetch_row($data);//this is not shown for some reason echo $msg3; This is the code. I'd like to get a number out of the db, and convert the resource into just a number value or string, then alter the number in PHP (i know how to do that part) then put the number back into the db (I think I can do that also) I just don't know how to convert a resource ("$data") into a variable to use in the PHP code. Hopefully you know what I mean. (the output of the above code is) Shop choice method. you bought 1 archer Array Resource id #4 1 Link to comment https://forums.phpfreaks.com/topic/286659-turning-a-mysql-resource-into-a-number-or-string/ Share on other sites More sharing options...
Barand Posted March 2, 2014 Share Posted March 2, 2014 have a look at the example in the manual http://uk1.php.net/manual/en/function.mysql-fetch-assoc.php Link to comment https://forums.phpfreaks.com/topic/286659-turning-a-mysql-resource-into-a-number-or-string/#findComment-1471259 Share on other sites More sharing options...
dannerz Posted March 2, 2014 Author Share Posted March 2, 2014 I'll start copy pasting and editing (thanks) Link to comment https://forums.phpfreaks.com/topic/286659-turning-a-mysql-resource-into-a-number-or-string/#findComment-1471260 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.