【发布时间】:2015-01-14 21:58:09
【问题描述】:
我是 php 新手并尝试执行以下操作:
1) 从外部链接解析 PLS 文件 (我已经设法使用堆栈溢出示例来做到这一点:How do I parse a .pls file using PHP? Having trouble with parse_ini_file)
2) 将解析代码得到的 Title 和 File 数据插入到数据库表中,如下所示:
解析代码的输出格式:
[Title1] => testradiostn
[文件1] => http://testradiostn.com/
我如何将这两个放在一个数组中,以便我可以将它插入到下面的表格中
--------------------------------------------------
| id | radio_stn | url |
-----|----------------|--------------------------|
| 1 | testradiostn | http://testradiostn.com/ |
| 2 | testradiostn2 | http://testradiostn2.com/|
| 3 | x | x |
| 4 | x | x |
$title = ???; //title from parsed pls file
$file = ???; //file from parsed plsm file
/*Also how do I insert more than one data at one go*/
$sql = "INSERT INTO Table_1 (radio_stn, url) VALUES (?, ?)";
$params = array($title, $file);
$stmt = sqlsrv_query( $conn, $sql, $params);
抱歉发了这么长的帖子。在此先感谢。
【问题讨论】:
-
看起来您插入了三个值而不是两个
-
大声笑,我现在对你在问什么感到更加困惑......
标签: php arrays parsing insert sqlsrv