Jump to content

Recommended Posts

Hi all

I am having a problem with the following statement - ie it doesn't work.

$qualyq = ('SELECT * FROM t_qualy_results WHERE t_qualy_results.RaceID = "$row[RaceID]"') or die(mysql_error());
$qualyr = mysql_query($qualyq) or die(mysql_error());
echo "<br> Driver and Points <br>";
while($qualyrow = mysql_fetch_array($qualyr)) {
echo $qualyrow['Driver'];
}

If I substitute "$row[RaceID]" for the number 1, I get expected results, which also veryfies faild names and data are all intact, so I think it has something to do with the accepting of the variable, which I test with an echo statement a few lines before this one and it returns the value of 1, as expected.

Any ideas? it's driving me nuts.


Cheers
Link to comment
https://forums.phpfreaks.com/topic/8276-whats-wrong-with-my-select-statement/
Share on other sites

Your query uses a array ($row['RaceID'])
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?php
// These examples are specific to using arrays inside of strings.
// When outside of a string, always quote your array string keys
// and do not use {braces} when outside of strings either.

// Let's show all errors
error_reporting(E_ALL);

$fruits = array('strawberry' => 'red', 'banana' => 'yellow');

// Works but note that this works differently outside string-quotes
echo "A banana is $fruits[banana].";

// Works
echo "A banana is {$fruits['banana']}.";

// Works but PHP looks for a constant named banana first
// as described below.
echo "A banana is {$fruits[banana]}.";

// Won't work, use braces. This results in a parse error.
echo "A banana is $fruits['banana'].";

// Works
echo "A banana is " . $fruits['banana'] . ".";

// Works
echo "This square is $square->width meters broad.";

// Won't work. For a solution, see the complex syntax.
echo "This square is $square->width00 centimeters broad.";[/quote]

since your query is a string, I simply 'broke out of it'
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.