I'm trying to pull the meta data & page titles from my db, but the method below just throws an error. I'm wondering if I have messed up somehow putting a variable as a case in the switch statement?
I just get this warning: <meta name="keywords" content="<br />
<b>Warning</b>: sprintf() [<a href='function.sprintf'>function.sprintf</a>]: Too few arguments in <b>/home/test/public_html/testsite/functions.php</b> on line <b>163</b><br />
<br />
<b>Warning</b>: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in <b>/test/easmaweb/public_html/testsite/functions.php</b> on line <b>138</b><br />
">


Here's my database table:


Here's my code:
PHP Code:


// Turn a result into an assoc array
function result_to_assoc($result)
    {
      
$result_array = array();
        for (
$i=0$row mysql_fetch_assoc($result) ; $i++)
        {
           
$result_array[$i] = $row
        }
        
        return 
$result_array;
    }

// Output the page data
    
function pages($name)
  {
      
db_connect();            
    
$query sprintf("SELECT page_keywords, page_description, page_title FROM pages WHERE page_file = %s");             
    
$result mysql_query($query);        
    
$result result_to_assoc($result);
    return 
$result;      
   } 
Now in my html file I have this (I have rewrite on, so urls will be /home or /our-team e.t.c.)
PHP Code:
<meta name="keywords" content="<?php
$url 
$_SERVER['REQUEST_URI'];
$url preg_replace ('/\/testsite\//','',$url);
$page $url;
$keywords pages($page);   
 switch (
$page)
      { 
        case 
$keywords:
        echo 
$keywords['page_keywords'];
            break;
    default:
    echo 
"testing";
       }
?>">