Jump to content

why wont my MySQL INSEERT INTO variable work?


ICEcoffee

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
$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

Archived

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

×
×
  • Create New...

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.