Previous Thread
Next Thread
Print Thread
Rate Thread
#272099 04/08/2004 4:32 PM
Joined: Apr 2002
Posts: 474
Enthusiast
Enthusiast
Offline
Joined: Apr 2002
Posts: 474
I added this to the area in addpost.php
The Last item "B_FMVersion" and "$fmversion"

Early in the script the $fmversion is defined... but it the value is empty when I look at the db.



$query = "
INSERT INTO {$config['tbprefix']}Posts (B_Board,B_Parent,B_Main,B_Posted,B_Last_Post,B_IP,B_Subject,B_Body,B_Kept,B_Status,B_Approved,B_Icon,B_Reged,B_Poll,B_Replies,B_Topic,B_Convert,B_PosterId,B_AnonName,B_Sticky,B_ParentUser,B_CalDay,B_CalMonth,B_CalYear,B_AddSig,B_FMVersion)
VALUES ('$Board_q','$Parent','$Main','$date','$date','$IP_q','$Subject_q','$BodySig','$Kept_q','$PStatus_q','$Approved_q','$Icon_q','$Reged_q','$PollId','0',$MainTopic,'$convert_q','$posterid','$AnonName_q','$Sticky','$ParentUser','$calday','$calmonth','$calyear','$addsig','$fmversion')
";

Sponsored Links
sdf123 #272100 04/08/2004 5:50 PM
Joined: Dec 2000
Posts: 1,471
Addict
Addict
Offline
Joined: Dec 2000
Posts: 1,471
This snipptet looks ok, so the error should be where you define your $fmversion.

Put
error_reporting(15);

at the top of your script and see if any warnings occur.

Joined: Apr 2002
Posts: 474
Enthusiast
Enthusiast
Offline
Joined: Apr 2002
Posts: 474
i hadn't noticed any errors.

this is where i define the variables



$fmversion = get_input("fmversion","post");
$fmplatform = get_input("fmplatform","post");

sdf123 #272102 04/09/2004 6:59 AM
Joined: Dec 2000
Posts: 1,471
Addict
Addict
Offline
Joined: Dec 2000
Posts: 1,471
You could echo out these two variables right before the insert statement:

echo "fmversion: " . $fmversion:
echo "fmplattform: " . $fmplattform;

and you can do a
print_r($_POST);

to see what variables are available from the form.

I assume that they are just an empty string.
So the problem maybe the form where these values are set.

Joined: Apr 2002
Posts: 474
Enthusiast
Enthusiast
Offline
Joined: Apr 2002
Posts: 474
the values are coming from their profile.
(josh added 2 fields in the user file.)

Sponsored Links
sdf123 #272104 04/09/2004 6:03 PM
Joined: Oct 2000
Posts: 2,223
Veteran
Veteran
Offline
Joined: Oct 2000
Posts: 2,223
How are they scoped? Are they available to that particular piece of code? Astaran had the best idea, echo them out to screen just before you try to use them. See if they are empty values, undefined, or - if they have a value what that value is.


Picture perfect penmanship here.
zerind #272105 04/09/2004 8:36 PM
Joined: Apr 2002
Posts: 474
Enthusiast
Enthusiast
Offline
Joined: Apr 2002
Posts: 474
AARG... I guess this is over my head?!


The data is set from their profile. And they can choose to change it when they
create a post. So I think the data is coming from the previous script newpost.php
and pulled from the profile.

I am not really certain what you mean by echo out the code?!

sdf123 #272106 04/09/2004 11:33 PM
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
He has a pull down box on the new post page - which let's the user choose the version number, and then it appends it to the front of the subject in addpost.

Stephen - I checked your code and it IS working correctly if you post without preview. The reason it doesn't work if you preview is because the form that you post from after preview is no longer passing the $fmversion variable (because after we appended it to the subject, you didn't need it.

So what you did to add it to the DB is fine - but to make sure it doesn't get lost if the user previews - you need to add the variable to the addpost_preview.tmpl

Like this:

<input type="hidden" name="fmversion" value="$fmversion" />


To all the hidden variables near the top of the form AND the hidden variables in the second form on that page - so if they edit more than once the variable still gets passed.

Then it gets added to the DB.

But then - since the addpost script will also append their usernumber to the end of their post - if they preview more than once, it keeps adding it.

So we add a second variable to "switch off" adding this each time it comes from the addpost_preview.tmpl So to BOTH forms in addpost_preview.tmpl, I added this as well:

<input type="hidden" name="noversion" value="1" />


Then add a get_input call for noversion using post.

And modify the code at the top from this:
Code
<br />if (($fmversion) && (!$Parent)) {<br />	$Subject = "[$fmversion] ".$Subject;<br />}<br /><br />if ($fmversion)  {<br />$Body = $Body."\n\nFileMaker Version: $fmversion";<br />}<br />if ($fmplatform) {<br />	$Body = $Body."\nPlatform: $fmplatform";<br />}	<br />


to this:
Code
<br />if (($fmversion) && (!$Parent) && (!$noversion)) {<br />	$Subject = "[$fmversion] ".$Subject;<br />}<br /><br />if (($fmversion) && (!$noversion))  {<br />$Body = $Body."\n\nFileMaker Version: $fmversion";<br />}<br />if ($fmplatform) {<br />	$Body = $Body."\nPlatform: $fmplatform";<br />}	<br />




So take a look at what I did to fix it - should be working now.

Daine #272107 04/10/2004 2:39 AM
Joined: Apr 2002
Posts: 474
Enthusiast
Enthusiast
Offline
Joined: Apr 2002
Posts: 474
Thank you Josh there is a dim flicker of light starting to float above my head.
Or I am just delirious.

It is working. Along w/ the replace function (How To) post I made I decided to take out the
prepending the subject as people were complaining that they have to visual acrobatics
to read the subject. Since I am capturing the data in a field at a later point when i am
fully caffeinated I will look into adding this field in the display perhaps in the search and in the postlist.

Thanks for taking the time to explain it...

BTW what book do you recommend for beginners to learn the basics of SQL syntax?

sdf123 #272108 04/10/2004 3:05 AM
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
I enjoyed PHP Cookbook from O'Reilly Press, that was a pretty basic overview. Then MySQL/PHP Database Applications by Jay Greenspan and Brad Bulger was a bit more indepth, but it's handy for reference and I still refer to that one regularly for syntax etc....

Sponsored Links
Daine #272109 04/10/2004 3:50 AM
Joined: Apr 2002
Posts: 474
Enthusiast
Enthusiast
Offline
Joined: Apr 2002
Posts: 474
Thanks


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)