Jump to content


Photo

Trouble inserting data


  • Please log in to reply
4 replies to this topic

#1 tjhilder

tjhilder
  • Members
  • PipPipPip
  • Advanced Member
  • 136 posts
  • LocationKent, UK

Posted 04 November 2005 - 02:12 AM

Hi,

I'm new to MySQL and know a limited knowledge of PHP, so I'm having a problem with trying to put information into MySQL, can someone tell me what I'm doing wrong with this code?

<?php
$uid = 'member_userid';
$uname = 'member_username';
$pwd = 'member_password';
$fname = 'member_fullname';
$email = 'member_email';
$rank = 'member_rank';
// get connection and database information
require_once('admin/mysql/mysql_connect.inc');

// Insert information into members for member: tjhilder
$query = "INSERT INTO members ($uid,$uname,$pwd,$fname,$email,$rank) VALUES (
        `1`,
        `tjhilder`,
        `something`,
        `TJ Hilder`,
        `tjhilder@something.com`,
        `1`
        )";

// Create data for Members
mysql_query($query) or die(mysql_error());

echo "<a href=\"mysql3.php\">Click Here</a>";

?>

I'm getting this error:

Unknown column '1' in 'field list'

thanks in advance if you can help me :)

TJ

#2 Cook

Cook
  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts
  • LocationSingapore

Posted 04 November 2005 - 03:31 AM

Your strings in the VALUES() clause should be enclosed with single-quotes ('), not backticks (`).
Cook

#3 tjhilder

tjhilder
  • Members
  • PipPipPip
  • Advanced Member
  • 136 posts
  • LocationKent, UK

Posted 04 November 2005 - 05:55 AM

thanks, I believe that worked, but I'm not sure. how do I check it?

I don't know how to display the information, can anyone help me please?

#4 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 04 November 2005 - 06:12 AM

I'm showing you the basic.
$query = "SELECT * FROM members";
$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_row($result))
{
    foreach($row as $value)
       echo "$value ";
}

Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#5 tjhilder

tjhilder
  • Members
  • PipPipPip
  • Advanced Member
  • 136 posts
  • LocationKent, UK

Posted 06 November 2005 - 02:42 AM

thanks, it's working :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users