这里我试图使用从其他表中提取的信息将数据输入到表播放列表中。 在执行它之后,我收到了“成功”消息,但实际上没有插入数据。 任何人都可以指出错误吗?
<?php
$connect= mysql_connect("localhost","root","") or die('couldnt connect to database');
mysql_select_db("music") or die("couldn't find the database");
$regis['id']=$_GET['id'];
$regis['username']=$_GET['username'];
$query="SELECT * FROM songs WHERE id ='id'";
$quer="SELECT * FROM images WHERE id ='id'";
$q="SELECT * FROM users WHERE username ='username'";
$query=mysql_query($query);
$quer=mysql_query($quer);
$q=mysql_query($q);
$row=mysql_fetch_assoc($query);
$regis['id']=$row['id'];
$regis['title']=$row['title'];
$regis['artist']=$row['artist'];
$rows=mysql_fetch_assoc($q);
$regis['link']=$rows['link'];
$r=mysql_fetch_assoc($q);
$regis['uid']=$r['uid'];
$sql="insert into playlist (songid,song,image,album,uid) values('{$regis['id']}','{$regis['title']}','{$regis['link']}','{$regis['artist']}','{$regis['uid']}')";
$res=mysql_query($sql);
if($res)
{
echo "<script type='text/javascript'>";
echo 'alert("addition to your playlist was succesful")';
echo "</script>";
}
else
{
echo "<script type='text/javascript'>";
echo 'alert("'.mysql_error().'Please try again")';
echo "</script>";
}
&GT;
答案 0 :(得分:0)
if(mysql_num_rows($res)>0){
//query inserted at least one row in db
}