PDA

View Full Version : A command inside a command!



dreamer
May 1st, 2004, 09:54 PM
This script is giving me errors. How do you put a command inside a command?



PHP Code:
<?
session_start();
header("Cache-control: private");

if((!$_SESSION['user_name'] === "") || (!$_SESSION['first_name'] === "") || (!$_SESSION['last_name'] === "")){
echo "You must login to post! If you do not have an account you may register it for free!";
include 'login.html';
include 'signup.html';
exit();
}

else{
include 'db.php';

$title = $_POST['title'];
$url = $_POST['url'];
$message = $_POST['message'];
$username = $_SESSION['user_name'];
$firstname = $_SESSION['first_name'];
$lastname = $_SESSION['last_name'];

$title = stripslashes($title);
$url = stripslashes($url);
$message = stripslashes($message);

if((!$title) || (!$url) || (!$message) || (!$username) || (!$firstname) || (!$lastname)){
echo 'You did not submit the following required information! <br />';
if(!$title){
echo "Message Title is a required field. Please enter it below.<br />";
}
if(!$url){
echo "Url is a required field. Please enter it below.<br />";
}
if(!$message){
echo "Message is a required field. Please enter it below.<br />";
}
if(!$username){
echo "There was an error in recording your username. Please Login!<br />";
}
if(!$firstname){
echo "There was an error in recording your first name. Please Login!<br />";
}
if(!$lastname){
echo "There was an error in recording your last name. Please Login!<br />";
}
include 'post.html';
exit();
}

$sql = mysql_query("INSERT INTO public (title, url, message, username, firstname, lastname, postdate)
VALUES('$title', '$url', '$message', '$username', '$firstname', '$lastname', 'now()')")
}
?>


thanks!

nobody
May 1st, 2004, 10:05 PM
if() {
} else if() {
} else if() {
} else {
}

It gets kind of annoying and tricky once you get a lot of logic in there, but you'll figure it out I'm sure.
Good luck.

dreamer
May 2nd, 2004, 12:01 AM
ahh ok.

does get tricky. thanks!

dreamer
May 2nd, 2004, 12:40 AM
my script is still having some problems. can you put it in for me? cause i have a command in a command in a command LOL.

thanks

nobody
May 2nd, 2004, 01:31 AM
it'd be easier if i could see your code that you tried to get to work so we could go from there.
i'd rather teach you than do it for you :)

dreamer
May 2nd, 2004, 02:05 AM
yes that would be better!

my code is the same as my first post. here it is again.



<?
session_start();
header("Cache-control: private");

if((!$_SESSION['user_name'] === "") || (!$_SESSION['first_name'] === "") || (!$_SESSION['last_name'] === "")){
echo "You must login to post! If you do not have an account you may register it for free!";
include 'login.html';
include 'signup.html';
exit();
}

else{
include 'db.php';

$title = $_POST['title'];
$url = $_POST['url'];
$message = $_POST['message'];
$username = $_SESSION['user_name'];
$firstname = $_SESSION['first_name'];
$lastname = $_SESSION['last_name'];

$title = stripslashes($title);
$url = stripslashes($url);
$message = stripslashes($message);

if((!$title) || (!$url) || (!$message) || (!$username) || (!$firstname) || (!$lastname)){
echo 'You did not submit the following required information! <br />';
if(!$title){
echo "Message Title is a required field. Please enter it below.<br />";
}
if(!$url){
echo "Url is a required field. Please enter it below.<br />";
}
if(!$message){
echo "Message is a required field. Please enter it below.<br />";
}
if(!$username){
echo "There was an error in recording your username. Please Login!<br />";
}
if(!$firstname){
echo "There was an error in recording your first name. Please Login!<br />";
}
if(!$lastname){
echo "There was an error in recording your last name. Please Login!<br />";
}
include 'post.html';
exit();
}

$sql = mysql_query("INSERT INTO public (title, url, message, username, firstname, lastname, postdate)
VALUES('$title', '$url', '$message', '$username', '$firstname', '$lastname', 'now()')")
}
?>