I only filled in a few form boxes.[/quote]INSERT INTO people (person_id, salutation, firstname, surname, organisation, role, address1, address2, city, postcode, telephone, mobile, fax, dateoflastcontact, datecontactagain, notes, email, org_id ) VALUES ('','Mr','Mohson','', '', '', '', '', '', '', '', '', '', '2005-5-25', '2005-5-25', '', '','')
[SOLVED] Using Select boxes to input date
Moderator: General Moderators
sorry pimp I spotted another error I got rid of it and this is what the query prints out
Code: Select all
<?php
/*Connecting, selecting database*/
$link = mysql_connect("xxxx", "xxx", "xxxx")
or die("Could not connect : " . mysql_error());
mysql_select_db("contact_management_system",$link) or die("Could not select database");
$var1 = $_POST["dateoflastcontact_Year"];
$var2 = $_POST["dateoflastcontact_Day"];
$var3 = $_POST["dateoflastcontact_Month"];
$dateoflastcontact = $var1."-".$var3."-".$var2;
$var1 = $_POST["datecontactagain_Year"];
$var2 = $_POST["datecontactagain_Day"];
$var3 = $_POST["datecontactagain_Month"];
$datecontactagain = $var1."-".$var3."-".$var2;
$sql = "INSERT INTO people (person_id, salutation, firstname, surname, organisation, role, address1, address2, city, postcode, telephone, mobile, fax, dateoflastcontact, datecontactagain, notes, email, org_id )
VALUES ('$person_id','$salutation','$firstname','$surname', '$organisation', '$role', '$address1', '$address2', '$city', '$postcode', '$telephone', '$mobile', '$fax', '$dateoflastcontact', '$datecontactagain', '$notes', '$email','$org_id')";
$result = mysql_query($sql, $link) or die ( mysql_error($link));
header ("location: http://www.soi.city.ac.uk/organisation/ ... eople.html");
?>i think you have PHP set up to not display any errors becuase the errors in your script before would normally have caused PHP to output the error to the screen.
It is really NOT a good idea to have PHP set up like this when you are developing, as you will have a hard time finding errors.
As a quick fix in this instance.
Add this to the top of the script
And run the script again, and see if any errors are returned
It is really NOT a good idea to have PHP set up like this when you are developing, as you will have a hard time finding errors.
As a quick fix in this instance.
Add this to the top of the script
Code: Select all
error_reporting(E_ALL); // error reporting set to display allI think this is my major problem, the University where I study have switched error reporting off I think for obvious reasons as they dont want students to see errors on pages if they do exist.
Ive used the error reporting before with no effect, I tried it now and it never gave me any feedback. just to make sure am I putting it in the right place, I know I probably am but just thought Id make sure.
Ive used the error reporting before with no effect, I tried it now and it never gave me any feedback. just to make sure am I putting it in the right place, I know I probably am but just thought Id make sure.
Code: Select all
<?php
error_reporting(E_ALL); // error reporting set to display all
/*Connecting, selecting database*/
$link = mysql_connect("xxxx", "xxxx", "xxxx")
or die("Could not connect : " . mysql_error());
mysql_select_db("contact_management_system",$link) or die("Could not select database");yeah, that is in the correct place.
Without the error information, it is hard to pinpoint the problem.
header will not work if an output has been sent to the browser before the function is called. This includes invisible stuff like tabs and spaces.
Without error information, i cant help you any further
Without the error information, it is hard to pinpoint the problem.
header will not work if an output has been sent to the browser before the function is called. This includes invisible stuff like tabs and spaces.
Without error information, i cant help you any further
Mark Im trying to incorporate my new date selector code into my search.
What I have is a search box which allows you to search dates stored in the database.
Ive done the same as with the form and created the 3 select boxes for this particular query im searching the contact again date and ive $_POST the variabls but no joy, can you see where im going wrong with this one?
What I have is a search box which allows you to search dates stored in the database.
Ive done the same as with the form and created the 3 select boxes for this particular query im searching the contact again date and ive $_POST the variabls but no joy, can you see where im going wrong with this one?
Code: Select all
// the query used to search the DB
$var1 = $_POST["datecontactagain_Year"];
$var2 = $_POST["datecontactagain_Day"];
$var3 = $_POST["datecontactagain_Month"];
$datecontactagain = $var1."-".$var3."-".$var2;
foreach($HTTP_POST_VARS as $varname => $value)
$formVars[$varname]=$value;
$query = "SELECT
o.org_id,o.web_url,
p.person_id,p.org_id,p.salutation,p.firstname,p.surname,
p.organisation,p.role,p.address1,p.address2,p.city,
p.postcode,p.telephone,p.mobile,p.fax,p.dateoflastcontact,
p.datecontactagain,p.notes,p.email,
DATE_FORMAT(dateoflastcontact, '%M/%Y')
AS dateoflastcontact, DATE_FORMAT(datecontactagain, '%M/%Y')
AS datecontactagain
FROM people p LEFT JOIN organisations o
ON o.org_id = p.org_id
WHERE datecontactagain LIKE '$formVars[datecontactagain]%'";
$result = mysql_query($query);