Page 1 of 1

problem with inserting data

Posted: Thu Apr 09, 2009 5:54 am
by smileboy
hi, i was creating website which has database and having problem on adding
my php code for adding is not working [don't know why]
when i press add button, it is showing white screen. nothing else

here is some info about my database

two tables: title and words
in title, fields: id and word
in words, fields :id, title, descr, example, synonim, user

here is the code for add.php

Code: Select all

 
<?php
 
mysql_connect("*********", "*****", "**************") or die(mysql_error());
mysql_select_db("*************") or die(mysql_error());
 
if (isset($_POST['add']))
{
 
    $sql = "INSERT INTO words (title, descr, example, synonim, user) VALUES ('$_POST[title]', '$_POST[descr]', '$_POST[example]', '$_POST[related]', '$_POST[user]')";
        $result = mysql_query($sql);
        $check_title = mysql_query("select*from title where word='$_POST['title']");
        $rows = mysql_num_rows($check_title);
        echo $rows;
    if ($rows==0)
    {
        $sql = "INSERT INTO title (word) VALUES ('$_POST[title]')";
        $result = mysql_query($sql);
    } else {}
}
 
?>  
<html>
<head><title>Added</title></head>
<link href="css/graffiti.css" rel="stylesheet" type="text/css">
<body>
<div id="wrapper">
<div id="header">
    <p id="home">
    <a href="index.php">Jargon.uz</a>
    </p>
</div>
        
<div id="navigation">
    <p id="menu">
        
    <?php
    foreach (range('A', 'Z') as $letter)
    {
            echo '<a href="az.php?category='.$letter.'">'.$letter.'</a> ';
        }
    ?>
 
    ::&nbsp;&nbsp;<a href="all.php">xamma so`zlar</a> &nbsp;<a href="random.php">tasodifiy</a> :: <a href="add.html">kirit</a> &nbsp;<a href="chat.php">chat</a> &nbsp;<a href="themes.html">temalar</a>
    </p>
</div>
 
<div id="leftcolumn">leftcol</div>
<div id="content">
<center>Your data has been added successfully!</center>
</div>
<div id="footer">footer</div>
 
<div id="about">
    <center>
        <p id="copyright">
        Jargon.uz &copy; 2009 [project of Akmal] :: <a href="aboutus.html">sayt haqida</a>&nbsp; <a href="fq.html">foydalanish qoidalari</a> &nbsp;<a href="svt.php">savol va takliflar</a> &nbsp;<a href="ads.html">reklama</a>
            
        </p>
    </center>
</div>
 
</div>
</body>
</html>
 
if you notice some problems, please help

Re: problem with inserting data

Posted: Thu Apr 09, 2009 6:38 am
by Apollo
If you don't see anything at all (not even the echo $rows;) pinpoint the problem by inserting some print('here I am #1!'); print('here I am #2!'); etc. after different lines, and see how far it gets.