?
Solved

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

Posted on 2010-09-15
3
Medium Priority
?
363 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 2000 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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses
Course of the Month16 days, 19 hours left to enroll

862 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