Solved

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

Posted on 2010-09-15
3
325 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

726 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