Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy need help with modifying a database

    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:

    PHP Code:
    [COLOR="Navy"]<html>
    <head>
    </head>
    <body>[/COLOR]
    [COLOR="DarkRed"]
    <?php   
     $host
    ="local";
    $user="c301";
    $password="fo";
    $dbname="c301";
    $tablename="employee"

    $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()); 

    $dbname="c3018192";
    $tablename="employee";

     
    $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
    "\"ok\"";                                                               
            } 
            else
            {                   
      print 
    "\"die('Could not connect: ' . mysql_error())\"";
      }
    mysql_close($con);
    ?>[/COLOR]
    </body>
    </html>
    [/COLOR]


    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

    Rob
    Last edited by guelphdad; 02-12-2007 at 01:00 AM.

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,631
    Thanks
    4
    Thanked 147 Times in 138 Posts
    check the line the error is on:
    db_selected
    it should most likely be a variable.

  • #3
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hello! thankyou!

    however, what does that mean?

  • #4
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,631
    Thanks
    4
    Thanked 147 Times in 138 Posts
    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.

  • #5
    New Coder
    Join Date
    Feb 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Newbie-friendly hint: variables in PHP must be prefixed with a dollar "$". So change

    PHP Code:
    db_selected mysql_select_db($dbname$link); 
    to

    PHP Code:
    $db_selected mysql_select_db($dbname$link); 
    Also, I noticed that in the end you use

    PHP Code:
    mysql_close($con); 
    but your DB connection is $link.
    Jozef "Lord Emperor" Jirasek

    English is my second language, excuse any mistakes I make.

  • #6
    Regular Coder
    Join Date
    Jan 2007
    Posts
    213
    Thanks
    0
    Thanked 0 Times in 0 Posts
    as Lord Emperor stated you missed out the $ on the following line
    Code:
       db_selected = mysql_select_db($dbname, $link);
    if (!$db_selected) {
    should be
    Code:
       $db_selected = mysql_select_db($dbname, $link);
    if (!$db_selected) {
    Matthew Bagley
    Paramiliar Design Studios
    Website Design | Website Development | Search Engine Optimisation (SEO)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •