![]() |
variables in php files
I'm having a slight issue with a script I'm making. And I'm wondering if something very simple I'm missing. Right now the code is hard coded into the php file, and so is the settings. The problem is with a vairable. It's pulling a list of the last X members from the database.
The problem is that when using a variable ex: $grabbedmembers It doesn't work in the SQL call. Variable is empty even though near the top of the php file I have $grabbedmembers = 5 But if I just replace the variable with the number in the SQL call it works. Do all variables in php file need to be register before working? Or just variables that will be used in templates? |
Post your code and we'd be able to help better. Variables need to be registered for use in templates not in the php files.
|
Here;s the one for the last few threads:
Code:
$Zforum = 5; |
Have you tried passing the variable to the function.
PHP Code:
|
$a_var remains empty. For some reason I can't get it to store any value what so ever. Although works fine in vb3.8. Thre must be something new in vb4 causing the problem
|
just before your mysql query, put:
PHP Code:
if the result was correct, some code in between is messing up with this variable |
Quote:
OK I figured it out. Wow programming in vb4 did add something new to the variables. I figured it out. It was just a delaration inside the funtion. Once added it worked flawlessly. Thx everyone for helping. |
In your first code, $Zforum was not in the scope!
You can't use variables inside a function which are declared outsite withouth an global ;) PHP Code:
|
Quote:
|
Quote:
Youre code will also work, i showed him just another possible code. |
Unfortunately, he said my code didn't work. So, I don't know that making it global would fix whatever is wrong either.
|
Ragtek is right. Doing a global declaration make it work perfectly. That was all that way needed. The code was based off of his newportal he made on vbgermany. After learning by his coding I was able to make a few mods from it. Basically a catergory listening for different forums. I wanted it hard coded becuase all I wanted to do was uploading the file and don't have to ever worry about it also now have even possible plugins that may interfere with other mods.
--------------- Added [DATE]1259286815[/DATE] at [TIME]1259286815[/TIME] --------------- How do I changed the query to pull threads from all forums? |
do you want all threads from all forums?
PHP Code:
I wanted to do everything with oop^^ Without oop it's much easier;) --------------- Added [DATE]1259302740[/DATE] at [TIME]1259302740[/TIME] --------------- Also this would work: PHP Code:
PHP Code:
|
Quote:
I learn alot from it though and was able to clean up some of the and add a few things. |
All times are GMT. The time now is 04:28 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 | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|