Hi all, So I set up a database on my server, made an account, and created a table called "content". I used MySQL workbench to edit values in the table. "category", "title", and "description" are all varchar(45) 's. Here's a pic of the table. I'm trying to print the content in my page, using this script: $category = $_GET["cat"]; if (($category == "") || ($category == NULL)) $category = 'index'; $conn = mysql_connect("$dbhost", "$dbuser", "$dbpass") or die ("Can't connect"); mysql_select_db($dbname, $conn); $query = sprintf("SELECT * FROM content WHERE category='%s'", mysql_real_escape_string($category)); $q = mysql_query($query) or die("Bad query of links table: " . ">$query<" . mysql_error()); print($q); Code (markup): but all it prints is "Resource id #4" (see pic) Any ideas how I can edit my script or my database to print contents correctly? Any tutorials/links to how to print tables from databases would be helpful too. Thanks!
Consider this a bump with info. I isolated the problem, I think. I echo'd each variable, and it appears that the connection (mysql_connect) is fine (does not return false), but the mysql_selectdb does. Any ideas? Pic in original post shows existence of the database "dogbertData" as well as the table "content".
Hello, try: $query = sprintf("SELECT * FROM content WHERE category='%s'", mysql_real_escape_string($category)); while($row = mysql_num_rows($query)){ echo $row['col1_name'] ."". $row['col12name'] ."". $row['col3_name'] .".......". $row['colN_name']; } thank, daksh
Thanks, I put it in, but no content printed. I think the initial problem is with mysql_selectdb. If that returns false, how can I expect the query to even be submitted? amiright?
so i fixed the mysql_selectdb problem, i had to add bind-address = 192.168.42.102 Code (markup): to my /etc/my.cnf. I'm still not able to print the data however, it simply writes "Resource id #n", where N is a number usually 1-4 (right now its printing 3). I think its related to the number of connections open... not sure.