Having trouble running queries in PHP

Avatar
  • Answered
I copy/pasted the PHP code from the help page into my .php file, but when I access it and try to print the results to the screen, the query is blank. I know the query itself has no typos because I ran the same string within the MyPHPAdmin app and it worked fine.

The code I used is below. I see the "X:" portion of the string on the screen, but the $results variable is blank.

$query="SELECT * FROM $usertable";
$result=mysql_query($query);
echo "X: " . $result;
Avatar
IMH Support Agent 5
Hello collin31,

Thank you for contacting us about the difficulty you're having running queries in PHP. From what I see in the code, and having testing it, I advise make sure you have PHP beginning and end tags.

Also, I think the code might be having trouble connecting because it doesn't the MySQL database and user information.

Let us know if you have any further questions.