私は訓練を受けたプログラマーではありません。私が学んだことはすべて、ネットから自分で学びました。私のコードと質問が非常に素人っぽいと思われる場合は、ご容赦ください。
データベースからの売り手のデータに対して買い手の一致を呼び出し、それらの一致を自動的にメールで送信しようとしています。
EasyPhp を使用してシステムでこのコードを実行すると、「クエリが空でした」と表示されます。サーバーでこれを実行すると"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 '1' at line 1 "
、どこが間違っているのかと表示されます。
<?php
include('adminmaster.htm');
Echo "<center>Mail Matching Properties</center><br><br>";
mysql_connect("localhost", "username","password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
$query= 'SELECT*FROM clientdata WHERE email != " " AND Transaction="Buyer"';
$result=mysql_query($query);
echo mysql_error();
if (!$result){ die("No Buy results");}
$matchrows=mysql_num_rows($result);
if($matchrows==0){ die("No Buy results");}
while($info = mysql_fetch_array($result))
$Price1= $info['Price']+($info['Price']*10/100);
$Price2 = $info['Price']-($info['Price']*10/100);
$una=$info['username'];
$query2='SELECT*FROM clientdata WHERE email!=" " AND Transaction="Seller"';
$result2=mysql_query($query2);
echo mysql_error();
$matchrows2=mysql_num_rows($result2);
if($matchrows2==0){ die("Sell Data Not Found");}
if(!$result2)
{die("Sell Data Not Found");}
while($info2=mysql_fetch_array($result2))
{
if ($info['Detail']==$info2['Detail'])
{
if ($info['Location']==$info2['Location'])
{
if ($Price1 >= $info2['Price'])
{
if ($Price2 <= $info2['Price'])
{
if ($info['username']!=$info2['username'])
{
echo mysql_error();
echo "<table width=600 border = 1 style='text-align:left';>
<tr>
<td><b>Clients</b></td>
<td><b><font color='maroon'>BUYER</font></b></td>
<td><b><font color='maroon'>SELLER</font></b></td>
</tr>
<tr>
<td><b>Date Posted:</b></td>
<td>$info[Date]</td>
<td>$info2[Date]</td>
</tr>
<tr>
<td><b>Title:</b></td>
<td>$info[propheading]</td>
<td>$info2[propheading]</td>
</tr>
<tr>
<td><b>Transaction:</b></td>
<td>$info[Transaction]</td>
<td>$info2[Transaction]</td>
</tr>
<tr>
<td style='background-color:lightgrey'><b>Detail:</b></td>
<td style='background-color:lightgrey'>$info[Detail]</td>
<td style='background-color:lightgrey'>$info2[Detail]</td>
</tr>
<tr>
<td style='background-color:lightgrey'><b>Price:</b></td>
<td style='background-color:lightgrey'>$info[Price]</td>
<td style='background-color:lightgrey'>$info2[Price]</td>
</tr>
<tr>
<td><b>Additional Data:</b></td>
<td>$info[AdditionalData]</td>
<td>$info2[AdditionalData]</td>
</tr>
<tr>
<td><b>Location:</b></td>
<td>$info[Location]</td>
<td>$info2[Location]</td>
</tr>
<tr>
<td><b>Agent/Individual:</b></td>
<td>$info[Agent_Ind]</td>
<td>$info2[Agent_Ind]</td>
</tr>
<tr>
<td><b>Name:</b></td>
<td>$info[Title] $info[firstname] $info[lastname]</td>
<td>$info2[Title] $info2[firstname] $info2[lastname]</td>
</tr>
<tr>
<td><b>Phone:</b></td>
<td>$info[Phone]</td>
<td>$info2[Phone]</td>
</tr>
<tr>
<td><b>Email:</b></td>
<td>$info[Email]</td>
<td>$info2[Email]</td></tr>
</table>";
$tomail=$info2['Email'];
if ($tomail=="anitgopinath@gmail.com"|$tomail=="anit@landshoppe.com"|$tomail=="info@landshoppe.com") {continue;}
$headers ="From:info@landshoppe.com"."\r\n";
$headers .='Bcc:anit@landshoppe.com'."\n";
$headers .= 'MIME-Version: 1.0'."\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
$subject ="You have a Property Match !";
$message="<html></head><body>
<table width=600 border = 1 style='text-align:left';>
<caption><b><font color='maroon'>YOUR PROPERTY MATCH!</font></b></caption>
<tr>
<td><b>Date Posted:</b></td>
<td>$info[Date]</td>
</tr>
<tr>
<td><b>Title:</b></td>
<td>$info[propheading]</td>
</tr>
<tr>
<td><b>Transaction:</b></td>
<td>$info[Transaction]</td>
</tr>
<tr>
<td style='background-color:lightgrey'><b>Detail:</b></td>
<td style='background-color:lightgrey'>$info[Detail]</td>
</tr>
<tr>
<td style='background-color:lightgrey'><b>Price:</b></td>
<td style='background-color:lightgrey'>$info[Price]</td>
</tr>
<tr><td><b>Additional Data:</b></td><td>$info[AdditionalData]</td></tr>
<tr><td><b>Location:</b></td><td>$info[Location]</td></tr>
<tr><td><b>Agent/Individual:</b></td><td>$info[Agent_Ind]</td></tr>
<tr><td><b>Name:</b></td><td>$info[Title] $info[firstname] $info[lastname]</td></tr>
<tr><td><b>Phone:</b></td><td>$info[Phone]</td></tr>
<tr><td><b>Email:</b></td><td>$info[Email]</td></tr>
</table></body><html>";
echo $tomail."<br>";
echo "$message"."<br>";
$mailresult=mysql_query(mail($tomail,$subject,$message,$headers));
if ($mailresult){echo "Mailed<br>";}else{echo "Not Mailed !<br>";}
echo "**********************************Seller Match**************************************************<br>";
$tomail2=$info['Email'];
if ($tomail2=="anitgopinath@gmail.com"|$tomail2=="anit@landshoppe.com"|$tomail2=="info@landshoppe.com"){continue;}
$headers ="From:info@landshoppe.com"."\r\n";
$headers .='Bcc:anit@landshoppe.com'."\n";
$headers .= 'MIME-Version: 1.0'."\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
$subject ="You have a Property Match !";
$message="<html></head><body>
<table width=600 border = 1 style='text-align:left';>
<caption><b><font color='maroon'>YOUR PROPERTY MATCH!</font></b></caption>
<tr>
<td><b>Date Posted:</b></td>
<td>$info2[Date]</td>
</tr>
<tr>
<td><b>Title:</b></td>
<td>$info2[propheading]</td>
</tr>
<tr>
<td><b>Transaction:</b></td>
<td>$info2[Transaction]</td>
</tr>
<tr>
<td style='background-color:lightgrey'><b>Detail:</b></td>
<td style='background-color:lightgrey'>$info2[Detail]</td>
</tr>
<tr>
<td style='background-color:lightgrey'><b>Price:</b></td>
<td style='background-color:lightgrey'>$info2[Price]</td>
</tr>
<tr>
<td><b>Additional Data:</b></td>
<td>$info2[AdditionalData]</td>
</tr>
<tr>
<td><b>Location:</b></td>
<td>$info2[Location]</td>
</tr>
<tr>
<td><b>Agent/Individual:</b></td>
<td>$info2[Agent_Ind]</td>
</tr>
<tr>
<td><b>Name:</b></td>
<td>$info2[Title] $info2[firstname] $info2[lastname]</td>
</tr>
<tr>
<td><b>Phone:</b></td>
<td>$info2[Phone]</td>
</tr>
<tr>
<td><b>Email:</b></td>
<td>$info2[Email]</td>
</tr>
</table></body><html>";
echo $tomail2."<br>";
echo "$message"."<br>";
$mailresult2=mysql_query(mail($tomail2,$subject,$message,$headers));
if ($mailresult2){echo "Mailed<br>";}else{echo "Not Mailed !<br>";}
echo "**********************************Buyer Match**************************************************<br>";
}
}
}
}
}
}
}
?>