我想得到我桌子上一个单元格的内容。 我的代码是这个 - >
session_start();
$username = $_SESSION["username"];
// Connect to your Database
mysql_connect("localhost", "root", "*!#@%#") or die(mysql_error());
//Select DB
mysql_select_db("yplay") or die(mysql_error());
$PlayList = mysql_query("SELECT * FROM users WHERE username=" . $username);
$videos = $PlayList["playlist"];
该单元格的内容必须在$ videos
中由于
答案 0 :(得分:2)
session_start();
$username = $_SESSION["username"];
mysql_connect("localhost", "root", "*!#@%#") or die(mysql_error());
mysql_select_db("yplay") or die(mysql_error());
$PlayListQuery = mysql_query("SELECT * FROM users WHERE username=" . $username." LIMIT 1");
$PlayList = mysql_fetch_assoc($PlayListQuery); // Do something with the result set from the query
$videos = $PlayList["playlist"];
答案 1 :(得分:0)
试试这个
session_start();
$username = $_SESSION["username"];
// Connect to your Database
$hostname = "localhost";
$username = "root";
$password = "*!#@%#";
$db_name = "yplay";
$conn = mysql_connect("localhost", "root", "*!#@%#") or die(mysql_error());
//Select DB
mysql_select_db($db_name, $conn) or die(mysql_error());
$username = mysql_real_escape_string(stripslahes($username)); // to prevent mysql injections
$result = mysql_query("SELECT * FROM users WHERE username='$username' LIMIT 1 ") or die(mysql_error());
if($row = mysql_fetch_assoc($res))
{
$videos = $row["playlist"];
}
else
{
echo "No username exists in the table";
}