MYSQL($Dbname, "INSERT INTO $Tbname_1 VALUES(1, 'John Doe', '$color')");
- single quotes around $color Jo Ann Comito wrote:
I'm working in PHP4 and have suceeded in creating a mySQL table. I can fill the table using the INSERT command as follows: <? //some code here to establish connection, define and create table, etc. ..... MYSQL($Dbname, "INSERT INTO $Tbname_1 VALUES(1, 'John Doe', 'red')"); MYSQL($Dbname, "INSERT INTO $Tbname_1 VALUES(2, 'Jane Smith', 'green')"); ...... ?> The above works fine. Here is the problem: Instead of specifying the color, red, green, etc. I would like to generate a random color and store it in a variable, then use the variable in the INSERT command. To simplify the code in this example, I have just assigned a color to the varialble. $color = "red"; MYSQL($Dbname, "INSERT INTO $Tbname_1 VALUES(1, 'John Doe', $color)"); $color="green" MYSQL($Dbname, "INSERT INTO $Tbname_1 VALUES(2, 'Jane Smith', $color)"); This syntax does not work. The table is created, but it has 0 rows. I have tried a multitude of variations, including ECHO $color '$color' \'$color\' {$color} etc. No combination I have tried works. Could some kind person please point me in the right direction? Thanks, Jo Ann
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php