Pulling up database fields in a list (with links)

This was originally a code that i used with an older version of php, and i changed it a bit to make it work with the new version, but as you can tell, it’s not working.

I have been struggling with this code for a few days now, and i can’t figure it out. Anyone see anything wrong with the following code? My database fields are: show, season, episode, code…

[code]<?
if(!isset($_GET[‘show’])) {
echo “You did not select a show!”;
exit;
}
$show=$_GET[‘show’];
?>

PlayMode.TV - Watch <? echo $row['show']; ?>

<?php $dbhost = 'localhost'; $dbuser = '*********'; $dbpass = '*****'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'playmode_shows' or die ('Error: '.mysql_error ()); mysql_select_db($dbname); $query = "SELECT `episode`, `show`, `code` FROM `shows` WHERE `episode`='$episode' ORDER BY `episode`"; $result = mysql_query ('SELECT * FROM shows') or die ('Error: '.mysql_error ()); while($row = mysql_fetch_array($result, MYSQL_ASSOC)); ?>

    <? echo $row['episode']; ?>

<? mysql_close($conn) or die ('Error: '.mysql_error ()); ?>[/code]

I’m trying to use that code to pull up a list of my shows in my db with the link http://www.playmode.tv/index.php?page=shows&show=Scrubs

Also, this is the code for the page that I’m trying to link to, which is also not working…

[code]<?
if(!isset($_GET[‘episode’])) {
echo “You did not select an episode!”;
exit;
}
$title=$_GET[‘episode’];
?>

<?php $dbhost = 'localhost'; $dbuser = '*********'; $dbpass = '*****'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'playmode_shows'; mysql_select_db($dbname); $query = "SELECT `episode`, `code` FROM `shows` WHERE `episode`='$episode'"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) ?>

    <? echo $row['code']; ?>
<? mysql_close($conn); ?>[/code]

If you manually (using something like phpMyAdmin) run the query SELECT * FROM shows on the database playmode_shows what does it return?

I’m not sure if this is what you wanted but: SQL query: Documentation

SELECT shows.show
FROM shows
WHERE (
shows.show Scrubs
)
ORDER BY shows.show ASC
LIMIT 0 , 30

MySQL said: Documentation
#1064 - 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 ‘Scrubs)
ORDER BY shows.show ASC
LIMIT 0, 30’ at line 3

Or I tried entering what you told me and got nothing…:

Showing rows 0 - 1 (2 total, Query took 0.0004 sec)
SQL query:
SELECT *
FROM shows
LIMIT 0 , 30

(No results i guess?)

I uploaded a screenshot of my results if the text was unclear…

Edit: I get the same results if i use show instead of *

[attachment deleted by admin]

You missed a = between shows.show and Scrubs.

I didn’t generate that code. I typed what i wanted to pull up in the form and it generated it for me. Does that mean my phpmyadmin is messed up?

Sponsor our Newsletter | Privacy Policy | Terms of Service