fantomel Posted June 27, 2008 Share Posted June 27, 2008 hello can someone debug a code please and tell me the mistakes i made.. because for 2 hours.. tried all i had in mind and still couldn't make it work.. to tired.. it views some datas from db by id. <?php require('www/dbconnect.php'); dbconnect(); $id = $_GET['id']; $sql = ("SELECT * FROM `books` WHERE `books_id` = '$id'"); $result = mysql_query($sql) or die ('Error : ' . mysql_error()); $row=mysql_fetch_assoc($result); { $book = $row['book Author']; $book_year = $row['booky']; $title = $row['title']; } ?> <table border="1" cellpadding="0" cellspacing="0" class="tabel_editare"> <tr> <td class="textare_butonase">Book Title</td> <td class="textare_butonase">Book Year</td> <td class="textare_butonase">Book Author</td> </tr> <tr> <td><?php echo $title; ?></td> <td><?php echo $book_year; ?></td> <td><?php echo $book; ?></td> </tr> </table> <?php include('www/dbclose.php'); ?> thank you for help Quote Link to comment Share on other sites More sharing options...
xyn Posted June 27, 2008 Share Posted June 27, 2008 this is your problem... $row=mysql_fetch_assoc($result); { $book = $row['book Author']; $book_year = $row['booky']; $title = $row['title']; } should be: while($row=mysql_fetch_assoc($result)) { $book = $row['book Author']; $book_year = $row['booky']; $title = $row['title']; } Quote Link to comment Share on other sites More sharing options...
fantomel Posted June 27, 2008 Author Share Posted June 27, 2008 this is your problem... $row=mysql_fetch_assoc($result); { $book = $row['book Author']; $book_year = $row['booky']; $title = $row['title']; } should be: while($row=mysql_fetch_assoc($result)) { $book = $row['book Author']; $book_year = $row['booky']; $title = $row['title']; } still doesn't work Quote Link to comment Share on other sites More sharing options...
waynewex Posted June 27, 2008 Share Posted June 27, 2008 $sql = ("SELECT * FROM `books` WHERE `books_id` = '$id'"); 1: Is your books_id a number? If so try: $sql = ("SELECT * FROM `books` WHERE `books_id` = $id"); Notice how I took out the inverted commas around $id. Might be the problem... or not... :-\ Also, recheck your column names to make sure that they're the same. Quote Link to comment Share on other sites More sharing options...
xyn Posted June 27, 2008 Share Posted June 27, 2008 Your code needs a big change; your loop is not going to work, use this: <?php require('www/dbconnect.php'); dbconnect(); $id = $_GET['id']; $sql = mysql_query("select * from `books` where `books_id` ='$id'"); # or die ('Error : ' . mysql_error()); ?> <table border="1" cellpadding="0" cellspacing="0" class="tabel_editare"> <tr> <td class="textare_butonase">Book Title</td> <td class="textare_butonase">Book Year</td> <td class="textare_butonase">Book Author</td> </tr> <?php while($row=mysql_fetch_assoc($sql)) { ?> <tr> <td><?php echo $row['book Author']; ?></td> <td><?php echo $row['booky']; ?></td> <td><?php echo $row['title']; ?></td> </tr> <?php } ?> </table> <?php include('www/dbclose.php'); ?> Quote Link to comment Share on other sites More sharing options...
fantomel Posted June 27, 2008 Author Share Posted June 27, 2008 i've tested your code and gives the same a blank page might be because i use this model of link index.php?page=locatie_view.php?id= ? Quote Link to comment Share on other sites More sharing options...
xyn Posted June 27, 2008 Share Posted June 27, 2008 ok, post the content of www/dbconnect.php here. Quote Link to comment Share on other sites More sharing options...
fantomel Posted June 27, 2008 Author Share Posted June 27, 2008 ok, post the content of www/dbconnect.php here. <?php function db_connect() { $link = mysql_connect('localhost', 'bobo', 'flory'); $db = mysql_select_db('digitalweb'); if (!$db) { echo ("am reusit"); die('Nu am putut selecta data de baze: ' . mysql_error()); } if (!$link) { die('Eroare esti un idiot: ' . mysql_error()); } } function makeClickableLinks($text) { $text = html_entity_decode($text); $text = " ".$text; $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)', '<a href="\1" target=_blank>\1</a>', $text); $text = eregi_replace('(((f|ht){1}tps://)[-a-zA-Z0-9@:%_+.~#?&//=]+)', '<a href="\1" target=_blank>\1</a>', $text); $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)', '\1<a href="http://\2" target=_blank>\2</a>', $text); $text = eregi_replace('([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})', '<a href="mailto:\1" target=_blank>\1</a>', $text); return $text; } ?> Quote Link to comment Share on other sites More sharing options...
xyn Posted June 27, 2008 Share Posted June 27, 2008 replace that with this; your code fine, but i dont understand the function business <? $host ="localhost"; $user ="ddsqladmin"; $pass ="bobo"; $data ="flory"; $connect =mysql_connect($host, $user, $pass); $database =mysql_select_db($data, $connect); if(!$connect||!$database)die("Database cannot connect..."); function makeClickableLinks($text) { $text = html_entity_decode($text); $text = " ".$text; $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)', '<a href="\1" target=_blank>\1[/url]', $text); $text = eregi_replace('(((f|ht){1}tps://)[-a-zA-Z0-9@:%_+.~#?&//=]+)', '<a href="\1" target=_blank>\1[/url]', $text); $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)', '\1\2', $text); $text = eregi_replace('([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})', '\1', $text); return $text; } ?> Quote Link to comment Share on other sites More sharing options...
fantomel Posted June 27, 2008 Author Share Posted June 27, 2008 replace that with this; your code fine, but i dont understand the function business <? $host ="localhost"; $user ="ddsqladmin"; $pass ="bobo"; $data ="flory"; $connect =mysql_connect($host, $user, $pass); $database =mysql_select_db($data, $connect); if(!$connect||!$database)die("Database cannot connect..."); function makeClickableLinks($text) { $text = html_entity_decode($text); $text = " ".$text; $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)', '<a href="\1" target=_blank>\1[/url]', $text); $text = eregi_replace('(((f|ht){1}tps://)[-a-zA-Z0-9@:%_+.~#?&//=]+)', '<a href="\1" target=_blank>\1[/url]', $text); $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)', '\1\2', $text); $text = eregi_replace('([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})', '\1', $text); return $text; } ?> i've changed there with my user and pass and db now not even the site is loading and doesn't show any error :| Quote Link to comment Share on other sites More sharing options...
fantomel Posted June 27, 2008 Author Share Posted June 27, 2008 replace that with this; your code fine, but i dont understand the function business <? $host ="localhost"; $user ="ddsqladmin"; $pass ="bobo"; $data ="flory"; $connect =mysql_connect($host, $user, $pass); $database =mysql_select_db($data, $connect); if(!$connect||!$database)die("Database cannot connect..."); function makeClickableLinks($text) { $text = html_entity_decode($text); $text = " ".$text; $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)', '<a href="\1" target=_blank>\1[/url]', $text); $text = eregi_replace('(((f|ht){1}tps://)[-a-zA-Z0-9@:%_+.~#?&//=]+)', '<a href="\1" target=_blank>\1[/url]', $text); $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)', '\1\2', $text); $text = eregi_replace('([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})', '\1', $text); return $text; } ?> i've changed there with my user and pass and db now not even the site is loading and doesn't show any error :| sorry my mistake it works forget to remove dbconnect(); from index.php Quote Link to comment Share on other sites More sharing options...
xyn Posted June 27, 2008 Share Posted June 27, 2008 Ok, now what isnt working? Quote Link to comment Share on other sites More sharing options...
fantomel Posted June 27, 2008 Author Share Posted June 27, 2008 Your code needs a big change; your loop is not going to work, use this: <?php require('www/dbconnect.php'); dbconnect(); $id = $_GET['id']; $sql = mysql_query("select * from `books` where `books_id` ='$id'"); # or die ('Error : ' . mysql_error()); ?> <table border="1" cellpadding="0" cellspacing="0" class="tabel_editare"> <tr> <td class="textare_butonase">Book Title</td> <td class="textare_butonase">Book Year</td> <td class="textare_butonase">Book Author</td> </tr> <?php while($row=mysql_fetch_assoc($sql)) { ?> <tr> <td><?php echo $row['book Author']; ?></td> <td><?php echo $row['booky']; ?></td> <td><?php echo $row['title']; ?></td> </tr> <?php } ?> </table> <?php include('www/dbclose.php'); ?> this one still now showing on page damn ~X( P.S Sorry For Swering Quote Link to comment Share on other sites More sharing options...
fantomel Posted June 27, 2008 Author Share Posted June 27, 2008 Your code needs a big change; your loop is not going to work, use this: <?php require('www/dbconnect.php'); dbconnect(); $id = $_GET['id']; $sql = mysql_query("select * from `books` where `books_id` ='$id'"); # or die ('Error : ' . mysql_error()); ?> <table border="1" cellpadding="0" cellspacing="0" class="tabel_editare"> <tr> <td class="textare_butonase">Book Title</td> <td class="textare_butonase">Book Year</td> <td class="textare_butonase">Book Author</td> </tr> <?php while($row=mysql_fetch_assoc($sql)) { ?> <tr> <td><?php echo $row['book Author']; ?></td> <td><?php echo $row['booky']; ?></td> <td><?php echo $row['title']; ?></td> </tr> <?php } ?> </table> <?php include('www/dbclose.php'); ?> this one still now showing on page damn ~X( P.S Sorry For Swering <table align="center" cellpadding="5" class="tabel" cellspacing="0"> <tr align="center" bgcolor="#CCCCCC"> <td class="table.td"width="447"><strong>Titlu</strong></td> <td width="190"><strong>Actiune</strong></td> </tr> <?php $query = "SELECT `vacante_locatii_id`, `title` FROM `vacante_locatii` ORDER BY `vacante_locatii_id`"; $result = mysql_query($query) or die('Error : ' . mysql_error()); while(list($vacante_locatii_id, $title) = mysql_fetch_array($result, MYSQL_NUM)) { ?> <tr bgcolor="#FFFFFF"> <td width="447"> <?php echo $title;?> </td> <td width="190" align="center"><a href="index.php?page=locatie_view&id=<?php echo $vacante_locatii_id; ?>">Vizualizeaza</a> | <a href="index?page=locatie_edit&id=<?php echo $vacante_locatii_id ?>">Editeaza</a> | <a href="javascript:delArticle('<?php echo $vacante_locatii_id ?>', '<?php echo $title; ?>');">Sterge</a></td> </tr> <?php } include 'www/closedb.php'; ?> </table> second code it's for the link to go to locatie_view.php and that is the page that doesn't work. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.