![]() |
Noobie array help, please.
Hi,
This should be easy but I'm not sure where to go from here. I made a "search.php" file that queries a mySQL db and I want the result to be shown in a VB template. So, I have succesfully duplicated the vb template: (I won't show all the code b/c you all know what it looks like, but for reference it's this I'm talking about) : PHP Code:
After the above code, I connect to the database and run a query. I have the results stored in a recordset like this: PHP Code:
How do I store that into some vb variable so I can access it in the HTML template later? Something like this? $array= construct_navbits($array); Thanks. |
No, you'll do like this
Code:
$myarray = get_ranges("..."); Although if you're using the vBulletin database, there's a better way of executing the query than what you're using... |
You want to use the vBulletin database class instead (as it also does MySQLi).
PHP Code:
|
Thank you both.
Dismounted: quick question. I'm not trying to trick you into writing the code for me, but I need a bit of help, please. My query is fine, but if you'd like to see it here it is: PHP Code:
PHP Code:
Thank you. |
Man you weren't kidding when you said "noobie". You've got it backwards. Your query could be improved too...
PHP Code:
Alternatively... PHP Code:
|
PHP Code:
|
Dismounted, do you really think that $state is a user inputted variable?
|
User-input or not, it needs to be cleaned beforehand.
Hypothetical: Assume it was added by Admins through the Admin CP. Unknowing Admin uses single quotes. Bam! Your query fails. |
True, but this guy is making a $query variable instead of inlining the string. I think he's done the same thing with something in the $state variable.
But I guess it's better to be safe than sorry. :) |
Hi guys,
Well, my SQL is fine since I actually did sql injection prevention before the query..but in regards to the other codes, they are causing the php page to turn blank, which means there is an error... Tiger: I think the reason why yours is doing it is because you can't echo within the php file, since its meant to display the template. Dismounted: I'm not sure why yours isn't working either. ...still grateful for the help so far!! |
All times are GMT. The time now is 08:58 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:
|