请帮助我解决这个问题。
注意:未定义的变量:第10行的C:\ xampp \ htdocs \ ecommerce \ function \ fuction.php中的con
警告:mysqli_query()期望参数1为mysqli,在第10行的C:\ xampp \ htdocs \ ecommerce \ function \ fuction.php中给出null
警告:mysqli_fetch_array()要求参数1为mysqli_result,在第11行的C:\ xampp \ htdocs \ ecommerce \ function \ fuction.php中给出null
<?php
$host="localhost";
$user_id="root";
$password="";
$con = mysqli_connect($host,$user_id,$password) OR die("not connected.... ");
$db = mysqli_select_db($con,'ecommerce') OR die ("not connected...");
?>
<?php
function getbrands()
{
$fetch_brand="SELECT * FROM brands";
$run=mysqli_query($con,$fetch_brand);
while($row=mysqli_fetch_array($run));
$brands_id=$row[0];
$brands_title=$row[1];
echo "<h4 align='center' style='margin:0px'>
<a href='ecommerce.php?brands=$brands_id'>$brands_title</a></h4><hr>";
}
?>
答案 0 :(得分:0)
试试这个:
function supportsSVG() {
return !!document.createElementNS && !!document.createElementNS('http://www.w3.org/2000/svg', "svg").createSVGRect;
}
var token = $('#_token').val();
$.ajax({
url: 'getShares',
type: 'post',
// dataType:'json',
data: {
_token: token,
},
success: function (data, textStatus, jQxhr) {
var DBData = jQuery.parseJSON(data);
UserGroupsBar = new AmCharts.AmSerialChart();
// var Data = [{}];
UserGroupsBar.dataProvider = DBData;
UserGroupsBar.startDuration = 1;
UserGroupsBar.categoryField = "gid";
$.each(DBData, function (i, item) {
// alert(item['Users']);
if (item['Users'] > 0) {
// Data[0][item['gid'] = item['Users']];
var UserGroupGraph = new AmCharts.AmGraph();
UserGroupGraph.id = item['gid'];
UserGroupGraph.valueField = item['Users'];
UserGroupGraph.title = item['gid'];
UserGroupGraph.type = "column";
UserGroupGraph.lineAlpha = 0;
UserGroupGraph.fillAlphas = 1;
UserGroupGraph.balloonText = "[[title]]: [[value]]";
UserGroupsBar.addGraph(UserGroupGraph);
}
});
UserGroupsBar.write("BarChart");
var GroupValueAxis = new AmCharts.ValueAxis();
GroupValueAxis.axisColor = "#DADADA";
GroupValueAxis.gridAlpha = 0.1;
GroupValueAxis.integersOnly = true;
UserGroupsBar.addValueAxis(GroupValueAxis);
UserGroupsBar.outlineColor = "#FFFFFF";
UserGroupsBar.outlineAlpha = 0.2;
UserGroupsBar.outlineThickness = 2;
UserGroupsBar.startDuration = supportsSVG() ? 1 : 0;
UserGroupsBar.depth3D = supportsSVG() ? 20 : 0;
UserGroupsBar.angle = supportsSVG() ? 30 : 0;
//Root Causes Legend
GroupLegend = new AmCharts.AmLegend();
UserGroupsBar.addLegend(GroupLegend, "Legend");
GroupLegend.valueText = "";
GroupLegend.align = "center";
GroupLegend.position = "absolute";
GroupLegend.marginTop = 30;
GroupLegend.markerType = "circle";
GroupLegend.labelWidth = 180;
GroupLegend.fontSize = 10;
GroupLegend.verticalGap = 20;
// WRITE
UserGroupsBar.write("BarChart");
}
});
答案 1 :(得分:0)
这是使用mysqli连接到mysql的方法:
<?php
$servername = "localhost";
$username = "root";
$password = "";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>