Jump to content

Recommended Posts

here is the code

 

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>insertinto</title>

</head>

 

<body>

<?php

$db = mysql_connect("localhost","username","password");

mysql_select_db("nu",$db);

$query = "insert into student (name, fname, age, phone) values ('".$name."','".$fname"','".$age."','".$phone."')" or die(mysql_error());

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

 

echo "Your data is entered correctly......";

?>

</body>

</html>

 

Link to comment
https://forums.phpfreaks.com/topic/153291-need-help/#findComment-805335
Share on other sites

errors like that you just need to read and re-read the line until you can pick something up

you are missing a . after $fname also you only the the "or dir" part on the end of a mysql_query call not when you are putting the query into a var

 

Scott.

Link to comment
https://forums.phpfreaks.com/topic/153291-need-help/#findComment-805336
Share on other sites

 

bit better with database protection.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>insertinto</title>
</head>

<body>
<?php
$db = mysql_connect("localhost","username","password");
mysql_select_db("nu",$db);

$query="insert into student(name, fname, age, phone)values('".mysql_real_escape_string($_POST['name'])."','".mysql_real_escape_string($_POST['fname'])."','".mysql_real_escape_string($_POST['age'])."','".mysql_real_escape_string($_POST['phone'])."')";

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

echo "Your data is entered correctly......";
?>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/153291-need-help/#findComment-805499
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.