Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-07-2004, 08:20 PM
Blue Moose Aaron's Avatar
Blue Moose Aaron Blue Moose Aaron is offline
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 149
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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.
Reply With Quote
  #2  
Old 08-07-2004, 08:27 PM
Modin Modin is offline
 
Join Date: Jun 2004
Posts: 162
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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...
Reply With Quote
  #3  
Old 08-07-2004, 08:35 PM
Blue Moose Aaron's Avatar
Blue Moose Aaron Blue Moose Aaron is offline
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 149
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thats the code above. I got no error, it would just always send me to the first row of the the table.
Reply With Quote
  #4  
Old 08-07-2004, 08:38 PM
nexialys
Guest
 
Posts: n/a
Default

if didn't create a while {}... so it's taking only the first in the query...
Reply With Quote
  #5  
Old 08-07-2004, 08:43 PM
Blue Moose Aaron's Avatar
Blue Moose Aaron Blue Moose Aaron is offline
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 149
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can you put that in novice terms? I barley know what im doing :-\
Reply With Quote
  #6  
Old 08-08-2004, 04:14 PM
Blue Moose Aaron's Avatar
Blue Moose Aaron Blue Moose Aaron is offline
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 149
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

<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?
Reply With Quote
  #7  
Old 08-08-2004, 06:33 PM
Colin F's Avatar
Colin F Colin F is offline
 
Join Date: Jul 2004
Location: Switzerland
Posts: 1,551
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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]");
Reply With Quote
  #8  
Old 08-09-2004, 10:52 AM
Blue Moose Aaron's Avatar
Blue Moose Aaron Blue Moose Aaron is offline
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 149
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #9  
Old 08-09-2004, 02:41 PM
Colin F's Avatar
Colin F Colin F is offline
 
Join Date: Jul 2004
Location: Switzerland
Posts: 1,551
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

making it: $row = $DB_site->query_first("SELECT * FROM smallville_cast WHERE id'=$_GET[bio]'");
Reply With Quote
  #10  
Old 08-09-2004, 04:39 PM
Blue Moose Aaron's Avatar
Blue Moose Aaron Blue Moose Aaron is offline
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 149
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks so much for your help. I appreciate it!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:58 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.04370 seconds
  • Memory Usage 2,264KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (9)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete