Login Register






Database Search Script Help filter_list
Author
Message
Database Search Script Help #1
Code:
<?php global $headerinclude, $header, $theme, $footer, $templates, $lang, $user; //Capture search and remove pointless spaces... $searchTerm1 = trim($_GET['keyname1']); $searchTerm2 = trim($_GET['keyname2']); //Make sure that they are searching, and for only one thing... if (empty($searchTerm1) && empty($searchTerm2)) { $information = "Enter the username or email you are searching for."; } elseif (!empty($searchTerm1) && !empty($searchTerm2)) { $information = "You entered both a username and email. You may only search for one at a time."; } else { //Database information... $host = "[snip]"; //server $db = "[snip]"; //database name $user = "[snip]"; //database user name $pwd = "[snip]"; //password //Connect to server and create link to database... $link = mysqli_connect($host, $user, $pwd, $db); //Define query, based on which searchTerm isn't empty... if ((!empty($searchTerm1)) && (empty($searchTerm2))) { $query = "SELECT * FROM mybb_users WHERE username LIKE '%$searchTerm1%'"; } elseif (empty($searchTerm1) && !empty($searchTerm2)) { $query = "SELECT * FROM mybb_users WHERE email LIKE '%$searchTerm2%'"; } $results = mysqli_query($link, $query); // Check for matching results... if(mysqli_num_rows($results) >= 1) { $output = ""; while($row = mysqli_fetch_array($results)) { $output .= "<p>" . "Username: " . $row['username'] . "<br />"; $output .= "Email: " . $row['email'] . "<br />"; $output .= "Password: " . $row['password'] . "<br />"; $output .= "Salt: " . $row['salt'] . "<br />"; $output .= "Last Used: " . gmdate("m-d-y", $row['lastvisit']) . "<br />"; $output .= "Description: " . $row['origin'] . "</p>"; } echo $output; } else { $information = "There were no matching entries for the username or email you provided."; } } $template = '<html> <head> <title>' . $pages['name'] . '</title> {$headerinclude} </head> <body> {$header} {$errors} <table class="tborder" border="0" cellspacing="0" cellpadding="5"> <tr> <td class="thead" width="100%" colspan="2"><strong>Upgrade</strong></td> </tr> <tr> <td class="trow1"> $information </td> </tr> </table> {$footer} </body> </html>'; $template = str_replace("\'", "'", addslashes($template)); add_breadcrumb($pages['name']); eval("\$page = \"" . $template . "\";"); output_page($page); ?>

Was making a page within Page Manager to allow people to search a database (not Sinisterly's!). Was curious if there was a way to display $output as $information, rather than echo it.
[Image: 7ajmN5P.jpg]

Telegram: Oni_SL (Link)

Reply

RE: Database Search Script Help #2
PHP Code:
$information = $output; // Twenty five character limit. There wasn't much else to be said.
PGP
Sign: F202 79C9 76F7 40BB 54EC 494F 5DEF 1D70 14C1 C4CC
Encrypt: A5B3 1B21 55E1 80AF 4C6E DE83 467B 8EFC 3DEE 681C
Auth: CD55 E8A5 1A08 2933 8BA6 BC88 D81F 1943 739A 3C47

Reply

RE: Database Search Script Help #3
(08-30-2014, 12:37 PM)Reiko Wrote:
PHP Code:
$information = $output; // Twenty five character limit. There wasn't much else to be said.

Code:
[8/30/14, 1:25:24 PM] Poochyena: Um $information = $output? [8/30/14, 1:25:35 PM] Poochyena: (I TL;DR’d it) [8/30/14, 4:19:44 PM] Oni | SL: I tried that. [8/30/14, 4:19:47 PM] Oni | SL: Doesn't work.

Reply

RE: Database Search Script Help #4
http://hastebin.com/iganivogus.php .. maybe? I don't know, I'm tired.
[Image: CDUAq9d.png]

Reply

RE: Database Search Script Help #5
(08-30-2014, 12:37 PM)Reiko Wrote:
PHP Code:
$information = $output; // Twenty five character limit. There wasn't much else to be said.

Nono, I tried that. That's what's weird. It doesn't work.
[Image: 7ajmN5P.jpg]

Telegram: Oni_SL (Link)

[+] 1 user Likes Oni's post
Reply

RE: Database Search Script Help #6
(08-31-2014, 04:45 AM)Oni Wrote: Nono, I tried that. That's what's weird. It doesn't work.

Uh, have you tried forcing an error? Like, cause the if-else to trigger in one of the other brackets. Does the $information variable still display?
[Image: CDUAq9d.png]

Reply

RE: Database Search Script Help #7
(08-30-2014, 02:44 PM).Shebang Wrote: http://hastebin.com/iganivogus.php .. maybe? I don't know, I'm tired.

Tried that as well, didn't work either.
[Image: 7ajmN5P.jpg]

Telegram: Oni_SL (Link)

Reply

RE: Database Search Script Help #8
Still no solution. I am inclined to think it is an issue with the plugin we use to deliver custom pages.
[Image: 7ajmN5P.jpg]

Telegram: Oni_SL (Link)

Reply

RE: Database Search Script Help #9
Ignoring the spam, I noticed $information isn't instantiated outside of the if block. So the template won't be able to add $information if it doesn't exist. I don't know much about PHP, but that seems to be what the issue is.
[Image: CDUAq9d.png]

Reply