我有一个数据库表,当我用用户名和密码选择数据时,它可以正常工作,但当我在该表中插入一些具有相同用户名和密码的数据时,它会显示错误
INSERT command denied to user 'username'@'localhost' for table 'tablename'
Run Code Online (Sandbox Code Playgroud)
我使用Google进行搜索,其他人也遇到了与db size相同的问题.我检查了我的数据库,当我直接去phpmyadmin将数据插入表中时,它可以工作,但是当我从PHP脚本调用表的查询时,它给了我错误.
我将图像上传到服务器并将路径保存在数据库中.现在我想要删除该记录以及我的代码带有该记录的图像
$id=$_GET['id'];
$select=mysql_query("select image from table_name where question_id='$id'");
$image=mysql_fetch_array($select);
@unlink($image['image']);
$result=mysql_query("delete from table_name where question_id='$id'");
当我回声$ image ['image']; 这会给我
http://www.example.com/folder/images/image_name.jpeg记录已成功删除,但图像仍保留在服务器上.
当我将一个字符串值添加到数组中时array_push(),它会给我一个数值,即
$array = array("one", "two", "three");
$array2 = array("test", "test2");
foreach ($array as $value) {
if ($value === 'one') {
$push = array_push($array2, $value);
}
}
print_r($push);
Run Code Online (Sandbox Code Playgroud)
输出是3.我想要的是什么$array2 = array("test", "test2", "one")
我想使用地理编码从给定的纬度和经度中检索地理位置,使用网站上的给定示例
http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true
我只是在这个例子中需要城市名称纽约,国家名称是美国.但问题是这些单词不止一次出现为long_name.
我的问题如何在php中解析这个json/xml以获取城市名称和国家/地区.
$url= file_get_contents('http://maps.googleapis.com/maps/api/geocode/xml?latlng=40.714??224,-73.961452&sensor=true');
$xml = simplexml_load_string($url);
$tracks = $xml->result;
$temp; $city; $country;
foreach($tracks as $key)
{
foreach($key->address_component as $val)
{
$temp= $val->long_name;
if($val->type=="locality")
{
$city=$temp;
}else if($val->type=="country")
{
$country=$temp;
}
}
}
echo $country."<br />"; echo $city;
<?xml version="1.0" encoding="UTF-8"?>
<GeocodeResponse>
<status>OK</status>
<result>
<type>street_address</type>
<formatted_address>277 Bedford Avenue, Brooklyn, New York 11211, USA</formatted_address>
<address_component>
<long_name>277</long_name>
<short_name>277</short_name>
<type>street_number</type>
</address_component>
<address_component>
<long_name>Bedford Avenue</long_name>
<short_name>Bedford Ave</short_name>
<type>route</type>
</address_component>
<address_component>
<long_name>Williamsburg</long_name>
<short_name>Williamsburg</short_name>
<type>neighborhood</type>
<type>political</type>
</address_component>
<address_component>
<long_name>Brooklyn</long_name>
<short_name>Brooklyn</short_name>
<type>sublocality</type>
<type>political</type>
</address_component>
<address_component> …Run Code Online (Sandbox Code Playgroud) 我有mysql表即
id | a | b | c | d |ud_id 1 | 20| 8 | 45| 18| 1
现在我想在php中检索该数据对数组进行排序并找到此示例中的最高字段(c = 45)
$query="SELECT `a`, `b`, `c`, `d` from table where ud_id=1"; $rs=mysql_query($query) or die(mysql_error()); $row=mysql_fetch_array($rs);
但是我如何对这个关联数组进行排序并找到最高的关键字.
我有一个mysql表即
st_id | name | email | maths | chemistry | bio | social_study 1 | john |@a.com | 20 | 23 | 10 | 15