Making a Video Player.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

I tried all of them like that, still I get the error.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Are you using dreamweaver? They thrown in hidden characters the odd time..

try copy and pasting the file into microsoft word and then copy that back into your editor
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

I use BBedit , which doesnt have any hidden characters, I will see though.

No hidden characters.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

nickman013 wrote:I use BBedit , which doesnt have any hidden characters, I will see though.
I presume you're using OS X? Try Taco Edit, it's pretty good... and free!
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

Try $clause=NULL
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

Still, I get the error.

I will download Taco edit.
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

WHOAAAAAA,, Thanks for telling me about taco, every space had a hidden character.

Now it connects to the DB

But If I go to the link http://www.example.com/play.php?id=4

It doesnt play, It includes a page that is the path to the video's in this case it would be /pages/videos/

It is not getting the data from the DB.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

If your using the code I gave you it was not complete.. I left out fetching the info from the db up to you (even though I gave you code to build the query)..

I would also suggest you look carefully at the logic of the code, especially outputting the embedded source. Think about it, you only want to display a movie if your query returns 1 row (hint mysql_num_rows()).. if not show all movie links
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

Ok,

This is where I am at right now.

Code: Select all

<?php
$username= "muot_video";
$password= "password";
$database= "muot_videos";
mysql_connect('localhost',$username,$password);
$result = mysql_query('SELECT `Filename` from `muot_videos` where `ID`=$id');
if (!$result) {
   die('Could not query:' . mysql_error());
}
echo mysql_result($result, 2); 
?>
The problem I have now is that it is giving me this error
Could not query:No database selected
Seems so simple but I think I am already connected to the DB.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

there'll be a single quote versus double quote issue too. Not to mention security filtering on $id.. :roll:
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

OK, I can connect now.

But now I get this error.
Could not query:Unknown column '$id' in 'where clause'
play.php

Code: Select all

<?
$username= "muot_video";
$password= "video";
$database= "muot_videos";
$connection = mysql_connect('localhost',$username,$password);
mysql_select_db($database, $connection);
$result = mysql_query('SELECT `Filename` from `videos` where `ID`=$id');
if (!$result) 	{
   die('Could not query:' . mysql_error());
				}
echo mysql_result($result);
?>
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

That's because PHP is parsing $id litterally, because you are using single quotes which do not expand variables which I explained to you in IM and feyd has already mentioned. Replace the single quotes around the query with double quotes, or ideally concate that $id in with some kind of filtering:

Code: Select all

$sql = 'select * from table where `id` = ' . (int)$id ' limit 1'
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

I replaced single quotes, with double quotes. But I still get the same error.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

that seems unlikely, even if $id was not an integer it should not be saying "unknown column $id" or whatever, post your code.
Post Reply