| | |
$_GET['id'] is not working?????
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: May 2008
Posts: 74
Reputation:
Solved Threads: 0
i am extemly newbie and don’t know whether I should post my problem here or somewhere else, however…
i have following problem in one of my php-mysql application
header link through browser is,
"http://localhost/test/reply.php?id=852"
and query is as follow,
The application does not pass any value related to $q_id in database table, the table view is as follow, The query does not insert any value to tid column except default value. What should I do…
The table specification is as follow,
I have tried every method, I know but in vain.
Please any body helps me….
Shuja
i have following problem in one of my php-mysql application
header link through browser is,
"http://localhost/test/reply.php?id=852"
and query is as follow,
$name=$_POST['name']; //from the name form $q_id=$_GET['id']; $sql="INSERT INTO `test`.`reply`(`rid`,`tid`,`name`)VALUES(NULL,'$q_id','$name')"; $result=mysql_query($sql);
rid tid name 1 0 karam 3 0 drupal 4 0 Shuja-u-Rehman
The table specification is as follow,
Field Type Null Default Extra rid int(11) No auto_increment tid int(11) No name varchar(25) No
I have tried every method, I know but in vain.
Please any body helps me….
Shuja
So, is your form action is like this ?
If this is the case, then it should work fine. If not, then you should post your code..
php Syntax (Toggle Plain Text)
<form method="POST" action="reply.php?id=852"> </form>
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
You need to isolate the problem. At this point, you don't know if the GET variable is not picking up the value or if the value is not being inserted into thte table.
add echo $q_id;
just after
$q_id=$_GET['id'];
also add echo $sql;
just before you assign the INSERT statement to $sql.
That will tell you right away where the problem lies.
add echo $q_id;
just after
$q_id=$_GET['id'];
also add echo $sql;
just before you assign the INSERT statement to $sql.
That will tell you right away where the problem lies.
His problem is quite simple actually. Here's his original code
All he needs to do is remove the single quotes (' ') from around the $q_id in his SQL.
So his new code should look like this:
He has declared the tid field as an integer and he is trying to pass it as a string. MySQL probably doesn't like it.
ALSO
Just to be on the safe side you really need to run the $_GET['id'] and the $_POST['name'] variables through the mysql_real_escape_string() function to prevent someone from doing nasty things to your database. Example:
Hope that helps you.
PHP Syntax (Toggle Plain Text)
$name=$_POST['name']; //from the name form $q_id=$_GET['id']; $sql="INSERT INTO `test`.`reply`(`rid`,`tid`,`name`)VALUES(NULL,'$q_id','$name')"; $result=mysql_query($sql);
All he needs to do is remove the single quotes (' ') from around the $q_id in his SQL.
So his new code should look like this:
PHP Syntax (Toggle Plain Text)
$name=$_POST['name']; //from the name form $q_id=$_GET['id']; $sql="INSERT INTO `test`.`reply`(`rid`,`tid`,`name`)VALUES(NULL, $q_id ,'$name')"; $result=mysql_query($sql);
He has declared the tid field as an integer and he is trying to pass it as a string. MySQL probably doesn't like it.
ALSO
Just to be on the safe side you really need to run the $_GET['id'] and the $_POST['name'] variables through the mysql_real_escape_string() function to prevent someone from doing nasty things to your database. Example:
php Syntax (Toggle Plain Text)
$q_id = mysql_real_escape_string($_GET['id']); $name = mysql_real_escape_string($_POST['name']);
Hope that helps you.
JRSofty Programming | .NET Dreaming | GalahTech
If your question is solved then mark the thread solved. If someone gives you good advice then give them some rep.
If your question is solved then mark the thread solved. If someone gives you good advice then give them some rep.
•
•
•
•
He has declared the tid field as an integer and he is trying to pass it as a string. MySQL probably doesn't like it.
I still believe its the form action which was causing the problem!
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
Similar Threads
- Problem with $_GET variable (PHP)
- datagrid working but php_self problem (PHP)
- PHP / SQL Delete From Statement Not working with URL? (PHP)
- mysql DELETE not working (PHP)
- URL with query is not working... (PHP)
- AJAX not working on firefox (JavaScript / DHTML / AJAX)
- echo not working (PHP)
- UPDATE query not working properly... (PHP)
- Pray for help on mod_rewrite rule (Linux Servers and Apache)
Other Threads in the PHP Forum
- Previous Thread: Write a one echo statment from html
- Next Thread: help needed for my update.....
| Thread Tools | Search this Thread |
apache api array beginner binary body broken buttons cakephp checkbox class cms code cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions global google href htaccess html image include insert ip javascript joomla limit link list login mail mediawiki menu mlm msqli_multi_query multiple mycodeisbad mysql number oop parameter paypal pdf php phpincludeissue phpmyadmin problem query radio random recursion regex remote script search seo server sessions sms source sp space speed sql static subdomain syntax system table tag tutorial update upload url validator variable vbulletin video web webdesign white wordpress xml youtube






