Quote:
Originally Posted by sarettah
I know where the issue is at this point.
Post the entire recipes.php page so I can kind of walk you through the mess.
please.
.
|
Thank you (again!).
PHP Code:
<?php
session_start();
("mysql:host=localhost;dbname=database", "user","password");
$table = "Recipes";
$metasettings = @mysql_fetch_assoc(@mysql_query("SELECT * FROM $table WHERE RecipeName, RecipeDescription, Author"));
$title = $metasettings['RecipeName'];
$description = $metasettings['RecipeDescription'];
$random_tags = $metasettings['Author'];
?>
<!DOCTYPE html>
<head>
<base href="https://gfy.com/" /><!--[if IE]></base><![endif]-->
<meta charset="UTF-8"/>
<title><?php echo $title; ?> Recipe | Sitename</title>
<meta name="Description" content="<?php echo $description; ?>">
<meta name="Keywords" content="<?php echo $title; ?> Recipe Ingredients Make <?php echo $title; ?> Recipes">
<link rel="stylesheet" href="style.css" type="text/css"/>
{-- removed all the random css testing crap --}
</head>
<body class="home page page-id-21 page-template-default ie et_includes_sidebar">
<?php
//in middle:
require('./templates/header.php');
?>
<div id="hd_logo0"><p><a href="http://www.domain.com">
<img class="alignnone size-full wp-image-169" alt="" src="logo.png" style="width: 310px"/></a></p>
</div>
</div> <!-- end .container -->
<?php
//in middle:
require('./templates/secondary.php');
?>
[b]included in secondary.php is a search function too, do you need to see the code for that?[/b]
<center><div id="main-area">
<div class="container" style="left: 0px; top: 0px">
<div id="content-area" class="clearfix">
<div id="left-area">
<div id="breadcrumbs" class="clearfix">
<a href="http://www.domain.com" class="breadcrumbs_home">Home</a> <span class="raquo">»</span>
</div> <!-- end #breadcrumbs --> <article id="post-21" class="post-21 page type-page status-publish hentry entry clearfix">
<div class="post_content clearfix">
<h1 class="title">Home</h1>
<h1 style="text-align: center;"></h1>
<?php
//in middle:
require('./templates/midbanner.php');
?>
<?php
// k33n and sarettah help with code fixes and examples from gfy
// check incoming params exist
if ( ! isset($_GET['id'] ) ) { //1.you were missing a )
// missing param, go to an error page for example
header('Location: index.php');
exit;
}
// You can now use $_GET['id'] which will be the id number passed
// any way you want.
// For example using a PDO connection called $pdo
// 2. Do the PDO connection
$pdo = new PDO("mysql:host=localhost;dbname=database", "dbuser","dbpass");
$table = "Recipes";
$sql = "SELECT * FROM $table WHERE ID = :id";
try {
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':id', $_GET['id'], PDO::PARAM_INT);
$stmt->execute();
$rows = $stmt->FetchAll(); // $rows now contains all the results of the query
}
catch( PDOException $e) {
echo $e-getMessage();
}
foreach ( $rows as $row ) {
// do things with the $row['column_name'] data
echo "<tr>";
echo "<p><h2>" . $row['Title'] . " Recipe.</h2></p>";
echo "<p><b>Ingredients</b></p>";
echo "<p> " . $row['Ingredients'] . "</p>";
echo "<p><b>Method</b></p>";
echo "<p>" . $row['Method'] . "</p>";
echo "</tr>";
}
// 4. You are using PDO, mysqli_fetch_array($result) will throw error: mysqli_fetch_array() expects parameter 1 to be mysqli_result.And $result is undefined.
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Title'] . "</td>";
echo "<td>" . $row['Ingredients'] . "</td>";
echo "<td>" . $row['Method'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
</div> <!-- end .post_content -->
</article> <!-- end .entry -->
</div> <!-- end #left-area -->
<?php
//in middle:
require('./templates/sidebar.php');
?>
</div> <!-- end #content-area -->
</div> <!-- end .container -->
</div> <!-- end #main-area --></center>
<?php
//in middle:
require('./templates/footer.php');
?>
<script type="text/javascript" src="jquery.form.min.js"></script>
<script type="text/javascript" src="superfish.js"></script>
<script type="text/javascript" src="jquery.fitvids.js"></script>
<script type="text/javascript" src="custom.js"></script>
</body>
</html>
Like I say, the recipes.php page works for everything else, its just not letting me throw the meta tag data in that I'd like to use.
The TABLE 'Recipes' contains the following columns...
RecipeID
Title
Description (not used but has data in it)
Ingredients
Method
Nutritional (not used but has data in it)
RecipeName (for metas)
RecipeDescription (for metas)
Author (for metas)
The last 3 are the only thing that was added 'new' to the table since last week. Although thinking about it now, I could probably use 'Title' instead of the 'RecipeName' data as its pretty much the same thing.