View Single Post
Old 19-03-2004, 13:48   #11
Richard M
Inactive
 
Join Date: Jun 2003
Location: Los Angeles, CA
Age: 47
Posts: 6,343
Richard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze array
Richard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze array
Re: PHP help needed this time :D

Quote:
Originally Posted by Bifta
Still gives me this error

Code:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in xxxxxxxxxxxxxxxxxxxxxxxxxxxx

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in xxxxxxxxxxxxxxxxxxxxxxxx
because styles=whatever is in the URL it's somehow trying to find that field in the DB by the look of it, when it can't find it it throws the above
I'm just guessing here but you'd need something like this:

PHP Code:
// Open SQL connection.

if (!$dbconnection) {
  echo( 
"<p>Unable to connect to the " .
        
"database server at this time.</p>" );
  exit();
}

// Select DB

@mysql_select_db($dbname) or die("Could not select database");

// The query for getting the $style

$result = @mysql_query("SELECT * FROM " . $table_name . " WHERE styles='" . $styles . "'");
if (!
$result) {
  echo(
"<p>Error performing query: " .
       
mysql_error() . "</p>");
  exit();
}

// Loop through the array and echo out the $style retrieved from the DB

while ( $row = @mysql_fetch_array($result) ) {
$styles = $row['styles'];
echo 
"<link rel=\"stylesheet\" href=\"$styles\" type=\"text/css\" />"; 
}

// Close SQL connection.

mysql_close($dbconnection); 
You could also use the more OOP way by using mysql_fetch_object() instead like so:

PHP Code:
// Open SQL connection.

if (!$dbconnection) {
  echo( 
"<p>Unable to connect to the " .
        
"database server at this time.</p>" );
  exit();
}

// Select DB

@mysql_select_db($dbname) or die("Could not select database");

// The query for getting the $style

$result = @mysql_query("SELECT * FROM " . $table_name . " WHERE styles='" . $styles . "'");
if (!
$result) {
  echo(
"<p>Error performing query: " .
       
mysql_error() . "</p>");
  exit();
}

// Get the object from the DB and echo out the $style.

$style_object = @mysql_fetch_object($result);
$styles = $style_object->styles;
echo 
"<link rel=\"stylesheet\" href=\"$styles\" type=\"text/css\" />"; 

// Close SQL connection.

mysql_close($dbconnection); 
Richard M is offline   Reply With Quote