vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   getting some errors (https://vborg.vbsupport.ru/showthread.php?t=61300)

assassingod 02-08-2004 05:11 PM

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' 


AN-net 02-08-2004 06:33 PM

hmm it just changes it to 0

assassingod 02-08-2004 06:35 PM

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.

AN-net 02-08-2004 07:14 PM

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') . '");');



AN-net 02-08-2004 08:51 PM

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>


Zero Tolerance 02-09-2004 03:36 AM

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 :)

g-force2k2 02-09-2004 04:00 AM

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

AN-net 02-09-2004 10:53 AM

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>


AN-net 02-11-2004 08:43 PM

anyone know how to solve my insert query problem?

g-force2k2 02-12-2004 12:30 AM

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


All times are GMT. The time now is 10:31 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.01232 seconds
  • Memory Usage 1,784KB
  • 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
  • (2)bbcode_html_printable
  • (8)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)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