0

I'm trying to display youTube videos on a page. the code is stored in a mySQL database.

I'm a real dummy when it comes to this. If anyone asks me to make an informed decision about changing the code I will not know what to do. I'm basically the copy and paste type so I'll be very grateful if someone can give me a corrected code. I'm sure the flaw is big as a bull but hey I'm a bit short-sighted at this!

I'm using this code. I'm not getting error messages or anything for that matter. Just a blank page.

Thanks!!

Eugenie

This is the code I'm using:

<?php

$DBhost = "localhost";
$DBuser = "----";
$DBpass = "----";
$DBName = "----";
$table = "----";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");

@mysql_select_db("$DBName") or die("Unable to select database $DBName");

$results = mysql_query($sqlquery);


$clip1 = $row["clip1"];
$clip2 = $row["clip2"];
$clip3 = $row["clip3"];
$clip4 = $row["clip4"];


echo "<iframe src=\"{$clip1}\" style=\"background: #fff;\" frameborder=\"0\" height=\"300\"     scrolling=\"auto\" width=\"480\"></iframe>"; 
echo "<iframe src=\"{$clip2}\" style=\"background: #fff;\" frameborder=\"0\" height=\"300\"     scrolling=\"auto\" width=\"480\"></iframe>"; 
echo "<iframe src=\"{$clip3}\" style=\"background: #fff;\" frameborder=\"0\" height=\"300\"     scrolling=\"auto\" width=\"480\"></iframe>"; 
echo "<iframe src=\"{$clip4}\" style=\"background: #fff;\" frameborder=\"0\" height=\"300\"     scrolling=\"auto\" width=\"480\"></iframe>"; 

?> 
Eugenie
  • 17
  • 1
  • 7
  • 2
    A blank page, in this case, means that the variables aren't set. To start debugging, make use of the error handling functions. Try `mysql_query($sqlquery) or die(mysql_error());` and see what it outputs. And if you're just starting out, I'd recommend learning PDO or mySQLi instead **([`mysql_*`](http://stackoverflow.com/questions/13944956/) functions are deprecated)** – Amal Murali Aug 13 '13 at 13:36
  • Well, you shouldn't just copy and paste. You should at least try to learn what you are working with. – Kneel-Before-ZOD Aug 13 '13 at 14:10

2 Answers2

0

Define proper way to process result set

Step 1: Define sql query


   $sqlquery="select * from some_table";

Step 2: Run the query


   $results = mysql_query($sqlquery);

Step 3: Retrieve the result


   while($row=mysql_fetch_array($results,MYSQL_ASSOC)){
      echo ""; 
   }

Kneel-Before-ZOD
  • 4,141
  • 1
  • 24
  • 26
alok.kumar
  • 380
  • 3
  • 11
0

This worked:

$con=mysqli_connect("localhost","-----","------","--------");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT * FROM pool");


while($row = mysqli_fetch_array($result))
{
$clip1 = $row["clip1"];
$clip2 = $row["clip2"];
$clip3 = $row["clip3"];
$clip4 = $row["clip4"];
  }

echo "<iframe src=\"{$clip1}\" style=\"background: #fff;\" frameborder=\"0\" height=\"300\"     scrolling=\"auto\" width=\"480\"></iframe><p>"; 
echo "<iframe src=\"{$clip2}\" style=\"background: #fff;\" frameborder=\"0\" height=\"300\"     scrolling=\"auto\" width=\"480\"></iframe><p>"; 
echo "<iframe src=\"{$clip3}\" style=\"background: #fff;\" frameborder=\"0\" height=\"300\"     scrolling=\"auto\" width=\"480\"></iframe><p>"; 
echo "<iframe src=\"{$clip4}\" style=\"background: #fff;\" frameborder=\"0\" height=\"300\"     scrolling=\"auto\" width=\"480\"></iframe><p>";
Eugenie
  • 17
  • 1
  • 7