MySQL client version: 4.0.16
Ok i am having a little problem with the following converting mysql into php.
Using the following mysql statement
INSERT INTO Url_User( Userid, Urlid )
SELECT 'bob', Urlid
FROM Urls
WHERE url = 'www.excel.com';
Now I can get the following code to work if i hard code it e.g(Bob and www..adobe.com).
$sql = 'INSERT INTO Url_User( Userid, Urlid ) '
. ' SELECT \'bob\', Urlid'
. ' FROM Urls'
. ' WHERE url = \'www.excel.com\';';
mysql_query ($sql);
the problem that i have is when i try to insert variables into the sql statement. For example, if i replace bob with $x (e.g. $x = bob1;) then the code doesnt pick up the variable it inserts "$x" into the table. Now if i strip the \' s from the code (ie \'$x\' to $x) it still doesn't work. Any suggestions?