php - mysqli_error() expects parameter 1 to be mysqli, null given -


i have a form pulls data database(mysql specific) , echos data value section of <input> tags. doesn't seem working have coded view section of website same thing different table in database. use same code make making changes easy , if developer works on site in future. anyway doesn't seem working i'm not sure why though.

the full error get:

warning: mysqli_query() expects parameter 1 mysqli, null given in /home/caseol5/public_html/jj/admin/news_update.php on line 9  

here line 9 error referring to:

$result = mysqli_query($link,$sql); 

i know both of function not null did:

echo $link echo $sql  

before line after started feting error , both not null.

here full code segment:

$nid = $_get['nid'];  include ("../sql/dbconnect.php");  $sql = "select * jj_news news_id = $nid"; echo "<p>the sql command: $sql </p>";    echo "<p>link: $link </p>"; $result = mysqli_query($link,$sql);   if (!$result) {     echo "<h1>you have encountered problem update.</h1>";     die( "<h2>" . mysqli_error($link) . "</h2>") ;   } $row = mysqli_fetch_array($result);      $ntitle = $row['news_title']; $ntline = $row['news_titleline']; $ndesc = $row['news_desc']; $nother = $row['news_other']; 

i have looked mysqli_query , can't find i'm missing. have tired breaking code down (and running parts of , gives same error. guess small missed. i've looked @ other question on site little similar none seem help. i've been looking @ while , need pair of eyes.

update

as requested contents of dbconnect.php file:

$hostname = "localhost";     $username = "caseol5_jjoes";                 $database = "caseol5_jj_site";               $password = "password1";                 $link = mysqli_connect($hostname, $username, $password, $database);  $link = mysqli_connect($hostname,$username,$password,$database) or   die("error " . mysqli_error($link));  if (!$link)                                      {      echo "we have problem!";  } 

as stated in error message, mysqli_querydocs expects first parameter mysqli resource. in case, parameter called $link holds null value. proper mysqli resource normally obtained connecting database making use of mysqli_connectdocs

i expect ../sql/dbconnect.php file holds logic connect database. verify whether $link variable indeed initialized there. if it's not there, try find occurrence of mysqli_connect - maybe resource set different variable.

without knowing in ../sql/dbconnect.php, problem right not have valid mysqli resource use mysqli_query.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -