Category : mysqli

I need help with foreach loop and I get an error (Invalid argument supplied for foreach()) : photo of my mistake <?php $connect = mysqli_connect(‘localhost’,’root’,”,’j2school’); mysqli_set_charset($connect,’utf8′); $sql=”insert * from info_model”; $result = mysqli_query($connect,$sql); ?> <?php foreach ($result as $each_post) {?> <div class=”model”> <a href=”#”> <h1><?php echo $each_post[‘name’] ?></h1> <img src=”<?php echo $each_post[‘link_picture’]?>” alt=”Ảnh Model”> </a> ..

Read more

I would like to update a row of my mysql database and tried this with bind parameters like this: if (empty($attachments)) { $sql_attachments = ‘NULL’; } else { $sql_attachments = encrypt(serialize($attachments)); } $sql = $db->prepare( "UPDATE `invoices` SET `status` = ?, `rechnungsnr` = ?, `incomingPayment` = ?, `attachments` = ? WHERE `invoiceID` = ?" ); ..

Read more

I have a "messages" MySQL table: message_time from_id to_id message 2021-11-30 22:50:59 1 3 just a string 2021-11-30 22:51:05 2 3 string 2 2021-11-30 22:51:49 1 3 any string 2021-11-30 22:55:32 1 3 string 4 2021-12-01 23:16:37 2 3 string 5 2021-12-01 23:18:11 2 3 string 6 2021-12-01 23:20:23 1 3 xxxx 2021-12-01 23:22:33 1 ..

Read more

Guys I have this PHP code : <?php foreach ($user as $u){ $sql = " Select Token From notification_data where user_id=’$u’;"; $result = mysqli_query($con,$sql); $tokens = array(); if(mysqli_num_rows($result) > 0 ){ while ($row = mysqli_fetch_assoc($result)) { array_push($tokens, $row["Token"]); } } mysqli_close($con); $notification = array( ‘title’ => "New ticket!!", ‘body’ => "A new tournament is ready, ..

Read more

I am trying to use the folowing query to update the database. I cant figur out where to put the place holders to make this work. Can someone tell me where I go wrong? while ($dataauto = $resultauto->fetch_assoc()) { $CheckAccountID = $dataauto[‘id’]; $IDcheck[] = $CheckAccountID; } $AccountNotes = "TestNotes"; $AccountType = "TestType"; $AccountBefore = "TestBefore"; ..

Read more

i have three table (specialties, exams, courses) so (exams and courses) have relation many-to-one with (specialties)…Currently, I am developing a page for related exams in the specialties, but my programming experience in php is weak and so how i can Show the related exam in mathematics or another subject, for example from another specialty, such ..

Read more

Currently I am facing a problem which the table cannot be created together with database at the same time. Below is the code I am using. <?php DEFINE (‘DB_USER’, ‘root’); DEFINE (‘DB_PASSWORD’, ”); DEFINE (‘DB_HOST’, ‘localhost’); DEFINE (‘DB_NAME’, ‘enquiry’); $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD); // Make my_db the current database $db_selected = mysqli_select_db($dbc, ‘enquiry’); if ..

Read more