Jump to content

Recommended Posts

The below is outputting:

 

Array

Fatal error: Unsupported operand types in /home/zyquo/public_html/area51entertainment.co/maintenance/home.php on line 28

 

So clearly $project_row_num is coming out as an array, and the multiplication is failing because its got a string not a number. I just don't see why it's getting an array out of $project_row_num.

 

<?php
$num_projects=15;
$scroller_projects="";

require_once 'db_select.php';
$project_query_num="SELECT COUNT(*) FROM $tbl_name";
$project_result_num=mysql_query($project_query_num);
$project_row_num=mysql_fetch_assoc($project_result_num);

echo $project_row_num;	
//if($project_row_num <= $num_projects){
$project_query="SELECT * FROM $tbl_name";
$project_result=mysql_query($project_query);
/*}
else{
$project_query="SELECT * FROM $tbl_name WHERE project_release_date BETWEEN $start_date AND $end_date LIMIT 0,$num_projects";
$project_result=mysql_query($project_query);
}*/
$i=1;
while($project_row=mysql_fetch_array($project_result)){
extract($project_row);
$scroller_projects.='<div class="project_entry" tabindex="'.$i.'" onclick="sndReq(\''.$project_id.'\');">Test</div>';
$i++;
}
if($project_row_num==""){
$films_row_num=$num_projects;
}
$scroller_width=$project_row_num*114;
$content='
<div class="video_scroller_wrapper">
<div class="video" id="tabs">

</div>


<div class="recentfilms_wrapper">
<div class="left_arrow"><img src="arrow_left.png" alt="Left" title=""  class="arrow_left" onclick="jumpLeft(\'recentfilms\')" onmouseover="startScrollLeft(\'recentfilms\')" onmouseout="stopScroll()" /></div> 
<div id="recentfilms">
<div id="scroller" style="width: '.$scroller_width.'px;">
'.$scroller_projects.'
</div>
</div>
<div class="right_arrow"><img src="arrow_right.png" alt="Left" title="" class="arrow_right" onclick="jumpRight(\'recentfilms\')" onmouseover="startScrollRight(\'recentfilms\')" onmouseout="stopScroll()" /></div>
</div>
</div>
<div class="news_wrapper">
<div class="news">
<div class="news_title"><span class="category_title_text">Latest News</span></div>
<div class="news_text">
<iframe src="http://www.indiegogo.com/project/widget/75876?a=9030" style="width: 224px; height: 429px; position: relative; left: 3px; top: 15px; border: 0px; overflow: hidden;"></iframe>
</div>
</div>
</div>
';
?>

Link to comment
https://forums.phpfreaks.com/topic/259788-array-being-output-unsure-why/
Share on other sites

mysql_fetch_assoc() returns an associative array. $project_result_num should be an int though ...

 

Right, that's what I figured; but I've tried mysql_fetch_array (which is clearly an array), and mysql_fetch_row which also returns an array. What should I be using here?

Got it with this:

 

$project_query_num="SELECT COUNT(*) FROM $tbl_name";
$project_result_num=mysql_query($project_query_num);
$project_row_num=mysql_fetch_row($project_result_num);
$project_row_num=$project_row_num[0];

 

Was trying to stay away from using mysql_num_rows; wanted to do the counting entirely with MySQL.

 

 

http://www.area51entertainment.co/maintenance

Actually, since you are using a COUNT() in your query and you are not using an alias name, you would need to use mysql_fetch_row or mysql_fetch_array and then access the zero'th element of that array to get the count.

 

Do you have php's error_reporting set to E_ALL so that all the errors php detects will be reported and displayed? You would be getting several notice and perhaps warnings from your code.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.