Hello people I have a script that is pulling from a MySQL database and I can't figure out the error on this page can anyone see why the next page is giving me a can't connect error like the url is incorrect so perhaps some of the code being passed is incorrect but I can't find it.
<?php
// Checks for the id value if it doesn't exist send user back to the selection form and exit script.
if (!$_POST[a_id]) {
header("Location: exit;
// if the required field has a value start session or continue one.
} else {
session_start();
}
// check value of session[valid] if answer is not yes then authentication is not valid
if ($_SESSION[valid] != "yes") {
// Send user back to the login form
header("Location: exit;
}
// Create a variable to hold the name of the database on which the table resides.
$db_name = "cayema";
// Create a variable to hold the name of the table you're populating with this script
$table_name = "Articles";
$connection = @mysql_connect("localhost", "cayema", "red27") or die (mysql_error());
// Select the database
$db = @mysql_select_db($db_name, $connection) or die (mysql_error());
// create the sql statement
$sql = "SELECT article_name, image, text FROM $table_name WHERE a_id = '$_POST[a_id]'";
// create a variable to hold the result of the mysql_query() function
$result = @mysql_query($sql, $connection) or die (mysql_error());
// Start the while loop create an array called $row for each record in the result set
while ($row = mysql_fetch_array($result)) {
// Get individual elements of the record and give them good names
$article_name = $row['article_name'];
$image = $row['image'];
$text = $row['text'];
// close the loop and php block
}
?>
<html><head><title>My Website Management System: Delete an Article</title>
</head>
<body>
<h1>My Website Management System</h1>
<h2><em>Delete an Article</em></h2>
<form method="post" action="do_delarticle.php">
<input type="hidden" name="a_id" value="<?php echo '$_POST[a_id]'; ?>">
<input type="hidden" name="article_name" value="<? echo '$article_name'; ?>">
<table cellspacing=3 cellpadding=5>
<tr><th>Article Information</th>
</tr>
<!-- Create rows and cells to hold input fields for items in the record usign value attributes in each input field -->
<tr><td valign=top>
<p><strong>Article Name:</strong><br>
<?php echo "$article_name"; ?></p>
<p><strong>Image:</strong><br>
<?php echo "$image"; ?></p>
<p><strong>Text:</strong><br>
<?php echo "$text"; ?></p>
</td>
</tr>
<tr><td align=center colspan=2><br>
<p><input type = "submit" Name="submit" value="Delete this Article"></p>
<p><a href="contact_menu.php">Return to Main Menu</a></p>
</td></tr></table></form></body></html>
<?php
// Checks for the id value if it doesn't exist send user back to the selection form and exit script.
if (!$_POST[a_id]) {
header("Location: exit;
// if the required field has a value start session or continue one.
} else {
session_start();
}
// check value of session[valid] if answer is not yes then authentication is not valid
if ($_SESSION[valid] != "yes") {
// Send user back to the login form
header("Location: exit;
}
// Create a variable to hold the name of the database on which the table resides.
$db_name = "cayema";
// Create a variable to hold the name of the table you're populating with this script
$table_name = "Articles";
$connection = @mysql_connect("localhost", "cayema", "red27") or die (mysql_error());
// Select the database
$db = @mysql_select_db($db_name, $connection) or die (mysql_error());
// create the sql statement
$sql = "SELECT article_name, image, text FROM $table_name WHERE a_id = '$_POST[a_id]'";
// create a variable to hold the result of the mysql_query() function
$result = @mysql_query($sql, $connection) or die (mysql_error());
// Start the while loop create an array called $row for each record in the result set
while ($row = mysql_fetch_array($result)) {
// Get individual elements of the record and give them good names
$article_name = $row['article_name'];
$image = $row['image'];
$text = $row['text'];
// close the loop and php block
}
?>
<html><head><title>My Website Management System: Delete an Article</title>
</head>
<body>
<h1>My Website Management System</h1>
<h2><em>Delete an Article</em></h2>
<form method="post" action="do_delarticle.php">
<input type="hidden" name="a_id" value="<?php echo '$_POST[a_id]'; ?>">
<input type="hidden" name="article_name" value="<? echo '$article_name'; ?>">
<table cellspacing=3 cellpadding=5>
<tr><th>Article Information</th>
</tr>
<!-- Create rows and cells to hold input fields for items in the record usign value attributes in each input field -->
<tr><td valign=top>
<p><strong>Article Name:</strong><br>
<?php echo "$article_name"; ?></p>
<p><strong>Image:</strong><br>
<?php echo "$image"; ?></p>
<p><strong>Text:</strong><br>
<?php echo "$text"; ?></p>
</td>
</tr>
<tr><td align=center colspan=2><br>
<p><input type = "submit" Name="submit" value="Delete this Article"></p>
<p><a href="contact_menu.php">Return to Main Menu</a></p>
</td></tr></table></form></body></html>