0

Hello Dear Brothers & Sisters
how are you....?

Well, i am facing a problem while handling a script and database.
actually i am trying to shift some data (user id form database) form one page to another. through $_GET (if you have any other technique also suggest.)

and after transfring i grap that data through $_GET. and now i want to put that id from url to database for future use. and for that purpose i am using poster_id() function. it works fine normally i checked it through echo. but when i put this funtion in INSERT statement of mysql it put always "0" in database. why?
Please guide me. also i am new user of PHP.

<?php
                       require 'connect.php';

                         if(!empty($_GET["id"]) && !empty($_GET{"Summary"})){
                         echo  $id = $_GET["id"].'<br>';
                         echo $summary = $_GET["Summary"].'<hr>';
                         }
                            
                            function poster_id(){
                                 if(!empty($_GET["id"]) && !empty($_GET{"Summary"})){
                                 $id = $_GET["id"];
                                 return $id;
                                 }
                              }

                            //echo $one = poster_id();


                         if(isset($_POST["name"]) && isset($_POST["email"]) && isset($_POST["textArea"])){
                           $name  =    $_POST["name"];
                           $email =    $_POST["email"];
                           $textArea = $_POST["textArea"];
                           if(!empty($name) && !empty($email) && !empty($textArea)){

                                 $id = poster_id();

                             $query = "INSERT INTO coments VALUES('', '$id', '$name','$email','$textArea')";
                             if($query_run = mysql_query($query)){
                               echo $id = poster_id();
                             }
                           }
                         }
?>

HTML CODE HERE

<form action="test.php" method="POST">
                            Your Name:<input type="text" name="name" size="25">
                            E-mail address:<input type="text" name="email" size="30"><br>
                            <textarea cols="69" rows="10" name="textArea"></textarea>
                            <input type="submit" value="Submit">
                      </form>
3
Contributors
5
Replies
7
Views
5 Years
Discussion Span
Last Post by Metophase
0

Hello Dear Brother
How are you......?

And thanks for giving me time
but no error appear on my script when i press submit button.
just tell me how i can use return value of function (poster_id) in my database, i wanna store return value in mysql.
Thanks

0

Hi

$query = "INSERT INTO coments VALUES('', '$id', '$name','$email','$textArea')";

do you have 5 field in coments table.

0
$query = "INSERT INTO coments VALUES('', '$id', '$name','$email','$textArea')";

isn't coments suppose to be comments, and i find it always best to name the columns

$query = "INSERT INTO comments ('col1','col2','col3','col4','col5') VALUES ('$var1','$var2','$var3','$var4','$var5')";
This topic has been dead for over six months. 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.