Jump to content

why doesn't this work?


delphi123

Recommended Posts

I've got a php page which is including a config page at the top like this:

 

include("includes/rating_config.php");

 

now in this config file I've put a variable declaring the table name ($table="table1";)

 

Now when I refer to it in the file within a function in the SQL query, it doesn't work, however when I put it inside the function like this:

function getRating($id){
$table = "table1";
$sel = mysql_query("SELECT rating_num FROM $table WHERE rating_id = '$id'");
}

It works perfectly!?

 

Is there a way of making my variable work within functions?

 

 

?>

Link to comment
https://forums.phpfreaks.com/topic/80880-why-doesnt-this-work/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.