View Full Version : need help with modifying a database

02-09-2007, 02:21 PM
Hey folks
I'm new here & very VERY new to PHP & MySQL.

here's the wrap, i need to create a database for calculating somebody's wages.

I've made the calculator, i've created a table that pulls out an employee's information, & i've managed to creat a form & handler that will insert new employee data. However, I dont have a clue how to create a modify page so the user can access the table from the web browser & alter information.

Here's what i've got:



$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Not connected : ' . mysql_error());
db_selected = mysql_select_db($dbname, $link);
if (!$db_selected) {
die ('Can\'t use foo : ' . mysql_error());


$query = " UPDATE $tablename SET (`number` , `name` , `address` , `postcode`, `telephone` , `email` , `hours`)

VALUES ('$number', '$name', '$address', '$postcode', '$telephone', '$email', '$hours') where primaryky = `number`;";

if (mysql_select_db($dbname, $link, )){;

print "\"die('Could not connect: ' . mysql_error())\"";


All I seem to get is:

Parse error: parse error, unexpected '=' in c:\inetpub\wwwroot\04\c301\Advanced Web Applications\test folder\test.php on line 17

Dont suppose anybody can help me? my assignments a week late & the tutor hasn't got any information on his site :confused:


02-09-2007, 02:54 PM
check the line the error is on:
it should most likely be a variable.

02-09-2007, 03:27 PM
hello! thankyou!

however, what does that mean?

02-09-2007, 03:37 PM
what do you think it means? What is a variable? You should know that. The error message is telling you there is an error on that line. You should have caught that before posting. As you didn't I pointed it out so change that to a variable.

Lord Emperor
02-11-2007, 11:45 PM
Newbie-friendly hint: variables in PHP must be prefixed with a dollar "$". So change

db_selected = mysql_select_db($dbname, $link);


$db_selected = mysql_select_db($dbname, $link);

Also, I noticed that in the end you use


but your DB connection is $link.

02-13-2007, 10:56 AM
as Lord Emperor stated you missed out the $ on the following line

db_selected = mysql_select_db($dbname, $link);
if (!$db_selected) {

should be

$db_selected = mysql_select_db($dbname, $link);
if (!$db_selected) {