Jump to content

debug...


fantomel

Recommended Posts

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

Link to comment
Share on other sites

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'];
     }

Link to comment
Share on other sites

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 :(

Link to comment
Share on other sites

$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.

 

Link to comment
Share on other sites

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');  
?>

Link to comment
Share on other sites

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;

        }

?>

Link to comment
Share on other sites

replace that with this; your code fine, but i dont understand the function business :P

 

<?
$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;
        }

?>

Link to comment
Share on other sites

replace that with this; your code fine, but i dont understand the function business :P

 

<?
$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 :| :(

Link to comment
Share on other sites

replace that with this; your code fine, but i dont understand the function business :P

 

<?
$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 :D

Link to comment
Share on other sites

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 :(

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.