Quotes as table names?
Posted: Mon Sep 05, 2011 7:04 am
I have been trying to make a wiki, and release it in an easy format. I have setup.php which sets the tables and things. The problem is it will not accept the variable as a table name. The way I am trying to do it is:
Which should return $pagenum as 1, however it errors with:
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource on line 6
How could I use a variable as a table name?
Code: Select all
<?php
include("setup.php");
include("database.php");
ob_start();
$table = "table_name";
$pagetest = mysql_query("select count(*) as count from '$table'");
$pages = mysql_fetch_object($pagetest)->count;
$pagenum = intval($pages);
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource on line 6
How could I use a variable as a table name?