Jump to content

triad1234

New Members
  • Posts

    1
  • Joined

  • Last visited

triad1234's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Let me put this straight. I have a table : name_table name varchar(10), meaning1 varchar(10), meaning2 varchar(10) ... meaning20 varchar(10). #Note : The Fields Name & Meaning2 are already Filled. Test.php (URL Passed : localhost/../test.php?name=some_name) <?php error_reporting(E_ALL); $servername = "localhost"; $username = "root"; $password = ""; $dbname = "test_db"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } //Get name $name = $_GET['name']; $name_meanings = array(sometext1, sometext2, ... sometext19, sometext20); for($k=1; $k<=20; $k++){ //check if the table cell is empty to be filled $element_col = "meaning" . $k; echo "</br>" . $element_col . "</br>"; $check = $conn->query("select $element_col from name_table WHERE name=$name"); if(!$check){ echo "</br> CHECK: False</br>"; $occurance = mysqli_num_rows($check); //Warning message pointing to this line if($occurance == 0 ){ echo "</br>Occurance is 0</br>"; for($l=0; $l<sizeof($name_meanings); $l++){ $name_element = $name_meanings[$l]; $raw_pwd=$conn->query("insert into name_table($element_col) values($name_element) where name=$name"); } } else{ echo "</br>Meaning exists at $element_col</br>"; } } else{ echo "</br>Check is True</br>"; break; } } ?> Output: Meaning1 Check: False Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\\test.php on line 26 Occurrence is 0 Meaning2 <--This iteration went wrong Check: False Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\\test.php on line 26 Occurrence is 0 . . . Meaning20 Check: False Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\\test.php on line 26 Occurrence is 0 Question: 1. How do I put the warning, mysqli_num_rows() right? 2. Why is the PHP unable to detect the already inserted fields (meaning2)? Any Suggestion.....Please.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.