Page 3 of 4
Posted: Thu Feb 02, 2006 10:15 pm
by nickman013
I tried all of them like that, still I get the error.
Posted: Thu Feb 02, 2006 10:16 pm
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
Posted: Thu Feb 02, 2006 10:18 pm
by nickman013
I use BBedit , which doesnt have any hidden characters, I will see though.
No hidden characters.
Posted: Thu Feb 02, 2006 10:20 pm
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!
Posted: Thu Feb 02, 2006 10:22 pm
by josh
Try $clause=NULL
Posted: Thu Feb 02, 2006 10:27 pm
by nickman013
Still, I get the error.
I will download Taco edit.
Posted: Thu Feb 02, 2006 10:33 pm
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.
Posted: Thu Feb 02, 2006 11:16 pm
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
Posted: Thu Feb 02, 2006 11:25 pm
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.
Posted: Thu Feb 02, 2006 11:29 pm
by John Cartwright
Posted: Thu Feb 02, 2006 11:33 pm
by feyd
there'll be a single quote versus double quote issue too. Not to mention security filtering on $id..

Posted: Thu Feb 02, 2006 11:44 pm
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);
?>
Posted: Fri Feb 03, 2006 12:21 am
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'
Posted: Fri Feb 03, 2006 12:47 am
by nickman013
I replaced single quotes, with double quotes. But I still get the same error.
Posted: Fri Feb 03, 2006 12:51 am
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.