Jump to content

Can't insert into DB


slpctrl

Recommended Posts

I've recently been getting back into PHP, and I've racked my brain over this incredibly simple piece of code, and can't figure out why I can't insert.

 

<?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
$user = "********";
$pass = md5("********");
$email = "******@live.com";

mysql_select_db("users", $con) or die("unable to select DB");

mysql_query("INSERT INTO users ('user', 'pass', 'email')
VALUES ($user,$pass,$email)") or die("Can't insert info into DB " mysql_error());


mysql_close($con);
?> 

 

I know my error is within the insert command...I just don't understand why this isn't working. I've even copied the code straight from W3schools, and it still doesn't work. My MYSQL version is 5.5.24

 

mod edit: removed user/pass/email details

Link to comment
https://forums.phpfreaks.com/topic/267725-cant-insert-into-db/
Share on other sites

<?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
$user = "********";
$pass = md5("********");
$email = "******@live.com";

mysql_select_db("users", $con) or die("unable to select DB");

mysql_query("INSERT INTO users (user, pass, email)
VALUES ('$user', '$pass', '$email')") or die("Can't insert info into DB " mysql_error());


mysql_close($con);
?> 

 

mod edit: removed user/pass/email details

Link to comment
https://forums.phpfreaks.com/topic/267725-cant-insert-into-db/#findComment-1373461
Share on other sites

I recommend that you go and change your password ASAP. A number of the views of this thread are bot scripts and search engine spiders that read and cache the content and it's only a matter of time before someone logs into your mail account.

Link to comment
https://forums.phpfreaks.com/topic/267725-cant-insert-into-db/#findComment-1373464
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.