未定义的索引PHP,MySQL,PhpMyAdmin

时间:2017-03-25 04:15:24

标签: php mysql indexing phpmyadmin undefined

错误:

  

(!)注意:未定义的索引:第10行的C:\ wamp \ www \ php \ myJoyofPHP \ viewcar.php中的VIN

$value = isset($array['VIN']) ? $array['VIN'] : '';
$value = array_key_exists('VIN', $array) ? $array['VIN'] : '';

我现在并不关心安全问题,因为我刚刚学习了基础知识。我知道,请不要回复说它是易受攻击的代码。

我有一个名为' VIN'在'汽车' PhpMyAdmin中的数据库中包含多个值但由于某种原因出现此错误。此外,在错误下方,会出现一个数据集。

为什么我会收到此错误? 为什么我会收到错误,特别是如果存在具有相同列名的数据库' VIN'? 当我在其上面输入以下代码时,也会出现变量错误。

<?php 
//localhost, root, password, database
$mysqli = new mysqli('localhost','root','','cars');
/*check connection */
if (mysqli_connect_errno()){
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
//select a database to work with
$mysqli->select_db("cars");

?>

此外,这是包含的db.php文件:

{{1}}

正如我所提到的,我知道这是一个易受攻击的数据库。没有密码。请不要发布有关这方面的任何内容,因为我需要完全理解基础知识。谢谢。

4 个答案:

答案 0 :(得分:1)

首先,不是&#34;错误&#34;,它是&#34;通知&#34;。几乎所有时间都可以忽略它。 它的意思是&#39; VIN&#39; index未在$ _GET全局变量/数组中定义。 那是&#39; VIN&#39;不要进入url参数。 PHP认为它像一个空字符串。

也许最好的解决方案是:

Recyclerview.Adapter

显然你需要在de VIN参数中使用你的脚本: ..... viewcar.php?VIN = ABC123

答案 1 :(得分:0)

你可以使用下面的代码和通知消息将消失,它只是一个通知说$ vin没有定义,因为有时$ vin是空的,它没有从$ _GET获得任何值

if (isset($_GET['VIN']))
{
   $vin = $_GET['VIN'];
}

答案 2 :(得分:0)

此行导致您收到该警告$vin = $_GET['VIN'];,这意味着您未在请求中收到VIN,您需要将其检查为

if (isset($_GET['VIN'])) {
 //rest of the code
}

答案 3 :(得分:0)

简短而简单:

VIN

如果没有输入$vin

  • 没有错误消息;
  • NULL将为if (isset($vin)) ...
  • 稍后,您可以使用from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC chrome_options = webdriver.ChromeOptions() prefs = {"profile.default_content_setting_values.notifications" : 2} chrome_options.add_experimental_option("prefs",prefs) driver = webdriver.Chrome(chrome_options=chrome_options) driver.get("http://www.facebook.com/") driver.find_element_by_name("email").send_keys("***EMAIL***") driver.find_element_by_id("pass").send_keys("***PW***") wait = WebDriverWait(driver, 15) driver.find_element_by_xpath("//*[@id='loginbutton']").click() wait = WebDriverWait(driver, 10) ele = driver.find_element_by_name("q") ele.send_keys("**FRIEND NAME**") wait = WebDriverWait(driver, 10) element = wait.until(EC.element_to_be_clickable((By.XPATH,"//*[@id='js_e']/form/button/i"))) element.click() wait = WebDriverWait(driver, 5) element = wait.until(EC.element_to_be_clickable((By.XPATH,"//*[@id='js_9t']/img"))) element.click() driver.find_element_by_xpath("//*[@id='js_3q9']/div[1]/div[1]/div[2]/div/div/div/div/div[2]/div/div/div/div").send_keys("Its Automated") ,它可以轻松阅读。