There was something wrong when I was creating the forum.
I had created the table named “forums” as follow:
CREATE TABLE forums(
id TINYINT AUTO_INCREMENT PRIMARY KEY,
cat_id TINYINT,
name VARCHAR(30),
description VARCHAR(255));
and I also inserted some values into the table as follow:
INSERT INTO forums
(
id,
cat_id,
name,
description
)
VALUES
(
/* id */NULL,
/* cat_id */1,
/* name */'Comedy',
/* description */'First that make you laugh'
)
(I set the id with the property with “AUTO_INCREMENT” when I created the table, so that’s why I keep the “id” NULL.)
As a result, there is a message in the table.
I tried to connect the database (MySQL) by typing the codes as follow:
$db = mysql_connect($dbhost, $dbuser, $dbpassword);
mysql_select_db($dbdatabase, $db);
if(isset($_GET['id']) == TRUE) {
if(is_numeric($_GET['id']) == FALSE) {
header("Location: " . $config_basedir);
}
$validforum = $_GET['id'];
}
else {
header("Location: " . $config_basedir);
}
“$config_basedir” is a variable which was defined in another file and I also “include” at the top.
As you see, I though $_GET[‘id’] can return the value from the database, but it didn’t work. Instead, $validforum get the value of NULL, I checked the database, the value of “id” is 1. I had no idea…
Some one helps me please, thank you!
I had created the table named “forums” as follow:
CREATE TABLE forums(
id TINYINT AUTO_INCREMENT PRIMARY KEY,
cat_id TINYINT,
name VARCHAR(30),
description VARCHAR(255));
and I also inserted some values into the table as follow:
INSERT INTO forums
(
id,
cat_id,
name,
description
)
VALUES
(
/* id */NULL,
/* cat_id */1,
/* name */'Comedy',
/* description */'First that make you laugh'
)
(I set the id with the property with “AUTO_INCREMENT” when I created the table, so that’s why I keep the “id” NULL.)
As a result, there is a message in the table.
I tried to connect the database (MySQL) by typing the codes as follow:
$db = mysql_connect($dbhost, $dbuser, $dbpassword);
mysql_select_db($dbdatabase, $db);
if(isset($_GET['id']) == TRUE) {
if(is_numeric($_GET['id']) == FALSE) {
header("Location: " . $config_basedir);
}
$validforum = $_GET['id'];
}
else {
header("Location: " . $config_basedir);
}
“$config_basedir” is a variable which was defined in another file and I also “include” at the top.
As you see, I though $_GET[‘id’] can return the value from the database, but it didn’t work. Instead, $validforum get the value of NULL, I checked the database, the value of “id” is 1. I had no idea…
Some one helps me please, thank you!
Comment