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)

AN-net 02-07-2004 11:09 PM

getting some errors
 
ok trying to code this but its being evil!
PHP Code:

if($view==gal){
$fgall$DB_site("SELECT gallery_index.gallery_views,gallery.gallery_id,gallery.image_id,gallery.image_url,gallery.image_des,gallery.image_views,gallery.image_rating,gallery.image_date FROM gallery,gallery_index WHERE gallery_index.gallery_views='$id'");
$gallery$DB_site->fetch_array($fgall)
$views=++$gallery[gallery_index];
$tviews$views;
$DB_site->query("UPDATE gallery_index SET gallery_views='$tviews' WHERE gallery_id='$id'");
eval(
'$navbar .= "' fetch_template('navbar') . '";');
eval(
'print_output("' fetch_template('gallery_gal') . '");');
}
?> 

im getting a parse error on Line 21.
Line 21 is this:
PHP Code:

$views=++$gallery[gallery_index]; 


Xenon 02-08-2004 12:32 AM

you forgot a ; one line before

AN-net 02-08-2004 01:03 AM

omg woops, xeon u always catch my small errors.
im so stupid>_<

AN-net 02-08-2004 01:12 AM

ok i cant get this thing to add 1 to # views it gets from DB
this is my code:
PHP Code:

$fgall$DB_site->query("SELECT gallery_index.gallery_views,gallery.gallery_id,gallery.image_id,gallery.image_url,gallery.image_des,gallery.image_views,gallery.image_rating,gallery.image_date FROM gallery,gallery_index WHERE gallery_index.gallery_views='$id'");
$gallery$DB_site->fetch_array($fgall);
$views=++$gallery[gallery_index];
$tviews=$views;
$DB_site->query("UPDATE gallery_index SET gallery_views='$tviews' WHERE gallery_id='$id'");
eval(
'$navbar .= "' fetch_template('navbar') . '";');
eval(
'print_output("' fetch_template('gallery_gal') . '");');
}
?> 

for some reason it just changes em all to 1 and thats it

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

anyone have any ideas or tips for making it add one to the views and not just chaning it to one

assassingod 02-08-2004 04:22 PM

1. Don't bump threads until atleast 24 hours later
2. For the UPDATE query, use:
PHP Code:

UPDATE gallery_index SET gallery_views='gallery_views+$tviews' WHERE gallery_id='$id' 

That will add to the views without overwriting the current entry

AN-net 02-08-2004 04:27 PM

dont need to use $gallery[gallery_views]?

assassingod 02-08-2004 04:28 PM

I wouldn't, infact if you only want to add 1 view, i'd use:
PHP Code:

$fgall$DB_site->query("SELECT gallery_index.gallery_views,gallery.gallery_id,gallery.image_id,gallery.image_url,gallery.image_des,gallery.image_views,gallery.image_rating,gallery.image_date FROM gallery,gallery_index WHERE gallery_index.gallery_views='$id'"); 
$gallery$DB_site->fetch_array($fgall);  
$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 04:58 PM

thanks;)
ill update the thread as experience more evil problems>_<

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

darn still aint adding 1 to the view T_T

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') . '";');    
    
$DB_site->query("UPDATE gallery_index SET gallery_views='$gallery[gallery_views]+1' WHERE gallery_id='$id'");
}
eval(
'$navbar .= "' fetch_template('navbar') . '";');
eval(
'print_output("' fetch_template('gallery_gal') . '");');



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

AN-net 02-12-2004 12:41 AM

well i fixed my insert query, it turns out by sending it to gallery.php?do=insert didnt work because when the forum is submitted it wrote a new url called gallery.php?etc. without a do=insert; so basically that was the prob. i have 2 other questions, ive seen in hacks that people use like "type the forum ids you wish to exclude with commas inbetween each", how does that work, i can only thing of something equalling one thing. also the book i have for php doesnt explain how to order things or grab the last entry of sumthing. can someone explain that to me?

AN-net 02-13-2004 03:20 AM

can anyone help with the mentioned above?

AN-net 02-14-2004 02:59 PM

can someone explain to me why this doesnt work:
PHP Code:

if ($bbuserinfo[usergroupid]==6) { 
            eval(
'$submitgal .= "' fetch_template('gallery_subbutton') . '";');
        } 

and plz also explain what i posted 2 posts up

Dean C 02-14-2004 04:06 PM

PHP Code:

if ($bbuserinfo['usergroupid'] == 6)
{
            eval(
'$submitgal = "' fetch_template('gallery_subbutton') . '";');


That should work. If it doesn't something else is conflicting with it :)

AN-net 02-14-2004 05:21 PM

thanks dean:D

edit:
didnt work>_<

could it be because $submitgal is grabbing a template and then im using $submital in another template to call $submitgal's template?

AN-net 02-15-2004 02:16 AM

anyone know how i could grab the last image added to a gallery(kinda like vb's last post)? and i see in a lot of hacks people say user groupid's who can view: 6,5,4
i dont get how commas create multiple conditions
so is the hack in php basically
PHP Code:

if($whocanview==6,5,4){
blah blah


?

Dean C 02-15-2004 08:07 AM

PHP Code:

if(in_array($bbuserinfo['userid'], array(4,5,6)))
{
blahblah();



AN-net 02-15-2004 12:55 PM

cool thanks ill try it out and post if it works but i still dont get y the usergroup if statement wont work>_<
edit:
im confused, what do i use the blahblah(); thing for?

Dean C 02-15-2004 01:08 PM

It's called pseduo code - just put the code in there that you want based on the if condition :)

AN-net 02-15-2004 01:53 PM

hmm its giving me a parse error on line 33.
PHP Code:

31:        if(in_array($bbuserinfo['usergroupid'], array(4,5,6))) 
32:            { 
33:                submitbutton(eval('$submitgal .= "' fetch_template('gallery_subbutton') . '";');); 
34:        } 

edit:
also anyone know or have any good tutorials or suggestions on how to do pagination?

assassingod 02-15-2004 03:54 PM

You don't need that . infront of the =. And what's this 'submitbutton' infront of the eval?

AN-net 02-15-2004 05:58 PM

Quote:

Originally Posted by assassingod
You don't need that . infront of the =. And what's this 'submitbutton' infront of the eval?

xeon in another thread told me to add the . before the = sign
also the submitbutton(); replace blahblah(); , see dean's post

assassingod 02-15-2004 06:04 PM

Quote:

Originally Posted by AN-net
xeon in another thread told me to add the . before the = sign
also the submitbutton(); replace blahblah(); , see dean's post

You only need that if you are looping a template. And that submitbutton() is not needed, Dean used blahblah(); as sample code to show where the real code will go - its not needed.

AN-net 02-15-2004 06:58 PM

oh, ok.
ok i added my own search engine to my gallery, but now im getting parse error on line 180.
this is 180:
PHP Code:

?> 

edit:
found it, i forgot a }(silly me :D)

assassingod 02-15-2004 06:58 PM

You may have forgotten a ; or a } somewhere in the file.

AN-net 02-15-2004 07:07 PM

yeah i figured that out, thanks for the help though.
now i added a results page to my search engine thingy but it only shows this:
HTML Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
<BODY></BODY></HTML>

this is my php code:
PHP Code:

if($show==searchresults){
$fresults$DB_site->query("SELECT * FROM gallery WHERE gallery_id='$gallery' OR image_name='$imgname' OR artist_name='$artistname$orderby $orderin");
$numresults$DB_site->num_rows($fresults);
if(
$numresults==0){
    
$navbits = array();
    
$navbits["#"] = "Gallery";
    
$navbits["gallery.php?view=index"] = "Gallery Index";
    
$navbits["#"] = "Search";
    
$navbits[''] = "Search Results";
    
$navbits construct_navbits($navbits);
eval(
'$navbar = "' fetch_template('navbar') . '";');
eval(
'print_output("' fetch_template('gallery_search_results_none') . '");');
}
else{
while(
$results$DB_site->fetch_array($fresults)){
    
$imagedate=date("m/d/Y - g:i A",$results[image_date]);
    eval(
'$resultsbits .= "' fetch_template('gallery_search_resultsbits') . '";');
}
    
mysql_free_result($fresults);
    
$navbits = array();
    
$navbits["#"] = "Gallery";
    
$navbits["gallery.php?view=index"] = "Gallery Index";
    
$navbits["#"] = "Search";
    
$navbits[''] = "Search Results($numresults)";
    
$navbits construct_navbits($navbits);
eval(
'$navbar = "' fetch_template('navbar') . '";');
eval(
'print_output("' fetch_template('gallery_search_results') . '");');
}


this is whats in the templates:
gallery_search_results:
HTML Code:

$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
        <title>$vboptions[bbtitle] - Gallery Search Results:($numresults)</title>
$headinclude
</head>
<body>
$header
$navbar
<br />
<table class="tborder" align="center">
<tr class="tcat">
<td>Search Results for:$imgname&nbsp;&nbsp;$artistname</td>
</tr>
$resultsbits
</table>
<br />
$footer
</body>
</html>

gallery_search_resultsbits:
HTML Code:

<tbody>
<tr>
<td class="tcat" colspan="3">$results[image_name]</td>
</tr>
<tr class="thead">
<td>Thumbnail</td>
<td>Artist Name</td>
<td>Date Added</td>
</tr>
<tr>
<td clas="al2"><a href="gallery.php?view=entry&id=$results[gallery_id]&imgid=$results[image_id]" alt"Click to see full size image of $results[image_name]"><img src="$results[image_url]" alt="Click to see full size image of $results[image_name]" length="40" width="40" border="0"></a></td>
<td class="alt1">$results[artist_name]</td>
<td class="alt2">$imagedate</td>
</tr>
</tbody>

and this is whats in the search template:
HTML Code:

$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
        <title>$vboptions[bbtitle] - Gallery Search:</title>
$headinclude
</head>
<body>
$header
$navbar
<br />
<form action="gallery.php?show=searchresults" method="post">
<table class="tborder" align="center">
<tr class="tcat">
<td align="center" colspan="2"><font size="2"><b>Search Gallery</b></font></td>
</tr>
<tr>
<td class="alt1">
<fieldset>
<legend>Search by Image Name</legend>
<table>
<tr>
<td><input type="text" name="imgname" value="" size="20"></td>
</tr>
</table>
</fieldset>
</td>
<td class="alt2">
<fieldset>
<legend>Search by Artist Name</legend>
<table>
<tr>
<td><input type="text" name="artistname" value="" size="15"></td>
</tr>
</table>
</fieldset>
</td>
</tr>
<tr class="thead">
<td colspan="2">Additional Searching Options</td>
</tr>
<tr>
<td class="alt1">
<table>
<tr>
<td>
<fieldset>
<legend>Order Search Results by:</legend>
<table>
<tr>
<td><select name="orderby">
<optgroup label="orderbytypes">
<option value="ORDER BY gallery.gallery_id" SELECTED>Gallery</option>
<option value="ORDER BY gallery.image_name">Image Name</option>
<option value="ORDER BY gallery.image_date">Image Date</option>
<option value="ORDER BY gallery.arist_name">Artist's Name</option>
</optgroup>
</select>
</td>
</tr>
</table>
</fieldset>
</td>
</tr>
<tr>
<td>
<fieldset>
<legend>Order Results in:</legend>
<table>
<tr>
<td><select name="orderin">
<optgroup label="orderins">
<option value="DESC" SELECTED>Descending</option>
<option value="ASC">Ascending</option>
</optgroup>
</select>
</td>
</tr>
</table>
</fieldset>
</td>
</tr>
</table>
</td>
<td class="alt2">
<fieldset>
<legend>Search in Gallery</legend>
<table>
<tr>
<td><select name="gallery" size="5">
<optgroup label="galleries">
$listgalleries
</optgroup>
</select>
</td>
</tr>
</table>
</fieldset>
</td>
</tr>
<tr class="thead">
<td colspan="2" align="center"><input type="submit" value="Search Now"></td>
</tr>
</table>
</form>
<br />
$footer
</body>
</html>


AN-net 02-15-2004 09:41 PM

ok suddenly i cant view source anymore for web pages(i know this isnt php,html,etc.). im using windows anyone know how to reactivate it?

Andreas 02-15-2004 09:50 PM

www.mozilla.org ;)

OK, if you want to stick with Internet Exploder (which I wouldn't recommend):
http://www.winguides.com/registry/display.php/1246/
http://support.microsoft.com/default...;EN-US;Q306907

Thanks fly out to Google ;)

AN-net 02-15-2004 10:00 PM

Quote:

Originally Posted by KirbyDE
www.mozilla.org ;)

OK, if you want to stick with Internet Exploder (which I wouldn't recommend):
http://www.winguides.com/registry/display.php/1246/
http://support.microsoft.com/default...;EN-US;Q306907

Thanks fly out to Google ;)

thanks alot, turns out i had to much of temperary files in my temp folder lol

AN-net 02-16-2004 11:02 PM

can anyone help me with my results page?


All times are GMT. The time now is 02:06 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.01563 seconds
  • Memory Usage 1,952KB
  • 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
  • (6)bbcode_html_printable
  • (21)bbcode_php_printable
  • (4)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
  • (40)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