Solved

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

Posted on 2010-09-15
3
316 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

786 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