$ClassName=mysql_real_escape_string($_POST["ClassName"], $con);

$query="SELECT ClassID FROM Class WHERE Name='".$ClassName."' ";
$q=mysql_query($query,$con);

its not working..any help...please............!!!!!!!!!

$q = mysql_query($query, $con) or die(mysql_error());

Be more specific.

i have used thz too

$q = mysql_query($query, $con) or die(mysql_error());

its still not working still ((

Post the error you get here. "Not working" is too vague.

when i used this it works

$query="SELECT * FROM Class WHERE Name='".$ClassName."' ";
$row=mysql_fetch_row($q);

can u tel me a good tutorial of implementing ajax with php?

Try w3schools.

Every time you use JavaScript to pass information to a PHP page you need to make sure to encode the strings. And also to add slashes before sending to Database.

Normally the problem relies in JavaScript handling string information. If the string includes and &(ampersand) will break the string into two different variables. The same if the string has quotes or single quotes.

If you're not receiving and error from the mysql_error() then the problem is in the JavaScript not the PHP.

i want the code of passing form elements with post in php with ajax..
i am trying a number of codes,but all in vain:(
can anyone send me please, full code

I agree with Sorcher. If you have enough bandwith there is "e-teacher" somewhere on youtube

The best tutorials in my opinion can be found here;
http://www.developphp.com/
and also if you are pretty new with PHP - MYSQL you should look up Phpacademy on youtube.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.