PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Ok, I have a form (authentication.php). In this form im trying to check the database to see if certain fields are empty and if they are then send them to example.php . I dont know if my code is correct, but I am getting errors so this might help. Keeep in mind that I am using a class file. I did not write this entire application, but im trying to get it to work for me. I appreciate your help in advanced!
My browser generated error is: Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home3/cnl83/actionfx-www/classes/access_user/authentication.php:4) in /home3/cnl83/actionfx-www/classes/access_user/access_user_class.php on line 25
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'rnquery' at line 1
My code is:
<?php
include($_SERVER['DOCUMENT_ROOT']."/classes/access_user/access_user_class.php");
$page_protect = new Access_user;
// $page_protect->login_page = "login.php"; // change this only if your login is on another page
$page_protect->access_page(); // only set this this method to protect your page
if (isset($_GET['action']) && $_GET['action'] == "log_out") {
$page_protect->log_out(); // the method to log off
}
//NEW CODE
//Error Checker
$error = 0;
$rnquery = @mysql_query("SELECT * FROM tbl_USERS WHERE real_name = '".$realname."'");
$result = mysql_query("rnquery") or die(mysql_error());
$row = @mysql_fetch_row_array($mysql);
//Foreach row check to make sure the fields are filled in
foreach ($row as $key => $value) {
If ($value = "") {
$error = $error + 1;
}
}
If ($error > 0) {
header("location: example.php");
}
//END OF NEW CODE
?>
$result = mysql_query("rnquery") or die(mysql_error());
rnquery is not sql in any way, so when you do that it will give you a invalid sql error. you already queried $rnquery in the previous line so you don't have to do it twice.
the headers problem, session_start(); has to be the FIRST line of the code, not in the middle.
instead of your foreach statement. also you don't need all of those @ symbols everywhere. if those things are going to give you errors then you might want to know about it instead of suppressing the errors (thats what the @ does, suppresses errors)
<?php
include($_SERVER['DOCUMENT_ROOT']."/classes/access_user/access_user_class.php");
$page_protect = new Access_user;
// $page_protect->login_page = "login.php"; // change this only if your login is on another page
$page_protect->access_page(); // only set this this method to protect your page
if (isset($_GET['action']) && $_GET['action'] == "log_out") {
$page_protect->log_out(); // the method to log off
}
//NEW <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span>
//Error Checker
$error = 0;
$rnquery = mysql_query("SELECT * FROM tbl_USERS WHERE real_name = '".$realname."'");
$row = mysql_fetch_row($rnquery)
//Foreach row check to make sure the fields are filled in
while ($row = mysql_fetch_row_array($rnquery) {
If ($value = "") {
$error = $error + 1;
}
}
If ($error > 0) {
header("location: authenticated.php");
}
//END OF NEW <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span>
?>
<?php
include($_SERVER['DOCUMENT_ROOT']."/classes/access_user/access_user_class.php");
$page_protect = new Access_user;
// $page_protect->login_page = "login.php"; // change this only if your login is on another page
$page_protect->access_page(); // only set this this method to protect your page
if (isset($_GET['action']) && $_GET['action'] == "log_out") {
$page_protect->log_out(); // the method to log off
}
//NEW smurf
//Error Checker
$error = 0;
$rnquery = mysql_query("SELECT * FROM tbl_USERS WHERE real_name = '".$realname."'");
//Foreach row check to make sure the fields are filled in
while ($row = mysql_fetch_assoc($rnquery)) {
If ($value = "") {//change $value to $row['field_name_you_are_checking_here']
$error = $error + 1;
}
}
If ($error > 0) {
header("location: authenticated.php");
}
//END OF NEW smurf
?>
//Foreach row check to make sure the fields are filled in
while ($row = mysql_fetch_assoc($rnquery)) {
If ($row['real_name'] = "") {//change $value to $row['field_name_you_are_checking_here']
$error = $error + 1;
}