vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   WHERE `id` = 'a-number-here' problem (https://vborg.vbsupport.ru/showthread.php?t=114856)

error_22 05-05-2006 06:33 PM

WHERE `id` = 'a-number-here' problem
 
Hi, I have a problem:

PHP Code:

echo "<form action='send.php' method='POST'>";
echo 
"<select name='pageid'>";

$sql "SELECT * FROM `page` ORDER by `id`";
    
$result mysql_query($sql) or die(mysql_error());
    while (
$row mysql_fetch_array($result,MYSQL_ASSOC))
    {
        echo 
"<option value='{$row['id']}'>{$row['title']}</option>";
    }
    
    echo 
"</select><input type='submit' value='save'></form>"

in send.php:

PHP Code:

$id $_POST['pageid'];
    
$sql "SELECT * FROM `page` WHERE ?id? = '$id'";
    
$result mysql_query($sql) or die(mysql_error());
    while (
$row mysql_fetch_array($result,MYSQL_ASSOC))
    { echo 
"something goes here"; } 

I get this when i hit the save button:

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '?id? = '16'' at line 1

What am i doing wrong?

Paul M 05-05-2006 08:16 PM

What are those funny characters around page and id, try removing them.

error_22 05-05-2006 10:19 PM

nope same thing. Ive had this problem before. It only occurs when the value contains numbers. Am I the only one with this problem? :S

harmor19 05-06-2006 04:42 AM

try removing the space id='$id'

Xorlev 05-08-2006 01:36 AM

You somehow managed to use front ticks. Here's how I'd rewrite it (fix + my style):

$sql = 'SELECT * FROM `page` WHERE `id` = "' . $id . '"';

error_22 05-11-2006 04:08 PM

very very strange....i changed:
PHP Code:

$id $_POST['pageid']; 

to:
PHP Code:

$id $_REQUEST['pageid']; 

and now it works. I was wondering, whats the difference between $_REQUEST and $_POST?

Thanks for all the help guys!

Adrian Schneider 05-11-2006 04:13 PM

$_POST is from forms where the method is set to post. $_GET is from the query string (showthread.php?t=5), and $_REQUEST combines the two, as well as a few others.


All times are GMT. The time now is 11:40 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02097 seconds
  • Memory Usage 1,728KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete