Solved

Display database records - "A non well formed numeric value..." - error

Posted on 2010-09-15
3
307 Views
Last Modified: 2012-06-27
I am using wordpress for a client site and I am also using a custom page template to pull records from another database other than the WP one.

I am getting this error message:

Notice: A non well formed numeric value encountered in /home/content/35/6358435/html/wp-content/themes/shanley/recipes.php on line 70

Any ideas why that is appearing there? I have attached my code below.

Thanks,

Ryan
<?php error_reporting(E_ALL); ?>

<?php /* Template Name: Family Recipes */ ?>
<?php include_once("recipes/inc/config.inc.recipe-wp.php");?>
<?php get_header(); ?>

<?php if(isset($_GET['r_id']))
{
?>

		<?php
		$sql    = "
		SELECT recipeList.r_id,recipeList.r_contents,recipeList.c_id,recipeList.o_id,recipeList.date_added,recipeList.r_name,categories.c_name,shan_fam.o_name
		FROM recipeList 
		INNER JOIN categories ON recipeList.c_id = categories.c_id
		INNER JOIN shan_fam ON recipeList.o_id = shan_fam.o_id WHERE r_id = ".$_GET['r_id']."";
		?>


	<div id="content" class="grid_8" role="main">
		<?php
			$querySingle  = mysql_query($sql) or die(mysql_error());
			while($row = mysql_fetch_array($querySingle)){
		?>
			<div class="postNews">
				<div class="posttitle">
					<h2 class="title"><a href="&r_id=<?php echo $row['r_id']; ?>"><?php echo $row['r_name']; ?></a></h2>
					<h3>Posted under: <?php echo $row['c_name']; ?> and submitted by <?php echo $row['o_name']; ?></h3>
				</div>
				
				<div class="body">
					<?php echo $row['r_contents']; ?>
				</div>
				<div class="tag"><?php echo date("m/d/y g:i (A)", $row['date_added']); ?></div>
			</div><!-- end .post -->
			
		<?php } ?>
</div>

<?php
}
else
{
?>


		<?php
		$sql    = "
		SELECT recipeList.r_id,recipeList.r_contents,recipeList.c_id,recipeList.o_id,recipeList.date_added,recipeList.r_name,categories.c_name,shan_fam.o_name
		FROM recipeList 
		INNER JOIN categories ON recipeList.c_id = categories.c_id
		INNER JOIN shan_fam ON recipeList.o_id = shan_fam.o_id";
		?>


	<div id="content" class="grid_8" role="main">
		<?php
			$query  = mysql_query($sql) or die(mysql_error());
			while($row = mysql_fetch_array($query)){
		?>
			<div class="postNews">
				<div class="posttitle">
					<h2 class="title"><a href="?r_id=<?php echo $row['r_id']; ?>"><?php echo $row['r_name']; ?></a></h2>
					<h3>Posted under: <?php echo $row['c_name']; ?> and submitted by <?php echo $row['o_name']; ?></h3>
				</div>
				
				<div class="body">
					<?php echo $row['r_contents']; ?>
				</div>
				<div class="tag"><?php echo date("m/d/y g:i (A)", $row['date_added']); ?></div>
			</div><!-- end .post -->

<?php }} ?>

<?php get_footer(); ?>

Open in new window

0
Comment
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
philkeene earned 500 total points
ID: 33686391
$row['date_added'] is almost certainly a mysql format date. This should be an integer as defined by...
http://uk.php.net/manual/en/function.date.php
in order to fix this you can use...
                                 <div class="tag"><?php echo date("m/d/y g:i (A)", strtotime($row['date_added'])); ?></div>  

in place of...
                                <div class="tag"><?php echo date("m/d/y g:i (A)", $row['date_added']); ?></div>  
 
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 33686436
thanks! the trick was adding the strtotime? To convert?

Ryan
0
 
LVL 4

Expert Comment

by:philkeene
ID: 33686458
Yeah...
$row['date_added'] was outputting something like... 2010-09-15 21:53:21
but the function was wanting an integer that is a timestamp (the number of seconds since 00:00:00 1st January 1970)
strtotime converts from the text to a timestamp.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now