the query below is not executing and i can not figure out the reason.please help.this is my first time of developing a web page. [php] Untitled Document
i'm i could not upload the code.i try uploading the code by pasting it in the new thread textarea and enclosing it between the tags: , to my surprise it did not work . it is the reason why the tag [php] untitled Document is attached to the post.if any one can help me post the code it will be appreciated. any help is welcome. thank you.
i'm i could not upload the code.i try uploading the code by pasting it in the new thread textarea and enclosing it between the tags: , to my surprise it did not work . it is the reason why the tag [php] untitled Document is attached to the post.if any one can help me post the code it will be appreciated. any help is welcome. thank you.
your [php] Untitled Document is not working (and it is not an attachment) probably you need to post as said in above post to make us understand about your code.
this is the code which is not executing.it produces the message:"post could not be added to forum".
PHP Code:
mysql_select_db($database_sql1, $sql1); if(isset($_POST['addpost'])) { if(!empty($_POST["posts"])){ foreach($_POST["posts"] as $postid){ $postid=mysql_real_escape_string($postid); $confirmpost="UPDATE forum_post SET confirm='yes' WHERE post_id={$postid}"; $rs_confirmpost=mysql_query($confirmpost,$sql1) or die("post could not be added to forum"); } } }
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
thanks for all the helps you have given so far. i remove the curly brackets in the where clause and error still exist. this is the code again and the form whose data is to be stored in the database. any help is appreciated
PHP Code:
<?php require_once('../Connections/sql1.php'); ?> <?phpmysql_select_db($database_sql1, $sql1); $query_rs_uncertpost = "SELECT topic_id, post_owner, post_description FROM forum_post WHERE confirm='no'"; $query_limit_rs_uncertpost = sprintf("%s LIMIT %d, %d", $query_rs_uncertpost, $startRow_rs_uncertpost, $maxRows_rs_uncertpost); $rs_uncertpost = mysql_query($query_limit_rs_uncertpost, $sql1) or die(mysql_error()); $row_rs_uncertpost =mysql_fetch_assoc($rs_uncertpost);mysql_select_db($database_sql1, $sql1); if(isset($_POST['addpost'])) { if(!empty($_POST["posts"])){ foreach($_POST["posts"] as $postid){ $postid=mysql_real_escape_string($postid); $confirmpost="UPDATE forum_post SET confirm='yes' WHERE post_id=$postid"; $rs_confirmpost=mysql_query($confirmpost,$sql1) or die(mysql_error()); } } } if(isset($_POST['delpost'])) { if(!empty($_POST["posts"])){ foreach($_POST["posts"] as $postid){ $deletepost="DELETE FROM forum_post WHERE post_id={$postid}"; $rs_deletepost=mysql_query($deletepost,$sql1) or die("could not remove post from forum"); }
I would say you just echo the query and understand what its querying..
try some thing like
echo $confirmpost;
__________________ Please login or register to view this content. Registration is FREE - Please login or register to view this content. Registration is FREE - 1-888-869-HOST(4678)
Award winning Managed Hosting - Please login or register to view this content. Registration is FREE
Managed Dedicated Servers. Reseller Discounts. 24/7 Impressive Tech Support
i am doubting whether the way i used the foreach function might be the cause since the $postid is initialised there. could it be the cause? else what other information do i need to provide in order for someone to be able figure out where things are getting wrong.or is there any other way i can fix it. please help i am comfuse
As your SQL looks ok. I assume you have tested the SQL with a tool like myPHPAdmin to make sure it's correct?
If so, that leaves the value of post_id. Focus on the values in the POST. I assume you're expecting integers. Check to see what is really being passed.
Add some bullet proofing in your code to make sure that only valid integers are being converted into SQL statements.
You could also add some logging to make it easier to debug.