MySQL help

Status
Not open for further replies.

Macemore

Circumcised pineapples
Aug 26, 2011
1,681
819
I have a form and it posts some one's username (give through form) to this:
PHP:
<?php
$user = $_POST['usre'];
$con = mysql_connect("localhost","u240887943_use","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("u240887943_use", $con);

mysql_query("INSERT INTO users (user)
VALUES ($user)");
mysql_close($con);
echo 'totally worked';
?>
but nothing ends up in my table! I'm not getting connection issues because there's no error. so I'm guessing it's something with tables.
Could you set up a SQL file that I can run in my database and see if that works? ;<

help please :D
 

Ept

Many men wish death upon me.
Jun 16, 2011
591
276
PHP:
<?php
$user = $_POST['usre'];
$con = mysql_connect("localhost","u240887943_use","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
 
mysql_select_db("u240887943_use", $con);
 
mysql_query("INSERT INTO users (user)
VALUES ('$user')");
mysql_close($con);
echo 'totally worked';
?>
Try that.
 

Macemore

Circumcised pineapples
Aug 26, 2011
1,681
819
PHP:
<?php
$user = $_POST['usre'];
$con = mysql_connect("localhost","u240887943_use","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
 
mysql_select_db("u240887943_use", $con);
 
mysql_query("INSERT INTO users (user)
VALUES ('$user')");
mysql_close($con);
echo 'totally worked';
?>
Try that.
THAT WORKED!
yaaay, what'd you change?
 

XenPHP

New Member
Apr 13, 2012
16
1
Next time, after a query, just make it die. This way, you can get the actual error, and it will be a whole lot easier, and one less help thread on DevBest. For example...
PHP:
mysql_query("UPDATE users SET username = '$user' WHERE id = '1'") or die(mysql_error());
 

Macemore

Circumcised pineapples
Aug 26, 2011
1,681
819
Next time, after a query, just make it die. This way, you can get the actual error, and it will be a whole lot easier, and one less help thread on DevBest. For example...
PHP:
mysql_query("UPDATE users SET username = '$user' WHERE id = '1'") or die(mysql_error());
Thanks, I started SQL today so ;d
 
Status
Not open for further replies.

Users who are viewing this thread

Top