Page 3 of 4

Posted: Wed May 25, 2005 4:49 am
by mohson
sorry pimp I spotted another error I got rid of it and this is what the query prints out
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', '', '','')
I only filled in a few form boxes.[/quote]

Posted: Wed May 25, 2005 4:53 am
by mohson
PIMPTASTIC THIS IS UNBEIEVABLE ITS WORKING!! THANK GOD FOR THAT!!! MARK i REALLY APPRECIATE YOUR HELP YOU HAVE BEEN UNBELIEVABLE!!!! THANK YOU!!!! FOR YOUR PATIENCE, PEOPLE LIKE YOU ARE FEW AND FAR BETWEEN!!!

Posted: Wed May 25, 2005 4:54 am
by JayBird
mohson wrote:PIMPTASTIC THIS IS UNBEIEVABLE ITS WORKING!! THANK GOD FOR THAT!!! MARK i REALLY APPRECIATE YOUR HELP YOU HAVE BEEN UNBELIEVABLE!!!! THANK YOU!!!! FOR YOUR PATIENCE, PEOPLE LIKE YOU ARE FEW AND FAR BETWEEN!!!

Thank christ for that!!!!

No need to thank me, just send money :lol:

Mark

Posted: Wed May 25, 2005 5:03 am
by mohson
:lol: :lol: Thanks again Mark one last thing though previously when I pressed the submit button the header call would reload the form ready to enter another record now it just seems to go to a blank screen any indeas why that may be?

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");
?>

Posted: Wed May 25, 2005 5:06 am
by JayBird
try an uppercase L on location

Posted: Wed May 25, 2005 5:07 am
by mohson
Ive tried that before never does the trick tried it now and the same? could it be anything else?

Posted: Wed May 25, 2005 5:17 am
by JayBird
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

Code: Select all

error_reporting(E_ALL);		// error reporting set to display all
And run the script again, and see if any errors are returned

Posted: Wed May 25, 2005 5:31 am
by mohson
I 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.

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");

Posted: Wed May 25, 2005 5:39 am
by JayBird
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

Posted: Wed May 25, 2005 5:45 am
by mohson
No probs Mark this is a minor problem compared to what I was going through before,ill get it sorted. you have been an absolute star.

Posted: Wed May 25, 2005 7:26 am
by mohson
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?

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);

Posted: Wed May 25, 2005 8:00 am
by JayBird
ill give you a clue

Take a look at your WHERE clause in your query!

Posted: Wed May 25, 2005 8:08 am
by mohson
Ok, the where clause basically refers to the variable the user enters in the database - in this case I know what the user will enter, they will either the options from the select boxes - Do i need to replace this with the 3 variables?

Posted: Wed May 25, 2005 8:10 am
by JayBird
think about it...

...im trying to get you to think more logically here instead of giving you the answer.

You have got the three values...you have joined them together to make the date...now you need to compare that value.

What you think you need to do?

Posted: Wed May 25, 2005 8:17 am
by mohson
I need to search the database for the values that match what the user put in the search box....