Marzia Abasszadah Marzia Abasszadah - 3 months ago 5
PHP Question

Mysql insert - don't insert

I'm new and have a question.

I think you know it , but I 'm new.
So I hope you can see what here wrong is and why!

And this is my Code

<?php
//Verbindung zur Datenbank herstellen
mysql_connect("****:3306", "****","*****!") or die ("Verbindung nicht möglich");
mysql_select_db("***") or die ("Datenbank existiert nicht");

$select = mysql_query("SELECT * FROM tbl_users WHERE userID = " . intval($row['userID']));
while ($row = mysql_fetch_array($select))
{
$row['userID'];
$row['userName'];
$select = mysql_query("INSERT INTO spielautomat_gewinn (userID, userName, gewinn) VALUES ('{$row['userID']}', ''{$row['userName']}', '+')");
}
?>


So, first select then insert.
But Insert don't work, but it may also be due to select, but insert don't work.
And so I can not check select.
And there are not Errors, the Website work but insert not.

I hope you can help me.
Thanks

Answer

It's Okay that you are new :) every one was new. Step the million strats with one. This is the problem: *) You did not save the $row['userID'] and $row['userName'] to variables Solution:

<?php
    //Verbindung zur Datenbank herstellen
mysql_connect("localhost:3306", "kevin","madarmadar22!") or die ("Verbindung nicht möglich");
mysql_select_db("mohammada_kevin") or die ("Datenbank existiert nicht");

$select = mysql_query("SELECT * FROM tbl_users WHERE userID = " . intval($row['userID']));
while ($row = mysql_fetch_assoc($select))
{
  $uid = $row['userID'];
  $userName = $row['userName'];
$select = mysql_query("INSERT INTO spielautomat_gewinn (userID, userName, gewinn) VALUES ('$uid', '$userName', '+')");
}
?>