PDA

View Full Version : getting some errors


AN-net
02-07-2004, 11:09 PM
ok trying to code this but its being evil!

if($view==gal){
$fgall= $DB_site("SELECT gallery_index.gallery_views,gallery.gallery_id,gal lery.image_id,gallery.image_url,gallery.image_des, gallery.image_views,gallery.image_rating,gallery.i mage_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:

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

$fgall= $DB_site->query("SELECT gallery_index.gallery_views,gallery.gallery_id,gal lery.image_id,gallery.image_url,gallery.image_des, gallery.image_views,gallery.image_rating,gallery.i mage_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:

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:

$fgall= $DB_site->query("SELECT gallery_index.gallery_views,gallery.gallery_id,gal lery.image_id,gallery.image_url,gallery.image_des, gallery.image_views,gallery.image_rating,gallery.i mage_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:

if($view==gal){
$fgall= $DB_site->query("SELECT gallery_index.gallery_views,gallery.gallery_id,gal lery.image_id,gallery.image_name,gallery.image_url ,gallery.image_des,gallery.image_views,gallery.ima ge_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:

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:

if($view==gal){
$fgall= $DB_site->query("SELECT gallery_index.gallery_views,gallery.gallery_id,gal lery.image_id,gallery.image_name,gallery.image_url ,gallery.image_des,gallery.image_views,gallery.ima ge_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:

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','$imgu rl','$imgdes')");
}


heres the form i used:

<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
if($view==gal){
$fgall= $DB_site->query("SELECT gallery_index.gallery_views,gallery.gallery_id,gal lery.image_id,gallery.image_name,gallery.image_url ,gallery.image_des,gallery.image_views,gallery.ima ge_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

$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

gallery_views=gallery_views+1

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

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

if($do==insert){
$image_date= time();
$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_dat e')");
}


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

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

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

?

Dean C
02-15-2004, 08:07 AM
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.

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

?>

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:

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

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:

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

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

$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.aspx?scid=kb;EN-US;Q306907

Thanks fly out to Google ;)

AN-net
02-15-2004, 10:00 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.aspx?scid=kb;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?

AN-net
02-18-2004, 01:06 AM
please can someone help me:(

AN-net
02-18-2004, 06:07 PM
table problem. ok i want only want it to repeat the template 3 times per row, so how do i get it to that?
see attachment for my prob

Dean C
02-18-2004, 06:28 PM
Please don't bump your thread any more. Thanks.

AN-net
02-18-2004, 06:36 PM
i wasnt bumping, i was posting another problem i have. sorry ill just wait till someone replies next time to post another prob of mine. im sorry :(

AN-net
02-22-2004, 03:29 PM
can someone plz help me fix my search results page? cause it wont work for me at all>_<
is it possible i grabbed to many templates in one php file?