Jump to content

MySQL INNER JOIN won't work on page


rx3mer
Go to solution Solved by rx3mer,

Recommended Posts

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.

 

heidi.jpg

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 by rx3mer
Link to comment
Share on other sites

  • Solution

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!

Link to comment
Share on other sites

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.