durins_day Posted March 22, 2008 Share Posted March 22, 2008 I'm trying to place user variables into a new SQL table, however im not having any luck at all. Can anyone explain to me why the following code fails to insert a new table into omg_usuarios? $db =& JFactory::getDBO(); //Get SQL database. $user =& JFactory::getUser(); //Get the logged in username, email, and real name $username = $user->get('username'); $name = $user->get('name'); $email = $user->get('email'); $password = 'whatever'; // Create New usertable $sql = "INSERT INTO `omg_usuarios` (`id`, `nome`, `usuario`, `contrasinal`, `contrasinal_tmp`, `email`, `estado`, `admin`, `id_grupo`, `mantemento`, `descargas_maximo`, `cambiar_datos`) VALUES (NULL, '$name', '$username', '$password', '', '$email', '1', '0', '2', CURDATE(),'150000', '1')"; $result = mysql_query($sql); In the end I don't even get an empty table, nothing! If I use print($username); the logged in user's name, email, and username shows up as expected. I'm so lost! Thanks! Link to comment https://forums.phpfreaks.com/topic/97397-help-my-sqlinsert-into-broke/ Share on other sites More sharing options...
BlueSkyIS Posted March 22, 2008 Share Posted March 22, 2008 to see if you're mysql_query is failing change this $result = mysql_query($sql); to $result = mysql_query($sql) or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/97397-help-my-sqlinsert-into-broke/#findComment-498398 Share on other sites More sharing options...
AndyB Posted March 22, 2008 Share Posted March 22, 2008 or better yet: $result = mysql_query($sql) or die("error ". mysql_error(). " with query ". $sql); Link to comment https://forums.phpfreaks.com/topic/97397-help-my-sqlinsert-into-broke/#findComment-498399 Share on other sites More sharing options...
durins_day Posted March 22, 2008 Author Share Posted March 22, 2008 Thanks guys!!! Solved it!! My problem (besides being a moron) was that the value of $username was already an entry in field 'nome'! Sorry for wasting your time! Link to comment https://forums.phpfreaks.com/topic/97397-help-my-sqlinsert-into-broke/#findComment-498411 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.