vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Calling info from a database via ID (https://vborg.vbsupport.ru/showthread.php?t=68091)

Blue Moose Aaron 08-07-2004 08:20 PM

Calling info from a database via ID
 
This is a tough one, but i was wondering if you ever ran into a problem using words rather than numbers as IDs in php/mysql before?

Before when I was simply caling files I had no trouble using words (ie smallville.php?action=bios&character=clarkkent), but now that I am calling info from the database it would only work if I called a number (ie smallville.php?action=bios&character=1)

I'm not sure what I can do about this. it isnt a huge deal, I just would like to try to keep my links the same as they were for the sake of bookmarks

If it isnt clear what Im talking about I can explain more.

Here is the code in using to call the info
PHP Code:

case 'bios': {
        
$bio intval($_GET['bio']);
        
$row $DB_site->query_first("SELECT * FROM smallville_cast WHERE id=$bio");
        
$id nl2br$row[id] ); 
        
$name nl2br$row[name] ); 
        
$character_name nl2br$row[character_name] ); 
        
$image nl2br$row[image] ); 
        
$birth_date nl2br$row[birth_date] ); 
        
$birth_place nl2br$row[birth_place] ); 
        
$info nl2br$row[info] ); 
        
$character_info nl2br$row[character_info] ); 
        eval(
"\$home[header] = \"".fetch_template('vbindex_header')."\";");
        eval(
"\$nav = \"".fetch_template('vbindex_customblock_1')."\";");
        eval(
"\$next_on_smallville = \"".fetch_template('vbindex_customblock_6')."\";");
        eval(
"\$smallville_episode_select = \"".fetch_template('smallville_episode_select')."\";");
        eval(
"\$smallville_biolink = \"".fetch_template('smallville_bio_links')."\";");
        eval( 
'print_output( "' fetch_template'smallville_bios' ) . '" );' );
        } 

Like I said before I originally set up the ID field to hold 'clarkkent' or 'lanalang' but it wouldnt work. However as soon as I changed the ids from clarkkent to 1 it worked.

Modin 08-07-2004 08:27 PM

I've used names to call many things from a database and never ran into a problem.

Maybe you had an error in your code? Post the code that didn't work for you...

Blue Moose Aaron 08-07-2004 08:35 PM

thats the code above. I got no error, it would just always send me to the first row of the the table.

nexialys 08-07-2004 08:38 PM

if didn't create a while {}... so it's taking only the first in the query...

Blue Moose Aaron 08-07-2004 08:43 PM

Can you put that in novice terms? I barley know what im doing :-\

Blue Moose Aaron 08-08-2004 04:14 PM

<a href="http://www.thekryptonian.com/smallville.php?action=bios&bio=jonathankent" target="_blank">http://www.thekryptonian.com/smallvi...o=jonathankent</a>

Thats the page. You can see that if you click links in the Smallville Cast box on the right that you always get Clark Kents info from the database no matter what the url calls for.I dont understand why it calls the correct info when the id is a number but not a word. Should I make my ID row something other than varchar?

Colin F 08-08-2004 06:33 PM

well you can't use intval() if you want it to be a string (like "jonathonkent")
try deleting the first row and changing the second to

$row = $DB_site->query_first("SELECT * FROM smallville_cast WHERE id=$_GET[bio]");

Blue Moose Aaron 08-09-2004 10:52 AM

I get an SQL error. For some reason its not catching that the word names are the id's of the table.

Quote:

Database error in vBulletin 3.0.3:

Invalid SQL: SELECT * FROM smallville_cast WHERE id=clarkkent
mysql error: Unknown column 'clarkkent' in 'where clause'

mysql error number: 1054

Date: Monday 09th of August 2004 06:50:47 AM
Script: http://www.thekryptonian.com/test.ph...&bio=clarkkent

Colin F 08-09-2004 02:41 PM

you need to surround the id with 's
thats: '

making it: $row = $DB_site->query_first("SELECT * FROM smallville_cast WHERE id'=$_GET[bio]'");

Blue Moose Aaron 08-09-2004 04:39 PM

Thanks so much for your help. I appreciate it!


All times are GMT. The time now is 10:03 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.01095 seconds
  • Memory Usage 1,746KB
  • 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
  • (1)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete