0

I have the following code, but for some reason I am getting an unexpected T_Variable. I can't seem to figure out where I am getting the error at. Any assistance will be greatly appreciated. Thanks

<? php 
$status = mysql_query('SELECT count(*) FROM AHG WHERE `Survey Tech Initials` = 'Jeff' AND   completed = 'yes');
if (!$result) {
die('Invalid query: ' . mysql_error());
}
?>
  • 1
    Look at the highlighting in the post above. It should be quite clear :) – andrewsi Feb 17 '14 at 22:15
  • 1
    Surround the select statement in double quotes, not single. `"SELECT count(*)....AND completed = 'yes'"` – Michael Berkowski Feb 17 '14 at 22:16
  • 1
    I really should write an article named "Notepad/wordpad considered bad practice while coding" – Royal Bg Feb 17 '14 at 22:16
  • 1
    @RoyalBg - I spent about two years writing code using DOS edit. – andrewsi Feb 17 '14 at 22:17
  • 2
    Please see [Why should I not use mysql_ functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) -- now is the time to start planning your migration to a newer supported API. The `mysql_*()` functions have a limited lifespan at this point, in addition to encouraging insecure coding practices. – Michael Berkowski Feb 17 '14 at 22:18
  • @andrewsi I hope you did not, while better alternatives were out there. I have spent some time on BASIC in its native editor (same as DOS edit) too. But in era of modern text editors and IDE's it's more than a bad practice. It's real alert for missunderstanding the modern conception of programming. Most of the courses about that starts with what and where from to download the relevant IDE for the particular language – Royal Bg Feb 17 '14 at 22:19
  • @RoyalBg - I couldn't agree more. It was a a long time ago, though, and we were very limited to what we could use based on budget and equipment. These days, there are so many good editors out there, it's just a case of finding one that suits. – andrewsi Feb 17 '14 at 22:21

1 Answers1

1

See below

<? php 
$status = mysql_query("SELECT count(*) FROM AHG WHERE `Survey Tech Initials` = 'Jeff' AND completed = 'yes'");
if (!$result) {
die('Invalid query: ' . mysql_error());
}
?>
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
matwr
  • 1,548
  • 1
  • 13
  • 23