MySQL Forums
Forum List  »  Newbie

connect mysql with ajax
Posted by: umut gurler
Date: November 01, 2009 01:36AM

hi!
i am trying to connect MySQL with ajax interface.
but i am getting "parsing error" in my localhost.
may my MySQL server is down or my code is wrong ? help me please.



<?php
$dbhost = "localhost";
$dbuser = "cam-balkon";
$dbpass = "1234567890";
$dbname = "cam-balkon-sistemleri";

mysql_connect($dbhost, $dbuser, $dbpass);

mysql_select_db($dbname) or die(mysql_error());

$age = $_GET['age'];
$sex = $_GET['sex'];
$wpm = $_GET['wpm'];

$age = mysql_real_escape_string($age);
$sex = mysql_real_escape_string($sex);
$wpm = mysql_real_escape_string($wpm);

$query = "SELECT * FROM ajax_example WHERE ae_sex = '$sex'";
if(is_numeric($age))
$query .= " AND ae_age <= $age";
if(is_numeric($wpm))
$query .= " AND ae_wpm <= $wpm";

$qry_result = mysql_query($query) or die(mysql_error());


$display_string = "<table>";
$display_string .= "<tr>";
$display_string .= "<th>Name</th>";
$display_string .= "<th>Age</th>";
$display_string .= "<th>Sex</th>";
$display_string .= "<th>WPM</th>";
$display_string .= "</tr>";


while($row = mysql_fetch_array($qry_result)){
$display_string .= "<tr>";
$display_string .= "<td>$row[ae_name]</td>";
$display_string .= "<td>$row[ae_age]</td>";
$display_string .= "<td>$row[ae_sex]</td>";
$display_string .= "<td>$row[ae_wpm]</td>";
$display_string .= "</tr>";

}
echo "Query: " . $query . "<br />";
$display_string .= "</table>";
echo $display_string;
?>

umt

Options: ReplyQuote


Subject
Written By
Posted
connect mysql with ajax
November 01, 2009 01:36AM
November 01, 2009 02:09PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.