Jump to content

mostafa581

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mostafa581's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. the problem is i,m building a site that shows news and allow visitors to comment for every news in that page that shows the news you can insert your comment on this news you,re watching you must get the shown news id and insert it with the comment inorder to show all comments related to this news i got this id by the following variable $id1=$row2['id']; echo "$id1"; and when i printed it (for testing if it is working ) it was working properly and show the right id for the shown topic the next step i need to insert it into the database of comments and use it to select all comments related to any topic i used the insert query $insertcomm =mysql_query("INSERT INTO comments (com_name,com_title,com_mail,comment,com_date,tid) VALUES ('$name','$title','$mail','$com','$d','$id1')") or die("comments were not inserted"); the problem is when inserting any test comment and serching the database for it i find it already inserted except that variable $id1 it always shows a( 0 ) inside the database in the field tid although it shows the right id printed on the page i replaced the place of this variable to insert it,s value in any other field for example (in the title of the email ) it also gave the value of 0
  2. Friends this is a very strange problem i,m facing i made a form by which you can enter comments to a topic i get the comment title and comment topic and date and the name and e mail of the one who insert a comment according to these variables $id1=$row2['id']; echo "$id1"; //Comment poster,s name $name =strip_tags(@$_POST['coname']); //Comment title $title =strip_tags(@$_POST['comtitle']); //ment poster,s email $mail =strip_tags(@$_POST['comemail']); //comment $com =strip_tags(@$_POST['limitedtextarea']); //comment,s date $d= date("Y-m-d"); notice that i,m printing the topic id and i used the variable $id1 to get it inorder to use it to show the comments for this topic later and it shows the right id for the shown topic then i used this code to insert these variable into the database if(isset($_POST['add']) and $_POST['add']=='comm'){ $insertcomm =mysql_query("INSERT INTO comments (com_name,com_title,com_mail,comment,com_date,tid) VALUES ('$name','$title','$mail','$com','$d','$id1')") or die("comments were not inserted"); if(isset($insertcomm)){ echo "comment inserted ";} }
  3. hi i got a question and i hope that someone help me with the reply i thought to build a SMTP server to use it in sending big number of e mails so what is the name of the software i can install it to use the server this way ??? how to go through this from A to Z need your replies Thank you
  4. yes it is but that topic was about the database connection and it was solved but this topic here is about adding data to the database so i thought that it is because of the phpmyadmin settings or something like that this is why i posted this topic here and you see it is not the same one you told me about
  5. Friends i,m having something wrong with mysql database first i tried to connect to the database but i couldn,t i posted such problem and someone advised me to go to privileges of the database and i did what he said then i succesfully connected to it and after connection i established a form <form action="admins.php" method='post'> <table align="center" valign="center"> <tr> <td> Admin,s name: </td> <td><input type="text" name="adminname" /><br /></td></tr> <td>Admin,s Password: </td> <td><input type="password" name="adminpassword" /></td></tr> <td><input type="submit" value="Add New Admin" /></td></tr> </form> </tr> </table> then i established the page admins.php to direct the data to it i tried to add obtained data to the table by this code <?php $admin = $_POST['adminname']; $password = $_POST['adminpassword']; if($admin&&$password){ mysql_query("INSERT INTO 'admin'('','admin','password') VALUES('','$admin','$password');"); echo "admin was added"; }else die("not added"); by entering the name and password to the form textboxes and press the form button it shows the message that admin was added and by checking the table i find that there is nothing was added and it is as it was created include no data at all how can i solve this problem MOD Edit: code tags added.
  6. i could connect to the database and i dod nothing but to go through privileges in phpmyadmin by selecting privileges of the data base i design and by using the icon (action) it gave me a page to edit user i selected all check boxes mentioned in the global privileges then pressed go and for resource limits i read a note that said setting these options to zero removes the limit i set then to 1 and by using the connection function i could connect to the data base <?php $connectdb = mysql_connect('localhost','root','') or die("not connected"); $selectdb = mysql_select_db("koora", $connectdb); if($selectdb) { echo "ok you,re now connected to table "; }else die("couldn,t connect to the database"); when refreshing my page it showed a message that said ok you,re now connected to table but i got another problem which is by using this form <form action="admins.php" method='post'> <table align="center" valign="center"> <tr> <td> Admin,s name: </td> <td><input type="text" name="adminname" /><br /></td></tr> <td>Admin,s Password: </td> <td><input type="password" name="adminpassword" /></td></tr> <td><input type="submit" value="Add New Admin" /></td></tr> </form> </tr> </table> to enter user name and password and by using the following code to get the data to the page the form directs to $admin = $_POST['adminname']; $password = $_POST['adminpassword']; if($admin&&$password){ mysql_query("INSERT INTO 'admin'('','admin','password') VALUES('','$admin','$password');"); echo "admin was added"; }else die("not added"); every time i enter a name and password to the text box and press enter it shows the message that admin was added and by checking the table which data are entered and stored i find nothing was added and the table is empty i guess that this problem is because of something wrong with the database may be something with settings or some like that i need your help with this problem Thanks in advance
  7. i tried it before but it gave me that message error connecting tableAccess denied for user ''@'localhost' to database 'koora'
  8. Dear friends i,m a php beginner and i got a problem with connecting to my database i created a database called (koora) with one table called (admins) and when i tried to connect to it (database ) ; it did not connect here is the code i used for that <?php $connectdb = mysql_connect('localhost','','') or die("not connected"); $selectdb = mysql_select_db("koora", $connectdb); if(!$selectdb) { die("error connecting table" .mysql_error()); } then when refreshing my phpmyadmin page i got that message error connecting tableAccess denied for user ''@'localhost' to database 'koora' koora is the name of the database so i need your help with this problem and what is the reason not to connect to the data base Thank you
×
×
  • 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.