Jump to content

Recommended Posts

I must once again ask for the PHP Freak communites help,

 

Here is the code:

 

<?
//Variable Setup
$name = $_POST["name"];
$dayphone = $_POST["dayphone"];
$evephone = $_POST["evephone"];
$mobphone = $_POST["mobphone"];
$email = $_POST["email"];
$q5 = $_POST["q5"];
$assignment = $_POST["q5a"];
$q5b = $_POST["q5b"];
$q6 = $_POST["q6"];
$q5c = "$q5b $q5";
$q5d = "Enquiry about $q5"; 

//Script Execute

echo "<h2 class='greenh2'>Message Sent</h2>

$name,<br/><br />

Your message has been sent to the relevant person within the club. Please bare in mind that our managers run teams as well as there jobs. As a result there may be a long delay before you recieve a response.

<br /><br />

Kindest Regards,<br/>
Pen Mill FC";

//Check for Relevant Person
$query = "SELECT * FROM team_members WHERE assignment='$assignment'"; 

$qry = mysql_query($query)
or die ("Could not match data because ".mysql_error());

while($row = mysql_fetch_array($qry))
  {
  $to_contact = $row['name'];
  $to_email = $row['email'];
  $to_subject = "$q5d";
  $to_message = "$q6";
  $today = date("Y-m-d");
  $time = date("g:i a");
  }
  
  echo "$to_contact";
  
//Send Message To Relevant Person

//$con = mysql_connect("mysql.interdns.co.uk","penmillfc","derrick2009");
//if (!$con)
//  {
//  die('Could not connect: ' . mysql_error());
//  }
//
//mysql_select_db("penmillfc", $con);
//
//$sql="INSERT INTO team_messages (to, from, from_email, subject, message, date, time) 
//VALUES ('$to_contact','$_POST[name]','$_POST[email]', '$to_subject', '$to_message', '$today', '$time')";
//
//if (!mysql_query($sql,$con))
//  {
//  die('Error: ' . mysql_error());
//  }
//echo "1 record added";

?>

 

Ignore the commented out section but when I run this script and try to extract the person from the database it doesn't extract them with the variable in the

WHERE assignment='$assignment'

section. It will however extract a person when I manually write their assignment for example

WHERE assignment='Payment'

.

 

My variables are present and correct which was proven after echoing them onto the page.

 

Thanks

George

Link to comment
https://forums.phpfreaks.com/topic/167259-solved-select-from-failure/
Share on other sites

I have sorted the intial fault but now when adding a AND to the equation it spits out

 

Could not match data because You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''Pen Mill U14s' at line 1

 

The new query is

 

$query = "SELECT * FROM team_members WHERE assignment='$assignment' AND team = '$team";

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.