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!
:)

Recommended Answers

All 12 Replies

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?

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

the error msg goes

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

what does this mean?

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?

the error msg goes

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

what does this mean?

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.");

?>

oh. now its trying to say query was empty.

set your mysql permissions to allow access

oh. now its trying to say query was empty.

im new to php.
how can i do that?

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.