这是我的连接代码和查询:
$conn = new mysqli('localhost' , 'root' , '#PASSWORD_HERE#' , 'NSEG');
if($conn->connect_error)
{
die("Unable to connect!");
}
$Query = "INSERT INTO professors(id , Username , FirstName , LastName , Gender , Email) VALUES (NULL , '$username' , '$fname' , '$lname' , '$Gender' , '$Email')";
$conn->query($Query);
$conn->close();
但是当我提交并且我转到php我的管理员时,它并没有显示任何" prfessors"表! 我该怎么办?!
答案 0 :(得分:1)
假设您的ID列为removeplayer()
而不是PK
,因为它应该自动增量,请尝试以下操作:
NULL
答案 1 :(得分:1)
./manage.py migrate
在尝试下面的PHP代码段之前。请确保以下几点。
<?php
$con = mysqli_connect("localhost", "root", "1379Mohammad", "NSEG");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// Perform queries
$query = "INSERT INTO professors(id , Username , FirstName , LastName , Gender , Email) VALUES (NULL , '$username' , '$fname' , '$lname' , '$Gender' , '$Email')";
if (!mysqli_query($con, $query))
{
echo ("Error description: " . mysqli_error($con));
}
mysqli_close($con);
表存在。professors
字段为主键并自动增加。使用主键和自动增量创建表的SQL,根据需要更改其他内容。
id
答案 2 :(得分:1)
function download_image($image_url){
$ch = curl_init($image_url);
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // enable if you want
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 1000); // some large value to allow curl to run for a long time
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0');
curl_setopt($ch, CURLOPT_WRITEFUNCTION, "curl_callback");
curl_setopt($ch, CURLOPT_VERBOSE, true); // Enable this line to see debug prints
curl_exec($ch);
curl_close($ch); // closing curl handle
}
/** callback function for curl */
function curl_callback($ch, $bytes){
global $fp;
$len = fwrite($fp, $bytes);
// if you want, you can use any progress printing here
return $len;
}
$image_file = "ram.png";
$fp = fopen ($image_file, 'w+'); // open file handle
download_image("http://chart.apis.google.com/chart?chl=30%&chs=300x120&cht=gm&chco=77AB10,FFFF00|FF0000&chd=t:30&chf=bg,s,232526");
fclose($fp);