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
Solved

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

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP not parsing ' character 12 46
Cpanel file manager 8 39
How has this flight information been added to this website? 7 31
Need to remove %20 from url in get 17 36
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

792 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