作者:mobiledu2402852413 | 来源:互联网 | 2023-05-17 11:39
Sorryforthestupidquestion.DonotmakevaluesinthetablefromphpcodeOnlyfromphpmyadmin.W
Sorry for the stupid question. Do not make values in the table from php code Only from phpmyadmin. While able to read records from a table. What could be the problem? User is same, has all privileges.
抱歉这个愚蠢的问题。不要从php代码中创建表中的值仅来自phpmyadmin。虽然能够从表中读取记录。可能是什么问题呢?用户相同,拥有所有权限。
My code. Table contain id, site name, ip of the site.
我的代码。表包含站点的ID,站点名称和IP。
$host='localhost';
$database='Spider';
$user='myuser';
$pswd='mypassword';
$dbh = mysql_connect($host, $user, $pswd) or die("Не могу соединиться с MySQL.");
mysql_select_db($database) or die("Не могу подключиться к базе.");
$query = "SELECT id, site, ip FROM `sites` LIMIT 0,100";
$res = mysql_query($query);
$reverse_ip = array();
for ($i=1; $row=mysql_fetch_array($res); $i++) {
echo $row['site']."
"; //print site name
$reverse_ip[$i] = substr($row['site'], 7, strlen($row['site'])-7);
if (strpos($reverse_ip[$i], 'www.') !== false) {
$reverse_ip[$i] = substr($reverse_ip[$i], 4, strlen($reverse_ip[$i])-4);
}
if (strpos($reverse_ip[$i], '/')) {
$reverse_ip[$i] = substr($reverse_ip[$i], 0, -1); //editing site name
}
echo $reverse_ip[$i]."
"; //print the edited name
$reverse_ip[$i]=gethostbyname($reverse_ip[$i]);
echo $reverse_ip[$i]."
"; //print the ip of site
}
$sql = "UPDATE sites SET ip = 200 WHERE id = 4 "; //table remains unchanged
When I When I use this queries $sql = "UPDATE sites SET ip = 200 WHERE id = 4 ";
in phpmyadmin it works
当我使用此查询时$ sql =“UPDATE sites SET ip = 200 WHERE id = 4”;在phpmyadmin它的工作原理
1 个解决方案