0

there seems to be a problem with adding records to my database.
heres the code.

//this redirects the logged in user to the create php whereas the idnum of the user is already 
//echoed in a textbox.
<?php
 $result1 = mysql_query("select * from info where idnum = ".$_SESSION['valid'],$conn);
    while($row = mysql_fetch_assoc($result1))
    {
         echo "<center><a href=\"create.php?idnum=$row[idnum]\">start new glob</a></center>";
    }
?>



//now this code is for adding the records. but somehow this doesnt seem to work.
//my tbglobs table allows duplicate idnum's . but then again theres no problem with
//that. thing is i cant add data to my data base. 

<form name="create" action="create.php" method="POST">
<input name="globtitle" type="text" style="position:absolute;width:229px;left:525px;top:280px;z-index:1">
<textarea name="globarea" style="position:absolute;left:464px;top:338px;width:290px;height:238px;z-index:2"></textarea>\
<input name="createglob" type="submit" value="create glob" style="position:absolute;left:663px;top:585px;z-index:3">
<input type="text" name="textid" value=<?php echo $_GET['idnum'];?>>
</form>


 <?php

 if(isset($_POST['createglob']))
 {
    $id = $_POST['textid'];
    $title=$_POST['globtitle'];
    $content=$_POST['globarea'];

    $resulta = mysql_query("INSERT into tbglobs (idnum,title,content) VALUES ('$id','$title','$content')");
    //$result=mysql_query("INSERT INTO tbglobs(idnum,title,content) VALUES('$id','$title','$content')",$conn);
    echo "glob successfully added!";
 }
?>

thanks for your help!
very much appreciated!
:)

3
Contributors
12
Replies
14
Views
4 Years
Discussion Span
Last Post by HunainHafeez
0

Can you not echo any errors to the screen?

$sql = "INSERT into test (idnum,title,content) VALUES ('$id','$title','$content')";
if (!$resulta = mysql_query($sql)){
    echo mysql_error();
    die();
    }

If not, can you not read the error log?

0

$resulta = mysql_query("INSERT into tbglobs (idnum,title,content) VALUES ('$id','$title','$content')");
$result=mysql_query($resulta,$conn);

0

the error msg goes

Access denied for user 'root'@'localhost' (using password: NO)

what does this mean?

0

It looks like a config error with your user/pass or you are trying to operate on a connection that wasn't established. Can you post the connection code being careful to mask the username and password?

0

the error msg goes

Access denied for user 'root'@'localhost' (using password: NO)

what does this mean?

0

this is my config.
<?php

$conn = mysql_connect("localhost","root","**********")
or die("Could not connect to the server.");

mysql_select_db("dbglob",$conn)
or die("Could not select the database.");

?>

0

oh. i think i finally got it.
the error msg kept saying that the query was empty.
but then when i looked into my database, all data was successfully added.
thank you so much fo the help.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.