Jump to content

Archived

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

ICEcoffee

why wont my MySQL INSEERT INTO variable work?

Recommended Posts

Hi all

I can't get this INSERT command to work using a variable?

I want to take the value from querying 1 table and INSERT that data into another table.




<?php
echo "race variables";
mysql_select_db($database_FF1, $FF1);
$raceq = ('SELECT RaceID FROM races WHERE CurrentRace = 1');
$raceresult = mysql_query($raceq) or die(mysql_error());
$row = mysql_fetch_array($raceresult);


// mysql_select_db($database_FF1, $FF1);
$leaderq = "INSERT INTO ff1_leaderboard (RaceID, TeamID) VALUES ($row['RaceID'],'9')";
mysql_query($leaderq) or die(mysql_error());


?>

Thanks for any help

Share this post


Link to post
Share on other sites
$leaderq = "INSERT INTO ff1_leaderboard (RaceID, TeamID) VALUES ($row['RaceID'],'9')";


needs to be


$leaderq = "INSERT INTO ff1_leaderboard (RaceID, TeamID) VALUES ('$row[RaceID]','9')";



variables ahve to be wrapped with ' either side

Regards
Liam

Share this post


Link to post
Share on other sites

×

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.