I am using the following code to find whether the content area is using a command (commands are held in a table column) or not. The commands call on "quick content" which are default areas that you might see regularly around the site.

This feature ensures they are not different or irregular each time and all changes made to the row will reflect on all pages calling it.

<?
$areain = "$styles[area2]";
$tables = mysql_query("SELECT * FROM `quick_content` WHERE `quickref`='$areain'");
$fetch = mysql_fetch_array($tables);
$frows = mysql_num_rows($tables);
$area = $fetch[quickref];
if($frows==1){
?>
<? echo"$fetch[area]"; ?>
<? }else{ ?>
<?php eval('?>' . $styles[area2] . '<?php '); ?>
<? } ?>

My problem is with:
$areain = "$styles[area2]";

the code works on the page and area using the command. This also executes/echo's the content being requested although on the pages that do not call the command I get the following error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/habbonow/public_html/V4/index.php on line 274

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/habbonow/public_html/V4/index.php on line 275

I have tried:

$areain = '$styles[area2]';

This causes the command not to be executed and therefore it just shows the command (e.g. %contactus)

Any help would be appreciated
Thank you in advance!

Recommended Answers

All 4 Replies

try..

$areain = $styles;

I tried this and it does execute the code although it still causes the fetch errors on the other pages..

//change this with basic mysql_fetch_array.. just try
$area = $fetch[quickref];

disregard my post previously

//I think you forgot to add '' in $fetch[quickref]
$area = $fetch['quickref'];
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.