rx3mer Posted March 27, 2014 Share Posted March 27, 2014 (edited) Hi guys, First of all I am new to this. I managed to create simple inner join request that displays some results. The problem I am having is that the results come up in the HeidiSQL software but they won't come on the page once coded. include("../includes/config.php"); mysql_connect("$host", "$username", "$password")or die("cannot connect"); $link = mysql_select_db("$db_name")or die("cannot select DB"); $data = mysql_query("SELECT * FROM playlists WHERE HostID IN (SELECT HostID FROM hosts WHERE UserID = 33 ") or die(mysql_error()); while($info = mysql_fetch_assoc( $data )) { ?> <?php ?> <ul> <li> <div> <span>Name: <?php echo $info['PlaylistName']; ?></span> </div> </li> </ul> <?php } ?> I get: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 I am using MySQL and PHP Any ideas? Edited March 27, 2014 by rx3mer Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted March 27, 2014 Share Posted March 27, 2014 the sql statement in your php code is not the same as when you directly ran it. i recommend that your form your sql statement in a php variable, thereby separating the sql from the php code running the query, so that you can echo the sql statement to see exactly what it is. Quote Link to comment Share on other sites More sharing options...
Solution rx3mer Posted March 27, 2014 Author Solution Share Posted March 27, 2014 I just found that MySQL can convert Queries to PHP. I know its probably not the best way to go, but I don't have much time at the moment. SELECT *\n". "FROM playlists\n". "WHERE HostID IN (\n". "SELECT HostID\n". "FROM HOSTS\n". "WHERE UserID = 33)" Thank you for your response! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.