Sten Helge Posted April 12, 2016 Posted April 12, 2016 Hei, Har kontakt med databasen, men får ikke ut informasjon fra tabellene. Databasen og tabellene fungerte fint på localhost under utvikling. Er det noen som har et tips? Share this post Link to post Share on other sites More sharing options...
PRO ISP Morten Posted April 12, 2016 Posted April 12, 2016 Hei Sten Helge, Du importerte databasen via phpmyadmin? Er det informasjon i tabellene når du sjekker inne i phpmyadmin? Share this post Link to post Share on other sites More sharing options...
Sten Helge Posted April 12, 2016 Posted April 12, 2016 Hei Morten, Ja det gjorde jeg. Det er litt innformasjon i alle tabellene som i bildet under. Det jeg ser er at de php filene som skal lese, skrive, oppdattere og slette (CRUD) ikke virker. Jeg får ut og inn så frontend fungerer opp mor bruker-tabellen. Men ikke admin siden. Share this post Link to post Share on other sites More sharing options...
PRO ISP Morten Posted April 12, 2016 Posted April 12, 2016 Men mangler det informasjon i tabellene inne i phpmyadmin? Hva slags feilmelding får du? Er det noen egenutviklet eller standard skript du kjører? Share this post Link to post Share on other sites More sharing options...
Sten Helge Posted April 12, 2016 Posted April 12, 2016 Nei, det manglet ikke noe fra utviklingssiden. Det er ingen feilmelding, det er det som er så rart. Dette er et egenutviklet gjennom et selvlæringskurs på nettet jeg holder på med. Alt fungerer som det skal lokalt. Jeg bruker XAMPP 5.6.12-0 som database når jeg utvikler lokalt. Legger ved et eksempel på koden i ene filen som skal liste opp alle postene i admin. <?php if(isset($_POST['checkBoxArray'])) { foreach($_POST['checkBoxArray'] as $postValueId ) { $bulk_options = escape($_POST['bulk_options']); switch($bulk_options) { case 'published': $query = "UPDATE posts SET post_status = '{$bulk_options}' WHERE post_id = {$postValueId} "; $update_to_published_status = mysqli_query($connection, $query); confirmQuery($update_to_published_status); break; case 'draft': $query = "UPDATE posts SET post_status = '{$bulk_options}' WHERE post_id = {$postValueId} "; $update_to_draft_status = mysqli_query($connection, $query); confirmQuery($update_to_draft_status); break; case 'delete': $query = "DELETE FROM posts WHERE post_id = {$postValueId} "; $update_to_delete_status = mysqli_query($connection, $query); confirmQuery($update_to_delete_status); break; } } } ?> <form action="" method='post'> <table class="table table-bordered table-hover"> <div id="bulkOptionContainer" class="col-xs-4" > <select class="form-control" name="bulk_options" id=""> <option value="">Select Options</option> <option value="published">Publish</option> <option value="draft">Draft</option> <option value="delete">Delete</option> </select> </div> <div class="col-xs-4"> <input type="submit" name="submit" class="btn btn-success" value="Utfør"> <a class="btn btn-primary" href="posts.php?source=add_post">Legg til Ny</a> </div> <thead> <tr> <th>Cb</th> <th>Id</th> <th>Aouthor</th> <th>Title</th> <th>Category</th> <th>Status</th> <th>Image</th> <th>Tags</th> <th>Comments</th> <th>Date</th> <th>Edit</th> <th>Delete</th> </tr> </thead> <tbody> <?php $query = "SELECT * FROM posts"; $select_posts = mysqli_query($connection,$query); while($row = mysqli_fetch_assoc($select_posts)) { $post_id = escape($row['post_id']); $post_author = escape($row['post_author']); $post_title = escape($row['post_title']); $post_category_id = escape($row['post_category_id']); $post_status = escape($row['post_status']); $post_image = escape($row['post_image']); $post_tags = escape($row['post_tags']); $post_comment_count = escape($row['post_comment_count']); $post_date = escape($row['post_date']); echo "<tr>"; ?> <td><input class='checkBoxes' type='checkbox' name='checkBoxArray[]' value='<?php echo $post_id; ?>'></td> <?php echo "<td>{$post_id}</td>"; echo "<td>{$post_author}</td>"; echo "<td><a href='../post.php?source&p_id={$post_id}'>$post_title</a></td>"; $query = "SELECT * FROM categories WHERE cat_id = {$post_category_id}"; $select_categories_id = mysqli_query($connection,$query); while($row = mysqli_fetch_assoc($select_categories_id)) { $cat_id = escape($row['cat_id']); $cat_title = escape($row['cat_title']); } echo "<td>{$cat_title}</td>"; echo "<td>{$post_status}</td>"; echo "<td><img width='100' src='../images/{$post_image}''</td>"; echo "<td>{$post_tags}</td>"; echo "<td>{$post_comment_count}</td>"; echo "<td>{$post_date}</td>"; echo "<td><a href='posts.php?source=edit_post&p_id={$post_id}'>Edit</a></td>"; echo "<td><a href='posts.php?delete={$post_id}'>Delete</a></td>"; echo "</tr>"; } ?> </tbody> </table> </form> <?php if(isset($_GET['delete'])){ $the_post_id = escape($_GET['delete']); $query = "DELETE FROM posts WHERE post_id = {$the_post_id}"; $delete_query = mysqli_query($connection, $query); header("Location: posts.php"); } Share this post Link to post Share on other sites More sharing options...
Sten Helge Posted April 12, 2016 Posted April 12, 2016 Morten. Dette er jo så flaut at det er fælt. Det er to database filer i prosjektet. og jeg har selvsagt glemt å legge inn database informasjonen for admin siden. Ikke noe rart at jeg ikke fikk tilgang. Men tusen takk likevel. Spørsmålene dine fikk meg til å tenke rasjonelt og logisk på problemet. Jeg hadde "låst" meg på tabellene og importen av filene. Takk takk Share this post Link to post Share on other sites More sharing options...
prasant Posted June 30, 2017 Posted June 30, 2017 i am doing same project, please help me .. where is the error? <?php if(isset($_POST['checkBoxArray'])) { foreach($_POST['checkBoxArray'] as $postValueId ) { $bulk_options = $_POST['bulk_options']; switch($bulk_options) { case 'published' : $query = "UPDATE posts SET post_status = '{$bulk_options}' WHERE post_id= {$postValueId} " ; $update_to_published_status = mysqli_query($connection,$query); confirmQuery($update_to_published_status); break; } } } ?> <form action="" method='post'> <table class="table table-bordered table-hover"> <div id="bulkOptionContainer" class="col-xs-4"> <select class="form-control" name="bulk_options" id=""> <option value="">Select Options</option> <option value="published">Publish</option> <option value="draft">Draft</option> <option value="delete">Delete</option> </select> </div> <div class="col-xs-4"> <input type="submit" name="submit" class="btn btn-success" value="Apply"> <a class="btn btn-primary" href="add_post.php"?>Add New</a> </div> <thead> <tr> <th><input id="selectAllBoxes" type="checkbox"></th> <th>ID</th> <th>tilte</th> <th>Category</th> <th>image</th> <th>content</th> <th>date</th> <th>tags</th> <th>comment count</th> <th>status</th> <th>Edit</th> <th>Delete</th> </tr> </thead> <tbody> <?php $query = "SELECT * FROM posts"; $select_post= mysqli_query($connection,$query); while($row = mysqli_fetch_assoc($select_post)) { $post_id = $row['post_id']; $post_title = $row['post_title']; $post_category_id = $row['post_category_id']; $post_image = $row['post_image']; $post_content = $row['post_content']; $post_date = $row['post_date']; $post_tags = $row['post_tags']; $post_comment_count = $row['post_comment_count']; $post_status = $row['post_status']; echo "<tr>"; ?> <td><input class='checkBoxes' type='checkbox' name='checkBoxArray[]' vlaue='<?php echo $post_id; ?>'></td> <?php echo "<td>$post_id</td>"; echo "<td>$post_title</td>"; $query = "SELECT * FROM categories WHERE cat_id = {$post_category_id} "; $select_categories_id = mysqli_query($connection,$query); while($row = mysqli_fetch_assoc($select_categories_id)) { $cat_id = $row['cat_id']; $cat_title = $row['cat_title']; echo "<td>{$cat_title}</td>"; } echo "<td><img width='100' src='../images/$post_image' alt='image'</td>"; echo "<td>$post_content</td>"; echo "<td>$post_date</td>"; echo "<td>$post_tags</td>"; echo "<td>$post_comment_count</td>"; echo "<td>$post_status</td>"; echo "<td><a href='posts.php?source=edit_post&p_id={$post_id}'>Edit</a></td>"; echo "<td><a href='posts.php?delete={$post_id}'>Delete</a></td>"; echo "</tr>"; } ?> </tbody> </table> </form> <?php if(isset($_GET['delete'])){ $the_post_id = $_GET['delete']; $query = "DELETE FROM posts WHERE post_id = {$the_post_id} "; $delete_query = mysqli_query($connection, $query); header("Location: posts.php"); } ?> please Helppppppppppp Share this post Link to post Share on other sites More sharing options...
prasant Posted June 30, 2017 Posted June 30, 2017 errro showing is : QUERY FAILED .You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'on' at line 1 Share this post Link to post Share on other sites More sharing options...