Jump to content

Mohamed_Taher

Members
  • Posts

    12
  • Joined

  • Last visited

Everything posted by Mohamed_Taher

  1. WoW finaly i found it i found it the problem was in the HTML code which pass the value for ($_Post[name]) as the value default option was Defined in the i just cleared the value option from <select> tag it was ( <td width="100"><select name="name"> <?php $sql = mysqli_query($conn ,"SELECT name FROM owners"); while ($row = mysqli_fetch_array($sql)){ ?> <option value="name"><?php echo $row['name']; ?></option> ) i removed the red colored text >>>> your advises guys really helped me out thank you all guys really i learned something today
  2. Dear Barand as the O_ID is auto increment field its will not be usfull for user i did that hard work arround ,if any other solutions , i will be thankful
  3. mysqli_result Object ( [current_field] => 0 [field_count] => 1 [lengths] => [num_rows] => 0 [type] => 0 )
  4. The full in-case it help : <!doctype html> <?php include ("DBConect.php");?> <html> <head> <style> .red { color:rgba(221,26,29,1.00); font-weight:bold; } h1 {color:rgba(237,17,21,1.00); align-items:center; } </style> <meta charset="utf-8"> <title>Insert Data</title> </head> <body> <?php echo "<h1>Add Units to owner:</h1>"; ?> <form method="post" action=""> <table> <tr> <td colspan="3"><strong>Insert Owner Information down:</strong></td> </tr> <tr> <td width="200"><b>Select Owner</b><br></td> <td width="6">:</td> <td width="100"><select name="name"> <?php $sql = mysqli_query($conn ,"SELECT name FROM owners"); while ($row = mysqli_fetch_array($sql)){ ?> <option value="name"><?php echo $row['name']; ?></option> <?php // close while loop } ?></td> </tr> <tr> <td width="200"><strong>Select Property</strong></td> <td width="6">:</td> <td width="100"><select name="pr_num"> <?php $sql5 = mysqli_query($conn ,"SELECT PR_num FROM property"); while ($row = mysqli_fetch_array($sql5)){ ?> <option value="PR_num"><?php echo $row['PR_num']; ?></option> <?php // close while loop } ?></td> </tr> <tr> <td colspan="3"><input name="submit" type="submit" id="submit" value="Submit"></td> </tr> </table> </form> <br> <br> <?php if (isset($_POST['submit'])) { /*$_If_Exist = mysqli_query($conn, "select PR_num from property where PR_num = '$_POST[PR_num]'"); if (mysqli_num_rows($_If_Exist) > 0) { die("<p class='red'>Sorry Unit # allready Exeist</p>"); } */ //Here the SQL Command to insert data in Property table $sql2 = "SELECT O_ID FROM owners WHERE name = '$_POST[name]'"; $result1 = mysqli_query($conn , $sql2); if ($result1==false) { die("failsd".$conn->error); } $row = $result1->fetch_object(); $own = $row->O_ID; $sql3 = "SELECT Pr_ID FROM property WHERE PR_num = $_POST[pr_num]"; $result2 = mysqli_query($conn , $sql3); $row = $result2->fetch_object(); $pro = $row->Pr_ID; $sql4= "INSERT INTO owner_property (Owner_ID, Pr_ID) VALUES ($own, $pro)"; if (!mysqli_query($conn, $sql4)) { die("Faild:". mysqli_error($conn)); } echo "<p class='red'>Unit added to $_POST[name]</p>"; unset($_POST); } mysqli_close($conn); ?> </body> </html>
  5. PHP Notice: Trying to get property of non-object in C:\inetpub\wwwroot\add_user_property.php on line 77 Line 77: $own = $row->O_ID;
  6. same : PHP Fatal error: Call to a member function fetch_object() on boolean in C:\inetpub\wwwroot\add_user_property.php on line 73 line 73 is :$row = $result1->fetch_object();
  7. Back again sorry another error : PHP Fatal error: Call to a member function fetch_object() on boolean in C:\inetpub\wwwroot\add_user_property.php on line 73 $sql2 = "SELECT Owner_ID FROM owners WHERE name = $_POST[name]"; $result1 = mysqli_query($conn , $sql2); $row = $result1->fetch_object(); $own = $row->Owner_ID; $sql3 = "SELECT Pr_ID FROM property WHERE PR_num = $_POST[pr_num]"; $result2 = mysqli_query($conn , $sql3); $row = $result2->fetch_object(); $pro = $row->Pr_ID; $sql4= "INSERT INTO owner_property (Owner_ID, Pr_ID) VALUES ($own, $pro)"; if (!mysqli_query($conn, $sql4)) { die("Faild:". mysqli_error($conn)); } echo "<p class='red'>Unit added to $_POST[name]</p>"; unset($_POST); } mysqli_close($conn); ?>
  8. sorry as i mentioned dear i am totaly new but now because of you i understand the fetch meaning many thanks for both of you
  9. Thanks for you reply any way as you see dear i am using both variables $own, $pro is that logic or make sense!! in one insert into query "$sql= "INSERT INTO owner_property (Owner_ID, Pr_ID) VALUES ($own, $pro)";"
  10. Hello dears My respect for you all. i am totaly new to php i made this code to add data into a table named owner_property I got this error PHP Catchable fatal error: Object of class mysqli_result could not be converted to string in C:\inetpub\wwwroot\add_user_property.php on line 75 Can you guys help me <?php if (isset($_POST['submit'])) { /*$_If_Exist = mysqli_query($conn, "select PR_num from property where PR_num = '$_POST[PR_num]'"); if (mysqli_num_rows($_If_Exist) > 0) { die("<p class='red'>Sorry Unit # allready Exeist</p>"); } */ //Here the SQL Command to insert data in Property table $sql2 = "SELECT Owner_ID FROM owners WHERE name = $_POST[آName]"; $sql3 = "SELECT Pr_ID FROM property WHERE PR_num = $_POST[PR_num]"; $own = mysqli_query($conn , $sql2); $pro = mysqli_query($conn , $sql3); $sql= "INSERT INTO owner_property (Owner_ID, Pr_ID) VALUES ($own, $pro)"; if (!mysqli_query($conn, $sql)) { die("Faild:". mysqli_error($conn)); } echo "<p class='red'>Unit added to $_POST[name]</p>"; unset($_POST); } mysqli_close($conn);
×
×
  • 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.