An unexpected Warning of mysql_fetch_array() in my php file
- mariaautomatism
- Born


- Joined: May 17, 2007
- Posts: 4
- Status: Offline
Hi!
i'm working on a simple site. I have already write some php pages like login.php, register.php.....
In my pages i have included the pages header.html, left.html, right.html and footer.html.
The left.html page is a simple select query which is used for my left menu.
When i run a page wich include a form (like login.php), and the form is not submitted correctly, i have an error on the left.html page! The error is:
mysql_fetch_array(): supplied argument is not a valid MySQL result resource in left.html (in the two bold lines in the code)
If the form submitted correctly i don't have any warning. If it is not, the previous error displayed instead of my menu (left.htm)
I can't understand what is going on...
please help!
left.html code:
login.php code:
mysql_connect.php code:
i'm working on a simple site. I have already write some php pages like login.php, register.php.....
In my pages i have included the pages header.html, left.html, right.html and footer.html.
The left.html page is a simple select query which is used for my left menu.
When i run a page wich include a form (like login.php), and the form is not submitted correctly, i have an error on the left.html page! The error is:
mysql_fetch_array(): supplied argument is not a valid MySQL result resource in left.html (in the two bold lines in the code)
If the form submitted correctly i don't have any warning. If it is not, the previous error displayed instead of my menu (left.htm)
I can't understand what is going on...
please help!
left.html code:
<!--left.html-->
<table border="0" cellspacing="0" cellpadding="0" width="150">
<tr>
<td class="minfo" style=" background: url('./images/bckbanner.gif') no-repeat; " height="35"> Ταινίες</td>
</tr>
<tr>
<td align="left">
<table background = "./images/banner.gif" valign="bottom" width="150" border="0">
<?php
require_once ('../mysql_connect.php'); // Connect to the db.
$query = "SELECT categories.category AS category, categories.cat_id AS id
FROM categories
GROUP BY id";
$result = @mysql_query ($query); // Run the query.
[b]while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {[/b]
// Start defining the URL.
$url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
// Check for a trailing slash.
if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) {
$url = substr ($url, 0, -1); // Chop off the slash.
}
// Add the page.
$url .= '/movies.php';
$cat= "-" . $row[category];
$url .= '?name=' . urldecode("$row[id] $cat");
// Display each record.
if ($row[id] != "12" and $row[id] != "13" and $row[id] != "14" ) {
echo " <tr><td><a href='$url'> $row[category]</a></td> </tr>";
}
}// End of while loop.
?>
<tr>
<td height="3" background="./images/btitle.gif" valign="bottom" width="150"></td>
</tr>
<tr>
<td height="3" valign="bottom" width="150"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="mbanner" bgcolor="#ffffff" height="4"> </td>
</tr>
<tr>
<td class="minfo" style=" background: url('./images/bckbanner.gif') no-repeat; " height="35"> Παιχνίδια</td>
</tr>
<tr>
<td align="left">
<table background = "./images/banner.gif" valign="bottom" width="150" border="0">
<?php
require_once ('../mysql_connect.php'); // Connect to the db.
$query = "SELECT categories.category AS category, categories.cat_id AS id
FROM categories
WHERE
(categories.cat_id=12 or categories.cat_id=13 or categories.cat_id=14)
GROUP BY id";
$result = @mysql_query ($query); // Run the query.
[b]while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {[/b]
// Start defining the URL.
$url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
// Check for a trailing slash.
if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) {
$url = substr ($url, 0, -1); // Chop off the slash.
}
// Add the page.
$url .= '/movies.php';
$cat= "-" . $row[category];
$url .= '?name=' . urldecode("$row[id] $cat");
// Display each record.
echo " <tr><td><a href='$url'> $row[category]</a></td> </tr>";
}// End of while loop.
?>
<tr>
<td height="3" background="./images/btitle.gif" valign="bottom" width="150"></td>
</tr>
<tr>
<td height="3" valign="bottom" width="150"></td>
</tr>
</table>
</td>
</tr>
</table>
<!-- Content starts here! -->
<table border="0" cellspacing="0" cellpadding="0" width="150">
<tr>
<td class="minfo" style=" background: url('./images/bckbanner.gif') no-repeat; " height="35"> Ταινίες</td>
</tr>
<tr>
<td align="left">
<table background = "./images/banner.gif" valign="bottom" width="150" border="0">
<?php
require_once ('../mysql_connect.php'); // Connect to the db.
$query = "SELECT categories.category AS category, categories.cat_id AS id
FROM categories
GROUP BY id";
$result = @mysql_query ($query); // Run the query.
[b]while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {[/b]
// Start defining the URL.
$url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
// Check for a trailing slash.
if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) {
$url = substr ($url, 0, -1); // Chop off the slash.
}
// Add the page.
$url .= '/movies.php';
$cat= "-" . $row[category];
$url .= '?name=' . urldecode("$row[id] $cat");
// Display each record.
if ($row[id] != "12" and $row[id] != "13" and $row[id] != "14" ) {
echo " <tr><td><a href='$url'> $row[category]</a></td> </tr>";
}
}// End of while loop.
?>
<tr>
<td height="3" background="./images/btitle.gif" valign="bottom" width="150"></td>
</tr>
<tr>
<td height="3" valign="bottom" width="150"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="mbanner" bgcolor="#ffffff" height="4"> </td>
</tr>
<tr>
<td class="minfo" style=" background: url('./images/bckbanner.gif') no-repeat; " height="35"> Παιχνίδια</td>
</tr>
<tr>
<td align="left">
<table background = "./images/banner.gif" valign="bottom" width="150" border="0">
<?php
require_once ('../mysql_connect.php'); // Connect to the db.
$query = "SELECT categories.category AS category, categories.cat_id AS id
FROM categories
WHERE
(categories.cat_id=12 or categories.cat_id=13 or categories.cat_id=14)
GROUP BY id";
$result = @mysql_query ($query); // Run the query.
[b]while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {[/b]
// Start defining the URL.
$url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
// Check for a trailing slash.
if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) {
$url = substr ($url, 0, -1); // Chop off the slash.
}
// Add the page.
$url .= '/movies.php';
$cat= "-" . $row[category];
$url .= '?name=' . urldecode("$row[id] $cat");
// Display each record.
echo " <tr><td><a href='$url'> $row[category]</a></td> </tr>";
}// End of while loop.
?>
<tr>
<td height="3" background="./images/btitle.gif" valign="bottom" width="150"></td>
</tr>
<tr>
<td height="3" valign="bottom" width="150"></td>
</tr>
</table>
</td>
</tr>
</table>
<!-- Content starts here! -->
- <!--left.html-->
- <table border="0" cellspacing="0" cellpadding="0" width="150">
- <tr>
- <td class="minfo" style=" background: url('./images/bckbanner.gif') no-repeat; " height="35"> Ταινίες</td>
- </tr>
- <tr>
- <td align="left">
- <table background = "./images/banner.gif" valign="bottom" width="150" border="0">
- <?php
- require_once ('../mysql_connect.php'); // Connect to the db.
- $query = "SELECT categories.category AS category, categories.cat_id AS id
- FROM categories
- GROUP BY id";
- $result = @mysql_query ($query); // Run the query.
- [b]while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {[/b]
- // Start defining the URL.
- $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
- // Check for a trailing slash.
- if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) {
- $url = substr ($url, 0, -1); // Chop off the slash.
- }
- // Add the page.
- $url .= '/movies.php';
- $cat= "-" . $row[category];
- $url .= '?name=' . urldecode("$row[id] $cat");
- // Display each record.
- if ($row[id] != "12" and $row[id] != "13" and $row[id] != "14" ) {
- echo " <tr><td><a href='$url'> $row[category]</a></td> </tr>";
- }
- }// End of while loop.
- ?>
- <tr>
- <td height="3" background="./images/btitle.gif" valign="bottom" width="150"></td>
- </tr>
- <tr>
- <td height="3" valign="bottom" width="150"></td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td class="mbanner" bgcolor="#ffffff" height="4"> </td>
- </tr>
- <tr>
- <td class="minfo" style=" background: url('./images/bckbanner.gif') no-repeat; " height="35"> Παιχνίδια</td>
- </tr>
- <tr>
- <td align="left">
- <table background = "./images/banner.gif" valign="bottom" width="150" border="0">
- <?php
- require_once ('../mysql_connect.php'); // Connect to the db.
- $query = "SELECT categories.category AS category, categories.cat_id AS id
- FROM categories
- WHERE
- (categories.cat_id=12 or categories.cat_id=13 or categories.cat_id=14)
- GROUP BY id";
- $result = @mysql_query ($query); // Run the query.
- [b]while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {[/b]
- // Start defining the URL.
- $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
- // Check for a trailing slash.
- if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) {
- $url = substr ($url, 0, -1); // Chop off the slash.
- }
- // Add the page.
- $url .= '/movies.php';
- $cat= "-" . $row[category];
- $url .= '?name=' . urldecode("$row[id] $cat");
- // Display each record.
- echo " <tr><td><a href='$url'> $row[category]</a></td> </tr>";
- }// End of while loop.
- ?>
- <tr>
- <td height="3" background="./images/btitle.gif" valign="bottom" width="150"></td>
- </tr>
- <tr>
- <td height="3" valign="bottom" width="150"></td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- <!-- Content starts here! -->
login.php code:
<?php # login.php
// Send NOTHING to the Web browser prior to the session_start() line!
// Check if the form has been submitted.
if (isset($_POST['submitted'])) {
require_once ('../mysql_connect.php'); // Connect to the db.
$errors = array(); // Initialize error array.
// Check for an email address.
if (empty($_POST['email'])) {
$errors[] = 'email address';
} else {
$email = escape_data($_POST['email']);
}
// Check for a password.
if (empty($_POST['password'])) {
$errors[] = 'password';
} else {
$password = escape_data($_POST['password']);
}
if (empty($errors)) { // If everything's OK.
/* Retrieve the user_id and first_name for
that email/password combination. */
$query = "SELECT user_id, firstName FROM users WHERE email='$email' AND password=md5('$password')";
$result = @mysql_query ($query); // Run the query.
$row = mysql_fetch_array ($result, MYSQL_NUM); // Return a record, if applicable.
if ($row) { // A record was pulled from the database.
// Set the session data & redirect.
session_name ('YourVisitID');
session_start();
$_SESSION['user_id'] = $row[0];
$_SESSION['firstName'] = $row[1];
$_SESSION['email'] = $row[2];
$_SESSION['agent'] = md5($_SERVER['HTTP_USER_AGENT']);
// Redirect the user to the loggedin.php page.
// Start defining the URL.
$url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
// Check for a trailing slash.
if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) {
$url = substr ($url, 0, -1); // Chop off the slash.
}
// Add the page.
$url .= '/loggedin.php';
header("Location: $url");
exit(); // Quit the script.
} else { // No record matched the query.
$errors[] = ' <br /> Δεν υπάρχει τέτοιος συνδυασμός e-mail και password';
}
} // End of if (empty($errors)) IF.
mysql_close(); // Close the database connection.
} else { // Form has not been submitted.
$errors = NULL;
} // End of the main Submit conditional.
// Begin the page now.
?>
<table width="940" height="100%" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td>
<?php
// Set the page title and include the HTML header.
$page_title = 'Login';
include ('./includes/header.html');
?>
</td>
</tr>
<tr><td>
<table width="940" height="100%" border="0" cellpadding="0" cellspacing="0" align="left">
<tr><td height="3" colspan="2"> </td></tr>
<tr>
<td valign="top">
<?php // Include the HTML left file.
include ('./includes/left.html');
?>
</td>
<td valign="top">
<table width="784" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td align="left" valign="top" width="100%">
<table class="mtable" border="0" cellpadding="0" cellspacing="0" width="100%" valign="top">
<tr>
<td height="14" class="minfot" background="./images/btitle.gif" cellpadding="0" cellspacing="0" valign="middle"> Login</td>
<td height="14" class="minfot" background="./images/btitle.gif" cellpadding="0" cellspacing="0" align="right" valign="middle">Guest </td>
</tr>
<tr>
<td colspan="2">
<form action="login.php" method="post">
<table align="center">
<tr>
<td class="minfos"> </td>
<td></td>
</tr>
<tr>
<td class="minfos">Email Address: </td>
<td><input type="text" name="email" size="20" maxlength="40" class="inpblue2" /></td>
</tr>
<tr>
<td class="minfos">Password: </td>
<td><input type="password" name="password" size="20" maxlength="20" class="inpblue" /></td>
</tr>
<tr>
<td class="minfos"> </td>
<td class="minfos" align="center">
<input type="submit" name="submit" value="Login" class="inpblue" />
<input type="hidden" name="submitted" value="TRUE" />
</td>
</tr>
<tr>
<td> </td>
<td class="minfos2" align="center"><br>
<a href="remind.php">Ξέχασα τoν κωδικό μου</a>
</td>
</tr>
<tr>
<td> </td>
<td class="minfos2" align="center"><br>
<a href="register.php">Eγγραφή</a>
</td>
</tr>
</form>
<tr>
<td colspan="2" >
<?php
if (!empty($errors)) { // Print any error messages.
echo '<p class="text"><b>ΠΡΟΣΟΧΗ!</b></p>
<p class="text" >Δεν έχετε συμπληρώσει σωστά τα πεδία <p />';
foreach ($errors as $msg) { // Print each error.
echo " <font class='text'>$msg </font>";
}
echo '<p class="text">Προσπαθείστε ξανά!</p>';
}
// Create the form.
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td class="mrtable" valign="top" width="120">
<?php // Include the HTML right file.
include ('./includes/right.html');
?>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2">
<?php // Include the HTML footer file.
include ('./includes/footer.html');
?>
</td>
</tr>
</table>
</td></tr>
</table>
// Send NOTHING to the Web browser prior to the session_start() line!
// Check if the form has been submitted.
if (isset($_POST['submitted'])) {
require_once ('../mysql_connect.php'); // Connect to the db.
$errors = array(); // Initialize error array.
// Check for an email address.
if (empty($_POST['email'])) {
$errors[] = 'email address';
} else {
$email = escape_data($_POST['email']);
}
// Check for a password.
if (empty($_POST['password'])) {
$errors[] = 'password';
} else {
$password = escape_data($_POST['password']);
}
if (empty($errors)) { // If everything's OK.
/* Retrieve the user_id and first_name for
that email/password combination. */
$query = "SELECT user_id, firstName FROM users WHERE email='$email' AND password=md5('$password')";
$result = @mysql_query ($query); // Run the query.
$row = mysql_fetch_array ($result, MYSQL_NUM); // Return a record, if applicable.
if ($row) { // A record was pulled from the database.
// Set the session data & redirect.
session_name ('YourVisitID');
session_start();
$_SESSION['user_id'] = $row[0];
$_SESSION['firstName'] = $row[1];
$_SESSION['email'] = $row[2];
$_SESSION['agent'] = md5($_SERVER['HTTP_USER_AGENT']);
// Redirect the user to the loggedin.php page.
// Start defining the URL.
$url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
// Check for a trailing slash.
if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) {
$url = substr ($url, 0, -1); // Chop off the slash.
}
// Add the page.
$url .= '/loggedin.php';
header("Location: $url");
exit(); // Quit the script.
} else { // No record matched the query.
$errors[] = ' <br /> Δεν υπάρχει τέτοιος συνδυασμός e-mail και password';
}
} // End of if (empty($errors)) IF.
mysql_close(); // Close the database connection.
} else { // Form has not been submitted.
$errors = NULL;
} // End of the main Submit conditional.
// Begin the page now.
?>
<table width="940" height="100%" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td>
<?php
// Set the page title and include the HTML header.
$page_title = 'Login';
include ('./includes/header.html');
?>
</td>
</tr>
<tr><td>
<table width="940" height="100%" border="0" cellpadding="0" cellspacing="0" align="left">
<tr><td height="3" colspan="2"> </td></tr>
<tr>
<td valign="top">
<?php // Include the HTML left file.
include ('./includes/left.html');
?>
</td>
<td valign="top">
<table width="784" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td align="left" valign="top" width="100%">
<table class="mtable" border="0" cellpadding="0" cellspacing="0" width="100%" valign="top">
<tr>
<td height="14" class="minfot" background="./images/btitle.gif" cellpadding="0" cellspacing="0" valign="middle"> Login</td>
<td height="14" class="minfot" background="./images/btitle.gif" cellpadding="0" cellspacing="0" align="right" valign="middle">Guest </td>
</tr>
<tr>
<td colspan="2">
<form action="login.php" method="post">
<table align="center">
<tr>
<td class="minfos"> </td>
<td></td>
</tr>
<tr>
<td class="minfos">Email Address: </td>
<td><input type="text" name="email" size="20" maxlength="40" class="inpblue2" /></td>
</tr>
<tr>
<td class="minfos">Password: </td>
<td><input type="password" name="password" size="20" maxlength="20" class="inpblue" /></td>
</tr>
<tr>
<td class="minfos"> </td>
<td class="minfos" align="center">
<input type="submit" name="submit" value="Login" class="inpblue" />
<input type="hidden" name="submitted" value="TRUE" />
</td>
</tr>
<tr>
<td> </td>
<td class="minfos2" align="center"><br>
<a href="remind.php">Ξέχασα τoν κωδικό μου</a>
</td>
</tr>
<tr>
<td> </td>
<td class="minfos2" align="center"><br>
<a href="register.php">Eγγραφή</a>
</td>
</tr>
</form>
<tr>
<td colspan="2" >
<?php
if (!empty($errors)) { // Print any error messages.
echo '<p class="text"><b>ΠΡΟΣΟΧΗ!</b></p>
<p class="text" >Δεν έχετε συμπληρώσει σωστά τα πεδία <p />';
foreach ($errors as $msg) { // Print each error.
echo " <font class='text'>$msg </font>";
}
echo '<p class="text">Προσπαθείστε ξανά!</p>';
}
// Create the form.
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td class="mrtable" valign="top" width="120">
<?php // Include the HTML right file.
include ('./includes/right.html');
?>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2">
<?php // Include the HTML footer file.
include ('./includes/footer.html');
?>
</td>
</tr>
</table>
</td></tr>
</table>
- <?php # login.php
- // Send NOTHING to the Web browser prior to the session_start() line!
- // Check if the form has been submitted.
- if (isset($_POST['submitted'])) {
- require_once ('../mysql_connect.php'); // Connect to the db.
- $errors = array(); // Initialize error array.
- // Check for an email address.
- if (empty($_POST['email'])) {
- $errors[] = 'email address';
- } else {
- $email = escape_data($_POST['email']);
- }
- // Check for a password.
- if (empty($_POST['password'])) {
- $errors[] = 'password';
- } else {
- $password = escape_data($_POST['password']);
- }
- if (empty($errors)) { // If everything's OK.
- /* Retrieve the user_id and first_name for
- that email/password combination. */
- $query = "SELECT user_id, firstName FROM users WHERE email='$email' AND password=md5('$password')";
- $result = @mysql_query ($query); // Run the query.
- $row = mysql_fetch_array ($result, MYSQL_NUM); // Return a record, if applicable.
- if ($row) { // A record was pulled from the database.
- // Set the session data & redirect.
- session_name ('YourVisitID');
- session_start();
- $_SESSION['user_id'] = $row[0];
- $_SESSION['firstName'] = $row[1];
- $_SESSION['email'] = $row[2];
- $_SESSION['agent'] = md5($_SERVER['HTTP_USER_AGENT']);
- // Redirect the user to the loggedin.php page.
- // Start defining the URL.
- $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
- // Check for a trailing slash.
- if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) {
- $url = substr ($url, 0, -1); // Chop off the slash.
- }
- // Add the page.
- $url .= '/loggedin.php';
- header("Location: $url");
- exit(); // Quit the script.
- } else { // No record matched the query.
- $errors[] = ' <br /> Δεν υπάρχει τέτοιος συνδυασμός e-mail και password';
- }
- } // End of if (empty($errors)) IF.
- mysql_close(); // Close the database connection.
- } else { // Form has not been submitted.
- $errors = NULL;
- } // End of the main Submit conditional.
- // Begin the page now.
- ?>
- <table width="940" height="100%" border="0" cellpadding="0" cellspacing="0" align="center">
- <tr>
- <td>
- <?php
- // Set the page title and include the HTML header.
- $page_title = 'Login';
- include ('./includes/header.html');
- ?>
- </td>
- </tr>
- <tr><td>
- <table width="940" height="100%" border="0" cellpadding="0" cellspacing="0" align="left">
- <tr><td height="3" colspan="2"> </td></tr>
- <tr>
- <td valign="top">
- <?php // Include the HTML left file.
- include ('./includes/left.html');
- ?>
- </td>
- <td valign="top">
- <table width="784" border="0" cellspacing="0" cellpadding="0" align="center">
- <tr>
- <td align="left" valign="top" width="100%">
- <table class="mtable" border="0" cellpadding="0" cellspacing="0" width="100%" valign="top">
- <tr>
- <td height="14" class="minfot" background="./images/btitle.gif" cellpadding="0" cellspacing="0" valign="middle"> Login</td>
- <td height="14" class="minfot" background="./images/btitle.gif" cellpadding="0" cellspacing="0" align="right" valign="middle">Guest </td>
- </tr>
- <tr>
- <td colspan="2">
- <form action="login.php" method="post">
- <table align="center">
- <tr>
- <td class="minfos"> </td>
- <td></td>
- </tr>
- <tr>
- <td class="minfos">Email Address: </td>
- <td><input type="text" name="email" size="20" maxlength="40" class="inpblue2" /></td>
- </tr>
- <tr>
- <td class="minfos">Password: </td>
- <td><input type="password" name="password" size="20" maxlength="20" class="inpblue" /></td>
- </tr>
- <tr>
- <td class="minfos"> </td>
- <td class="minfos" align="center">
- <input type="submit" name="submit" value="Login" class="inpblue" />
- <input type="hidden" name="submitted" value="TRUE" />
- </td>
- </tr>
- <tr>
- <td> </td>
- <td class="minfos2" align="center"><br>
- <a href="remind.php">Ξέχασα τoν κωδικό μου</a>
- </td>
- </tr>
- <tr>
- <td> </td>
- <td class="minfos2" align="center"><br>
- <a href="register.php">Eγγραφή</a>
- </td>
- </tr>
- </form>
- <tr>
- <td colspan="2" >
- <?php
- if (!empty($errors)) { // Print any error messages.
- echo '<p class="text"><b>ΠΡΟΣΟΧΗ!</b></p>
- <p class="text" >Δεν έχετε συμπληρώσει σωστά τα πεδία <p />';
- foreach ($errors as $msg) { // Print each error.
- echo " <font class='text'>$msg </font>";
- }
- echo '<p class="text">Προσπαθείστε ξανά!</p>';
- }
- // Create the form.
- ?>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- </td>
- <td class="mrtable" valign="top" width="120">
- <?php // Include the HTML right file.
- include ('./includes/right.html');
- ?>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td colspan="2">
- <?php // Include the HTML footer file.
- include ('./includes/footer.html');
- ?>
- </td>
- </tr>
- </table>
- </td></tr>
- </table>
mysql_connect.php code:
<?php # mysql_connect.php
// This file contains the database access information.
// This file also establishes a connection to MySQL and selects the database.
// This file also defines the escape_data() function.
// Set the database access information as constants.
DEFINE ('DB_USER', 'xxxxxxxxxx');
DEFINE ('DB_PASSWORD', 'xxxxxxxxxx');
DEFINE ('DB_HOST', 'xxxxxxxxxxxxxxx');
DEFINE ('DB_NAME', 'xxxxxxxxxx');
// Make the connection.
$dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error() );
// Select the database.
@mysql_select_db (DB_NAME) OR die ('Could not select the database: ' . mysql_error() );
mysql_query('set names greek;');
// Create a function for escaping the data.
function escape_data ($data) {
// Address Magic Quotes.
if (ini_get('magic_quotes_gpc')) {
$data = stripslashes($data);
}
// Check for mysql_real_escape_string() support.
if (function_exists('mysql_real_escape_string')) {
global $dbc; // Need the connection.
$data = mysql_real_escape_string (trim($data), $dbc);
} else {
$data = mysql_escape_string (trim($data));
}
// Return the escaped value.
return $data;
} // End of function.
?>
// This file contains the database access information.
// This file also establishes a connection to MySQL and selects the database.
// This file also defines the escape_data() function.
// Set the database access information as constants.
DEFINE ('DB_USER', 'xxxxxxxxxx');
DEFINE ('DB_PASSWORD', 'xxxxxxxxxx');
DEFINE ('DB_HOST', 'xxxxxxxxxxxxxxx');
DEFINE ('DB_NAME', 'xxxxxxxxxx');
// Make the connection.
$dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error() );
// Select the database.
@mysql_select_db (DB_NAME) OR die ('Could not select the database: ' . mysql_error() );
mysql_query('set names greek;');
// Create a function for escaping the data.
function escape_data ($data) {
// Address Magic Quotes.
if (ini_get('magic_quotes_gpc')) {
$data = stripslashes($data);
}
// Check for mysql_real_escape_string() support.
if (function_exists('mysql_real_escape_string')) {
global $dbc; // Need the connection.
$data = mysql_real_escape_string (trim($data), $dbc);
} else {
$data = mysql_escape_string (trim($data));
}
// Return the escaped value.
return $data;
} // End of function.
?>
- <?php # mysql_connect.php
- // This file contains the database access information.
- // This file also establishes a connection to MySQL and selects the database.
- // This file also defines the escape_data() function.
- // Set the database access information as constants.
- DEFINE ('DB_USER', 'xxxxxxxxxx');
- DEFINE ('DB_PASSWORD', 'xxxxxxxxxx');
- DEFINE ('DB_HOST', 'xxxxxxxxxxxxxxx');
- DEFINE ('DB_NAME', 'xxxxxxxxxx');
- // Make the connection.
- $dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error() );
- // Select the database.
- @mysql_select_db (DB_NAME) OR die ('Could not select the database: ' . mysql_error() );
- mysql_query('set names greek;');
- // Create a function for escaping the data.
- function escape_data ($data) {
- // Address Magic Quotes.
- if (ini_get('magic_quotes_gpc')) {
- $data = stripslashes($data);
- }
- // Check for mysql_real_escape_string() support.
- if (function_exists('mysql_real_escape_string')) {
- global $dbc; // Need the connection.
- $data = mysql_real_escape_string (trim($data), $dbc);
- } else {
- $data = mysql_escape_string (trim($data));
- }
- // Return the escaped value.
- return $data;
- } // End of function.
- ?>
- Anonymous
- Bot


- Joined: 25 Feb 2008
- Posts: ?
- Loc: Ozzuland
- Status: Online
May 17th, 2007, 11:52 am
- cometmall
- Student


- Joined: Apr 27, 2007
- Posts: 78
- Status: Offline
========================================
$result = @mysql_query ($query); // Run the query.
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {
========================================
I think the problem is that $result maybe not an array sometimes, try to remove the @ sign from mysql_query, and check the result
$result = @mysql_query ($query); // Run the query.
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {
========================================
I think the problem is that $result maybe not an array sometimes, try to remove the @ sign from mysql_query, and check the result
- cometmall
- Student


- Joined: Apr 27, 2007
- Posts: 78
- Status: Offline
- mariaautomatism
- Born


- Joined: May 17, 2007
- Posts: 4
- Status: Offline
You have right. i did this and the error message changed to:
Query failed: Access denied for user.....
But i can't understand why...
the same code run ok in all other pages which include the left.html.
Also it run ok if the form in the login.php submitted correctly...
i'm so confused...
Query failed: Access denied for user.....
But i can't understand why...
the same code run ok in all other pages which include the left.html.
Also it run ok if the form in the login.php submitted correctly...
i'm so confused...
- cometmall
- Student


- Joined: Apr 27, 2007
- Posts: 78
- Status: Offline
I think you are including the left after you close the connection
mysql_close(); // Close the database connection.
and in left you specified : require_once ('../mysql_connect.php');
because you already included the file, it will not be included again.
Warning: i wouldnt write PHP files with .html, any1 can see your source
mysql_close(); // Close the database connection.
and in left you specified : require_once ('../mysql_connect.php');
because you already included the file, it will not be included again.
Warning: i wouldnt write PHP files with .html, any1 can see your source
- mariaautomatism
- Born


- Joined: May 17, 2007
- Posts: 4
- Status: Offline
Page 1 of 1
To Reply to this topic you need to LOGIN or REGISTER. It is free.
Post Information
- Total Posts in this topic: 7 posts
- Users browsing this forum: No registered users and 349 guests
- You cannot post new topics in this forum
- You cannot reply to topics in this forum
- You cannot edit your posts in this forum
- You cannot delete your posts in this forum
- You cannot post attachments in this forum


