Jump to content

Recommended Posts

I entered this code into mysql (phpmyadmin) [code]CREATE TABLE users (
userid INT unsigned NOT NULL AUTO_INCREMENT primary key,
username char(16) not null,
password char(10) not null,
email char (20) not null
);

[/code]

but in my php code [code]// if ok, put in db
  $result = mysql_query("insert into user values
                        ('$username', sha1('$password'), '$email')");
  if (!$result)
    throw new Exception(mysql_error);

  return true;
}[/code]

i am getting an error saying "mysql_error". help please ???
Link to comment
https://forums.phpfreaks.com/topic/32716-solved-sql/
Share on other sites

well you have 4 fields and only inserting 3 values it thinks you are trying to insert the username into the id field.

try
[code]// if ok, put in db
  $result = mysql_query("insert into user (username, password, email) values
                        ('$username', sha1('$password'), '$email')");
  if (!$result)
    throw new Exception(mysql_error);

  return true;
}[/code]

Ray
Link to comment
https://forums.phpfreaks.com/topic/32716-solved-sql/#findComment-152281
Share on other sites

[code]<?php
// if ok, put in db
 $result = mysql_query("insert into user values
                        ('$username', sha1('$password'), '$email')");
 if (!$result)
   throw new Exception(mysql_error());

 return true;
?>[/code]

mysql_error is a function.
Link to comment
https://forums.phpfreaks.com/topic/32716-solved-sql/#findComment-152284
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.