Thread: PHP mysql error
View Single Post
Old 09-03-2012, 11:39 PM   PM User | #28
amcf1992
Regular Coder

 
Join Date: Jul 2011
Posts: 114
Thanks: 7
Thanked 0 Times in 0 Posts
amcf1992 is an unknown quantity at this point
Quote:
Originally Posted by _Aerospace_Eng_ View Post
You have a problem here
PHP Code:
$query "SELECT id, email, key FROM friendko_text WHERE key = '{$_POST['key']}'";
$result mysql_query($query);
while(
$row mysql_fetch_array($resultMYSQL_ASSOC))  
{
  echo 
'11 Digit Key: ' $row['key'] . '<br>';
  echo 
'Email: ' $row['email'] . '<br>';
  echo 
'Carrier: ' $carrier'] . '<br>';
}


$to = $_POST['
to'];
$carrier = $_POST['
carrier'];
$message = stripslashes($_POST['
message]); 
It should be
PHP Code:

$to 
$_POST['to'];
$carrier $_POST['carrier'];
$message stripslashes($_POST['message']);
$query "SELECT id, email, key FROM friendko_text WHERE key = '{$_POST['key']}'";
$result mysql_query($query);
while(
$row mysql_fetch_array($resultMYSQL_ASSOC))  
{
  echo 
'11 Digit Key: ' $row['key'] . '<br>';
  echo 
'Email: ' $row['email'] . '<br>';
  echo 
'Carrier: ' $carrier '<br>';

Your code is very insecure by the way. I suggest you look into preventing SQL injection: http://www.tizag.com/mysqlTutorial/m...-injection.php
Yes, very insecure. I am just focusing on getting this to work

I removed $from, since it had no value. Also the its still stuck on send.php

now its

PHP Code:
$con mysql_connect("localhost","friendko_admin","Macbookpro17#");
 if (!
$con)
   {
   die(
'Could not connect: ' mysql_error());
   }
 
mysql_select_db("friendko_text"$con);




$key $_POST['key'];
$carrier $_POST['carrier'];
$message stripslashes($_POST['message']);
$query "SELECT id, email, key FROM friendko_text WHERE key = '{$_POST['key']}'";
$result mysql_query($query);
while(
$row mysql_fetch_array($resultMYSQL_ASSOC))  
{
  echo 
'11 Digit Key: ' $row['key'] . '<br>';
  echo 
'Email: ' $row['email'] . '<br>';
  echo 
'Carrier: ' $carrier '<br>';
}  

if ((empty(
$key)) || (empty($message)) {
header ("Location: sms_error.php");


Last edited by amcf1992; 09-03-2012 at 11:42 PM..
amcf1992 is offline   Reply With Quote