Forum Moderators: coopster
Help!
Thank you
$query = "UPDATE student SET
(stu_id='$stu_id' And f_name='$f_name'And l_name='$l_name'And phone='$phone')";
@mysql_select_db($database)
I can see lots many problems. I am discussing them below :
I dont think the way you are establishing your database connection is correct.
Here is how you should do it and also it is better to establish the connection before you execute any query...generally we make a single file for databse connection and include it in every other file at the top of the page.
$dbc = mysql_connect("server", "user", "password");
if (!$dbc) {
echo ' Cannot connect to the database because ' . mysql_error();
}
mysql_select_db('databasename', $dbc);
if (!mysql_select_db('databasename')) {
echo ' Cannot select the database because ' . mysql_error();
}
And also, your query doesnt look too good to me, make it this way.
$query = "UPDATE student SET stu_id='$stu_id', f_name='$f_name', l_name='$l_name' AND phone='$phone';";
Lastly you aren't exexuting this query anywhere. Do this
if (!mysql_query($query)) {
echo mysql_error();
}
I hope on correcting all the above, it should work.
</body>
</html>
Change the l_name type to one of the string types. (if varchar, don't forget that you can set your string to a limited amount, anywhere from 1 to anywhere under 255 charactors in length. This is the best choice for usernames, email, first/last name, etc that won't be long to save space.)
Hope that helps you. If that's not the issue, just reply.