我目前正在使用弃用的代码来从用户那里获取数据,如下所示:
/* retrieve */
$lastName = $_POST['lastName'];
$firstName = $_POST['firstName'];
$examLevel=$_POST['level'];
/* connect */
$dbc=mysql_connect("localhost", "user", "passw") or die('Error connecting to MySQL server');
mysql_select_db("db") or die('Error selecting database.');
/* sanitize */
$lastName=mysql_real_escape_string($lastName);
$firstName=mysql_real_escape_string($firstName);
$examLevel=mysql_real_escape_string($examLevel);
/* insert */
$query_personal = "INSERT INTO personal (LastName, FirstName) VALUES ('$lastName', '$firstName')";
$query_exam = "INSERT INTO exam (Level, Centre, BackupCentre, etc.) VALUES ('$examLevel', '$centre', '$backup', 'etc')";
Run Code Online (Sandbox Code Playgroud)
这是有效的,但我不断发出有关安全性和缺乏支持的警告.有一个小的重写连接 mysqli而不是mysql但是mysqli_real_escape_string怎么样?我已经看到它在示例中使用但我也看到了使用预处理语句的建议,而不使用mysqli_real_escape_string.
我如何使用预准备语句来插入我的数据?到目前为止,我有点在海上.例如,仅针对INSERT的参数绑定和仅针对SELECT的结果绑定吗?
我有一些要加粗的文字,与前几段和后几段分开并缩进。我不能让所有三个属性一起工作。
这适用于粗体和空格:
$section = $phpWord->addSection();
$section->addText(
'Re: Your Application for Post of Security Guard',
array('bold' => true),
array('space' => array('before' => 360, 'after' => 280))
);
Run Code Online (Sandbox Code Playgroud)
这适用于缩进:
$section = $phpWord->addSection();
$section->addText(
'Re: Your Application for Post of Security Guard',
array('indentation' => array('left' => 540, 'right' => 120))
);
Run Code Online (Sandbox Code Playgroud)
但这不起作用:
$section = $phpWord->addSection();
$section->addText(
'Re: Your Application for Post of Security Guard',
array('bold' => true),
array('space' => array('before' => 360, 'after' => 280)),
array('indentation' => array('left' => 540, 'right' => 120)) …Run Code Online (Sandbox Code Playgroud)