Hi I am a complete newb at PHP and i was wondering if you guys could help me out I have a form
<form name="report" action="show.php" method="post">
Logon:<input type="text" name="logon" class="indent" /><br /><br />Unit:<input type="text name="unit" class="indent" /><br /><br />
location:<input type="text" name="location" class="indent" /><br /><br />Problem:<textarea name="problem" style="position:
absolute; left: 160px;" rows="10" cols="40"></textarea><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
resolution:<input type="text" name="resolution" class="indent" /><br /><br />Email Address:<input type="text" name="email" class="indent" /><br /><br />
<input type="Submit" name="submit" value="Enter" class="indent" /><input type="reset" value="reset" class="indent1" /><br /><br /><br /></form>
and the php that is supposed to insert the data into the table incedent
<?php
$db = mysql_connect("localhost","root");
mysql_select_db("testdb1",$db) or die ( "Unable to connect to database");
$sql = insert INTO incedent (logon,unit,location,problem,resolution,email)
VALUES
('$_POST[logon]','$_POST[unit]','$_POST[location]','$_POST[problem]','$_POST[resolution]','$_POST')
$result = mysql_query($sql) or die(mysql_error());
?>
was wondering what was happening i get this error
Parse error: parse error, unexpected T_STRING in c:\easyphp\www\reporting\show.php on line 14
where line 16 is
('$_POST[logon]','$_POST[area]','$_POST[location]','$_POST[problem]','$_POST[resolution]','$_POST[email]')
any help would be greatunexpected T_STRING means that php encountered a 'string' ..in this case the 'string' is your mysql query..your assigning the value to a variable..so you have to surround the query with quotes:
$sql = "INSERT INTO incedent (logon,unit,location,problem,resolution,email)
VALUES
('$_POST[logon]','$_POST[unit]','$_POST[location]','$_POST[problem]','$_POST[resolution]','$_POST[em
ail]')";Okay this is my code as we speak but i still get an error
<?php
$db = mysql_connect("localhost","root");
mysql_select_db("testdb1",$db) or die ( "Unable to connect to database");
$sql = "INSERT INTO incedent (logon,unit,location,problem,resolution,email)
VALUES
('$_POST[logon]','$_POST[unit]','$_POST[location]','$_POST[problem]','$_POST[resolution]','$_POST[email]')";
?>
error is
Notice: Undefined index: unit in c:\easyphp\www\reporting\show.php on line 16
where line 16 is
('$_POST[logon]','$_POST[unit]','$_POST[location]','$_POST[problem]','$_POST[resolution]','$_POST[email]')";
any help would be great thanksThat isn't an error..it's just a notice....meaning you didn't define the variable/array key before you used it(not nessary to do).I would suggest putting the following line at the top of your php file:
error_reporting(E_ALL^E_NOTICE);
^_^thanks will can i just ask you what exactly that does???
<edit> thought it was working but not... still not inserting info to the db but no errors any ideas
btw thanks for your help so farOriginally posted by corey84
thanks will can i just ask you what exactly that does???
yeah sure CoreyD) ...error_reporting(); is a way to set the level of...error reporting your scripts generate. E_NOTICE is a level of error which just points out very minor things that you really don't need to worry about...they can get very annoying.E_ALL sets it to display all errors(including notices)...but the value E_ALL^E_NOTICE literally means "all errors but not E_NOTICE level errors" basically...it tells how php shows(or..doesn't show) various errors that your script may generate.On a live site..people generally set error reporting to E_NONE...which...shows no errors...and log them internally...as they don't want their users seeing the errors.But errors of E_ERROR and higher level are vital to the debugging process.E_NOTICE can catch typos and other errors...but most of the time these are caught just as easy with your eye. <!-- m --><a class="postlink" href="http://ca.php.net/manual/en/ref.errorfunc.php#errorfunc.constants">http://ca.php.net/manual/en/ref.errorfu ... .constants</a><!-- m --> is a list of all error level constants ...I'll let you draw your own conclusions on which to use for yours ^_^Originally posted by corey84
<edit> thought it was working but not... still not inserting info to the db but no errors any ideas
looking above at your code....you still have the call to mysql_query in it don't you?if not..add it back...the variable will do nothing by itself
edit: better idea..re-post your code ..I'm skipping off the morning so I've got plenty of time to debug yeah code is exactly as above not sure why it isn't working though, I had alot of crap in the db after i put in
error_reporting(E_ALL^E_NOTICE);
but then i tried it again and nothing
thanks for all your helpI'm still confused as to which 'code above' your referring to...I can only guess it's the one that works
<?php
$db = mysql_connect("localhost","root");
mysql_select_db("testdb1",$db) or die ( "Unable to connect to database");
$sql = "INSERT INTO incedent (logon,unit,location,problem,resolution,email)
VALUES
('$_POST[logon]','$_POST[unit]','$_POST[location]','$_POST[problem]','$_POST[resolution]','$_POST[em
ail]')";
?>
so you need to re-add the mysql_query call...
<?php
$db = mysql_connect("localhost","root");
mysql_select_db("testdb1",$db) or die ( "Unable to connect to database");
$sql = "INSERT INTO incedent (logon,unit,location,problem,resolution,email)
VALUES
('$_POST[logon]','$_POST[unit]','$_POST[location]','$_POST[problem]','$_POST[resolution]','$_POST[em
ail]')";
mysql_query($sql) or die(mysql_error());
?>
other then that....we've got some debugging to do thanks will i just figured it out myself :snail: im a bit slow
all i had to do was add
$result = mysql_query($sql) or die(mysql_error());
I removed it cause i got an error on that line... A notice i think but now it works
thanks for all your help willeh..for a "complete noob" to php...you did really well...I've done more "slow" mistakes then you this week...and I've been coding php for like 4-5 years...so...^_^
glad I could help
<form name="report" action="show.php" method="post">
Logon:<input type="text" name="logon" class="indent" /><br /><br />Unit:<input type="text name="unit" class="indent" /><br /><br />
location:<input type="text" name="location" class="indent" /><br /><br />Problem:<textarea name="problem" style="position:
absolute; left: 160px;" rows="10" cols="40"></textarea><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
resolution:<input type="text" name="resolution" class="indent" /><br /><br />Email Address:<input type="text" name="email" class="indent" /><br /><br />
<input type="Submit" name="submit" value="Enter" class="indent" /><input type="reset" value="reset" class="indent1" /><br /><br /><br /></form>
and the php that is supposed to insert the data into the table incedent
<?php
$db = mysql_connect("localhost","root");
mysql_select_db("testdb1",$db) or die ( "Unable to connect to database");
$sql = insert INTO incedent (logon,unit,location,problem,resolution,email)
VALUES
('$_POST[logon]','$_POST[unit]','$_POST[location]','$_POST[problem]','$_POST[resolution]','$_POST')
$result = mysql_query($sql) or die(mysql_error());
?>
was wondering what was happening i get this error
Parse error: parse error, unexpected T_STRING in c:\easyphp\www\reporting\show.php on line 14
where line 16 is
('$_POST[logon]','$_POST[area]','$_POST[location]','$_POST[problem]','$_POST[resolution]','$_POST[email]')
any help would be greatunexpected T_STRING means that php encountered a 'string' ..in this case the 'string' is your mysql query..your assigning the value to a variable..so you have to surround the query with quotes:
$sql = "INSERT INTO incedent (logon,unit,location,problem,resolution,email)
VALUES
('$_POST[logon]','$_POST[unit]','$_POST[location]','$_POST[problem]','$_POST[resolution]','$_POST[em
ail]')";Okay this is my code as we speak but i still get an error
<?php
$db = mysql_connect("localhost","root");
mysql_select_db("testdb1",$db) or die ( "Unable to connect to database");
$sql = "INSERT INTO incedent (logon,unit,location,problem,resolution,email)
VALUES
('$_POST[logon]','$_POST[unit]','$_POST[location]','$_POST[problem]','$_POST[resolution]','$_POST[email]')";
?>
error is
Notice: Undefined index: unit in c:\easyphp\www\reporting\show.php on line 16
where line 16 is
('$_POST[logon]','$_POST[unit]','$_POST[location]','$_POST[problem]','$_POST[resolution]','$_POST[email]')";
any help would be great thanksThat isn't an error..it's just a notice....meaning you didn't define the variable/array key before you used it(not nessary to do).I would suggest putting the following line at the top of your php file:
error_reporting(E_ALL^E_NOTICE);
^_^thanks will can i just ask you what exactly that does???
<edit> thought it was working but not... still not inserting info to the db but no errors any ideas
btw thanks for your help so farOriginally posted by corey84
thanks will can i just ask you what exactly that does???
yeah sure CoreyD) ...error_reporting(); is a way to set the level of...error reporting your scripts generate. E_NOTICE is a level of error which just points out very minor things that you really don't need to worry about...they can get very annoying.E_ALL sets it to display all errors(including notices)...but the value E_ALL^E_NOTICE literally means "all errors but not E_NOTICE level errors" basically...it tells how php shows(or..doesn't show) various errors that your script may generate.On a live site..people generally set error reporting to E_NONE...which...shows no errors...and log them internally...as they don't want their users seeing the errors.But errors of E_ERROR and higher level are vital to the debugging process.E_NOTICE can catch typos and other errors...but most of the time these are caught just as easy with your eye. <!-- m --><a class="postlink" href="http://ca.php.net/manual/en/ref.errorfunc.php#errorfunc.constants">http://ca.php.net/manual/en/ref.errorfu ... .constants</a><!-- m --> is a list of all error level constants ...I'll let you draw your own conclusions on which to use for yours ^_^Originally posted by corey84
<edit> thought it was working but not... still not inserting info to the db but no errors any ideas
looking above at your code....you still have the call to mysql_query in it don't you?if not..add it back...the variable will do nothing by itself
edit: better idea..re-post your code ..I'm skipping off the morning so I've got plenty of time to debug yeah code is exactly as above not sure why it isn't working though, I had alot of crap in the db after i put in
error_reporting(E_ALL^E_NOTICE);
but then i tried it again and nothing
thanks for all your helpI'm still confused as to which 'code above' your referring to...I can only guess it's the one that works
<?php
$db = mysql_connect("localhost","root");
mysql_select_db("testdb1",$db) or die ( "Unable to connect to database");
$sql = "INSERT INTO incedent (logon,unit,location,problem,resolution,email)
VALUES
('$_POST[logon]','$_POST[unit]','$_POST[location]','$_POST[problem]','$_POST[resolution]','$_POST[em
ail]')";
?>
so you need to re-add the mysql_query call...
<?php
$db = mysql_connect("localhost","root");
mysql_select_db("testdb1",$db) or die ( "Unable to connect to database");
$sql = "INSERT INTO incedent (logon,unit,location,problem,resolution,email)
VALUES
('$_POST[logon]','$_POST[unit]','$_POST[location]','$_POST[problem]','$_POST[resolution]','$_POST[em
ail]')";
mysql_query($sql) or die(mysql_error());
?>
other then that....we've got some debugging to do thanks will i just figured it out myself :snail: im a bit slow
all i had to do was add
$result = mysql_query($sql) or die(mysql_error());
I removed it cause i got an error on that line... A notice i think but now it works
thanks for all your help willeh..for a "complete noob" to php...you did really well...I've done more "slow" mistakes then you this week...and I've been coding php for like 4-5 years...so...^_^
glad I could help