Hi, I have this database that saves people's job applications.
Can anyone analyze the script (files.txt) that I use and which returns
"Error saving data" and tell me what I'm doing wrong that positions don't get saved in mysql db.
http://www.webdev.initialhost.com/files.txt
Thank you
CREATE TABLE answers (
a_date date NOT NULL default '0000-00-00',
q_text tinytext NOT NULL,
a_text tinytext,
id int(11) NOT NULL auto_increment,
applicant_id int(11) NOT NULL default '0',
PRIMARY KEY (id)
) TYPE=MyISAM COMMENT='answers for applicants questions';
--
-- Table structure for table 'applicant'
--
CREATE TABLE applicant (
id int(10) unsigned NOT NULL auto_increment,
fullname varchar(60) NOT NULL default '',
address varchar(60) NOT NULL default '',
city varchar(60) NOT NULL default '',
state varchar(60) NOT NULL default '',
zip varchar(60) NOT NULL default '',
phone varchar(60) NOT NULL default '',
fax varchar(60) NOT NULL default '',
cell varchar(60) NOT NULL default '',
email varchar(60) NOT NULL default '',
website varchar(60) NOT NULL default '',
PRIMARY KEY (id)
) TYPE=MyISAM COMMENT='applicants for jobs';
--
-- Table structure for table 'applicant_position'
--
CREATE TABLE applicant_position (
applicant_id int(11) NOT NULL default '0',
positions_id int(11) NOT NULL default '0',
id int(11) NOT NULL auto_increment,
PRIMARY KEY (id)
) TYPE=MyISAM;
--
-- Table structure for table 'portfolio'
--
CREATE TABLE portfolio (
url varchar(60) NOT NULL default '',
responsibilities text NOT NULL,
comments text NOT NULL,
id int(11) NOT NULL auto_increment,
applicant_id int(11) NOT NULL default '0',
PRIMARY KEY (id)
) TYPE=MyISAM COMMENT='applicants portfolio';
--
-- Table structure for table 'positions'
--
CREATE TABLE positions (
position_name varchar(30) NOT NULL default '',
url varchar(60) NOT NULL default '',
id int(11) NOT NULL auto_increment,
PRIMARY KEY (id)
) TYPE=MyISAM COMMENT='holds positions applicant applied to';
--
-- Dumping data for table 'positions'
--
INSERT INTO positions VALUES ('web-programmer','http://php.net',1);
INSERT INTO positions VALUES ('web-designer ','http://adobe.com',3);
--
-- Table structure for table 'skills'
--
CREATE TABLE skills (
skill varchar(60) NOT NULL default '',
expertise varchar(60) NOT NULL default '',
applicant_id int(11) NOT NULL default '0',
id int(11) NOT NULL auto_increment,
PRIMARY KEY (id)
) TYPE=MyISAM COMMENT='skillset for applicants';
data doesn't get saved in mysql
Moderator: General Moderators
-
surforever
- Forum Newbie
- Posts: 6
- Joined: Tue Apr 20, 2004 12:45 am
Maybe this:
...to
There need to be single quotes around the data you are inserting.
Code: Select all
$SQL = "INSERT INTO applicant_position (applicant_id, positions_id) VALUES (".$_SESSION["user_id"].",".$_POST["position"][$i].")";Code: Select all
$SQL = "INSERT INTO applicant_position (applicant_id, positions_id) VALUES ('".$_SESSION["user_id"]."','".$_POST["position"][$i]."')";-
surforever
- Forum Newbie
- Posts: 6
- Joined: Tue Apr 20, 2004 12:45 am
yes yes thank you
another thing:
login.php
------------
<?
include ("inc/functions.php");
function check_input()
{
if ($_POST["login"]!="xyz" || $_POST["password"]!="xyz")
{
echo "Wrong username or password. <A HREF=\"javascript:history.back()\">Try</A> again";
return false;
}
else return true;
}
include ("inc/u_header.php");
$ref=getenv('HTTP_REFERER');
if(!ereg("^http://www.webdev.initialhost.com/",$ref))
{
header ("Location: http://www.webdev.initialhost.com/");
exit;
}
else if (check_input())
{
$_SESSION["LoggedIn"]=true;
?><SCRIPT LANGUAGE="JavaScript">
<!--
window.location.replace("admin.php");
//-->
</SCRIPT>
<?}?>
admin.php redirects us to check_login.php which returns check.html,
looks like the problem with isset()
can anyone help
thank you
PS: manage.html is the login page to which user returns if the code doesnt go through
check_login.php
----------------------
<?
if (!isset($_SESSION["LoggedIn"]))
{
header("Location: check.html");
exit;
}
elseif (!$_SESSION["LoggedIn"])
{
header("Location: manage.html");
exit;
}
$connected = mysql_connect("localhost", "site","password");
if (!$connected)
{
echo "<H5>Error connecting to database.</H5>";
exit;
}
else
{
mysql_select_db("databasename") or die(mysql_error());
}
?>
another thing:
login.php
------------
<?
include ("inc/functions.php");
function check_input()
{
if ($_POST["login"]!="xyz" || $_POST["password"]!="xyz")
{
echo "Wrong username or password. <A HREF=\"javascript:history.back()\">Try</A> again";
return false;
}
else return true;
}
include ("inc/u_header.php");
$ref=getenv('HTTP_REFERER');
if(!ereg("^http://www.webdev.initialhost.com/",$ref))
{
header ("Location: http://www.webdev.initialhost.com/");
exit;
}
else if (check_input())
{
$_SESSION["LoggedIn"]=true;
?><SCRIPT LANGUAGE="JavaScript">
<!--
window.location.replace("admin.php");
//-->
</SCRIPT>
<?}?>
admin.php redirects us to check_login.php which returns check.html,
looks like the problem with isset()
can anyone help
thank you
PS: manage.html is the login page to which user returns if the code doesnt go through
check_login.php
----------------------
<?
if (!isset($_SESSION["LoggedIn"]))
{
header("Location: check.html");
exit;
}
elseif (!$_SESSION["LoggedIn"])
{
header("Location: manage.html");
exit;
}
$connected = mysql_connect("localhost", "site","password");
if (!$connected)
{
echo "<H5>Error connecting to database.</H5>";
exit;
}
else
{
mysql_select_db("databasename") or die(mysql_error());
}
?>
Please please use the php tags. We won't read it otherwise:
admin.php redirects us to check_login.php which returns check.html,
looks like the problem with isset()
can anyone help
thank you
PS: manage.html is the login page to which user returns if the code doesnt go through
Code: Select all
<?
include ("inc/functions.php");
function check_input()
{
if ($_POST["login"]!="xyz" || $_POST["password"]!="xyz")
{
echo "Wrong username or password. <A HREF="javascript:history.back()">Try</A> again";
return false;
}
else return true;
}
include ("inc/u_header.php");
$ref=getenv('HTTP_REFERER');
if(!ereg("^http://www.webdev.initialhost.com/",$ref))
{
header ("Location: http://www.webdev.initialhost.com/");
exit;
}
else if (check_input())
{
$_SESSION["LoggedIn"]=true;
?><SCRIPT LANGUAGE="JavaScript">
<!--
window.location.replace("admin.php");
//-->
</SCRIPT>
<?}?>looks like the problem with isset()
can anyone help
thank you
PS: manage.html is the login page to which user returns if the code doesnt go through
Code: Select all
check_login.php
----------------------
<?
if (!isset($_SESSION["LoggedIn"]))
{
header("Location: check.html");
exit;
}
elseif (!$_SESSION["LoggedIn"])
{
header("Location: manage.html");
exit;
}
$connected = mysql_connect("localhost", "site","password");
if (!$connected)
{
echo "<H5>Error connecting to database.</H5>";
exit;
}
else
{
mysql_select_db("databasename") or die(mysql_error());
}
?>-
surforever
- Forum Newbie
- Posts: 6
- Joined: Tue Apr 20, 2004 12:45 am
Code: Select all
Sorry, I will do that next time
Can anyone look into my previous post?
Thanks