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

Reply
 
Thread Tools Display Modes
  #11  
Old 02-08-2004, 05:11 PM
assassingod's Avatar
assassingod assassingod is offline
 
Join Date: Jul 2002
Posts: 3,337
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You don't need to use a variable, just use:
PHP Code:
UPDATE gallery_index SET gallery_views='gallery_views+1' WHERE gallery_id='$id' 
Reply With Quote
  #12  
Old 02-08-2004, 06:33 PM
AN-net's Avatar
AN-net AN-net is offline
 
Join Date: Dec 2003
Location: AnimationTalk.com
Posts: 2,367
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hmm it just changes it to 0
Reply With Quote
  #13  
Old 02-08-2004, 06:35 PM
assassingod's Avatar
assassingod assassingod is offline
 
Join Date: Jul 2002
Posts: 3,337
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

1. I wouldn't query in a loop if I were you.
2. I'm not sure why it's not updating - I used the exact same method for my Tutorial Hack and it works perfectly.
Reply With Quote
  #14  
Old 02-08-2004, 07:14 PM
AN-net's Avatar
AN-net AN-net is offline
 
Join Date: Dec 2003
Location: AnimationTalk.com
Posts: 2,367
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

oh i removed, the update query from the loop
heres my current code:
PHP Code:
if($view==gal){
$fgall$DB_site->query("SELECT gallery_index.gallery_views,gallery.gallery_id,gallery.image_id,gallery.image_name,gallery.image_url,gallery.image_des,gallery.image_views,gallery.image_rating,gallery.image_date FROM gallery,gallery_index WHERE gallery_index.gallery_id='$id' AND gallery.gallery_id='$id'");
while(
$gallery$DB_site->fetch_array($fgall))
{
    eval(
'$gallerybits .= "' fetch_template('gallery_gal_lvl1') . '";');    
}
$fv$DB_site->query("SELECT gallery_views FROM gallery_index WHERE gallery_id='$id'");
$views=$DB_site->fetch_array($fv);
$DB_site->query("UPDATE gallery_index SET gallery_views='gallery_views+1' WHERE gallery_id='$id'");
eval(
'$navbar .= "' fetch_template('navbar') . '";');
eval(
'print_output("' fetch_template('gallery_gal') . '");');

Reply With Quote
  #15  
Old 02-08-2004, 08:51 PM
AN-net's Avatar
AN-net AN-net is offline
 
Join Date: Dec 2003
Location: AnimationTalk.com
Posts: 2,367
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hmmm i can get this to insert stuff in the table
heres the code:
PHP Code:
if($do==insert){
$DB_site->query("INSERT INTO gallery (gallery_id,artist_name,artist_id,image_name,image_url,image_des) VALUES('$id','$artname','$artid','$imgname','$imgurl','$imgdes')");

heres the form i used:
HTML Code:
<table align="center" class="tborder" style="border: 1px outset;">
<tr>
<td><strong>At this time you must host your own images</strong></td>
</tr>
<tr>
<td class="thead">Required Information</td>
</tr>
<tr>
<td class="gal1"><form action="gallery.php?do=insert" method="get">
<input type="hidden" name="id" value="$id">
<input type="hidden" name="artid" value="$bbuserinfo[userid]">
<input type="hidden" name="artname" value="$bbuserinfo[username]">
Image Name:<input type="text" name="imgname" value="Image Name" maxlength="35" size="20">
</td>
</tr>
<tr>
<td class="gal2">Image Description:<br /><textarea name="imgdes" maxlength="900" rows="3" cols="45">Put your image's description here</textarea>
</td>
</tr>
<tr>
<td class="gal1">Image Url:<input type="text" name="imgurl" value="Image's Url" maxlength="255"></td>
</tr>
<tr>
<td class="galhead"><input type="submit" value="Submit Entry"></td>
</tr>
</table>
</form>
Reply With Quote
  #16  
Old 02-09-2004, 03:36 AM
Zero Tolerance's Avatar
Zero Tolerance Zero Tolerance is offline
 
Join Date: Feb 2004
Location: England
Posts: 813
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
if($view==gal){ 
$fgall$DB_site->query("SELECT gallery_index.gallery_views,gallery.gallery_id,gallery.image_id,gallery.image_name,gallery.image_url,gallery.image_des,gallery.image_views,gallery.image_rating,gallery.image_date FROM gallery,gallery_index WHERE gallery_index.gallery_id='$id' AND gallery.gallery_id='$id'"); 
while(
$gallery$DB_site->fetch_array($fgall)) 

    eval(
'$gallerybits .= "' fetch_template('gallery_gal_lvl1') . '";');     

$fv$DB_site->query("SELECT gallery_views FROM gallery_index WHERE gallery_id='$id'"); 
$views=$DB_site->fetch_array($fv); 
$DB_site->query("UPDATE gallery_index SET gallery_views=gallery_views+'1' WHERE gallery_id='$id'"); 
eval(
'$navbar .= "' fetch_template('navbar') . '";'); 
eval(
'print_output("' fetch_template('gallery_gal') . '");'); 

Mysql 'field' doesnt go inside the quotes, atleast, i never do that and it works fine for me
Reply With Quote
  #17  
Old 02-09-2004, 04:00 AM
g-force2k2 g-force2k2 is offline
 
Join Date: Mar 2002
Location: Everywhere you wanna be..
Posts: 1,608
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

First off

PHP Code:
$fv$DB_site->query("SELECT gallery_views FROM gallery_index WHERE gallery_id='$id'"); 
$views=$DB_site->fetch_array($fv); 
is a waste of a query as it is getting data that already exists.

Also you don't need any quotes at all

PHP Code:
gallery_views=gallery_views+
will suffice, and where in the script are you definning the $id, and does everything display correctly just the views will note update?

Only reason I can see that the data doesn't update correctly is that the url is not yourscript.php?view=gal, other then that it should update, unless you also defined the templates to eval elsewhere. You can free the memory that is used by the query after the while loop

PHP Code:
$DB_site->free_result $fgall ) ; 
Cheers,
g-force2k2
Reply With Quote
  #18  
Old 02-09-2004, 10:53 AM
AN-net's Avatar
AN-net AN-net is offline
 
Join Date: Dec 2003
Location: AnimationTalk.com
Posts: 2,367
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks guys ill try it out when i get home
gforce i am defining $id through the link to the gallery from the gallery index.
example:
gallery.php?view=gall&id=1
where should i put that free result
im a tid bit new to php but i think im doing ok, also can someone help me out with my post on inserting stuff into the db, i have clue y it doesnt work

edit:
thanks to both of you, its updating views now now i gotta sort out that inserting>_<

edit2:
ok i changed the insert query to this but it still aint working:
PHP Code:
if($do==insert){
$image_datetime();
$DB_site->query("INSERT INTO gallery (gallery_id,artist_name,artist_id,image_name,image_url,image_des,image_date) VALUES('$gallery_id','$artist_name','$artist_id','$image_name','$image_url','$image_des','$image_date')");

HTML Code:
<form action="gallery.php?do=insert" method="get">
<input type="hidden" name="gallery_id" value="$id">
<input type="hidden" name="artist_name" value="$bbuserinfo[username]">
<input type="hidden" name="artist_id" value="$bbuserinfo[userid]">
Image Name:<input type="text" name="image_name" value="Image Name" maxlength="35" size="20">
</td>
</tr>
<tr>
<td class="gal1">Image Url:<input type="text" name="image_url" value="Image's Url" maxlength="255"></td>
</tr>
<tr>
<td class="gal2">Image Description:<br /><textarea name="image_des" maxlength="900" rows="3" cols="45">Put your image's description here</textarea>
</td>
</tr>
<tr>
<td class="galhead"><input type="submit" value="Submit Entry"></td>
</tr>
</table>
</form>
Reply With Quote
  #19  
Old 02-11-2004, 08:43 PM
AN-net's Avatar
AN-net AN-net is offline
 
Join Date: Dec 2003
Location: AnimationTalk.com
Posts: 2,367
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

anyone know how to solve my insert query problem?
Reply With Quote
  #20  
Old 02-12-2004, 12:30 AM
g-force2k2 g-force2k2 is offline
 
Join Date: Mar 2002
Location: Everywhere you wanna be..
Posts: 1,608
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by AN-net
anyone know how to solve my insert query problem?
Try changing the method to POST and then make it $_POST['do'] == "insert" and also make the form action="gallery.php"

Hope that helps somewhat.

Cheers,
g-force2k2
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 07:59 PM.


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.04379 seconds
  • Memory Usage 2,314KB
  • Queries Executed 12 (?)
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
  • (2)bbcode_html
  • (8)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
  • (3)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
  • (10)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