This little snippet will teach you all about arrays and arrays of arrays, and so on and so forth.
Troy commented: Helpful post with high-quality code example and comments. +1
This little snippet will teach you all about arrays and arrays of arrays, and so on and so forth.
No no no...it's
<?php echo 'Foo Bar :P'; ?>
Oh, I get it. It just stores a list of variables and values and replaces accordingly. Not really what I wanted, but I guess it'll have to do. It's good to know something like that exists, thanks.
execute is a PHPBB-specific function which probably uses eval() anyway (going to php.net/execute doesn't exist, and exec() executes shell commands on Linux). And what do you mean by 'trace' them?
I'm writing a CMS-style application, and I can't quite figure out templating.
I have a function that returns the file contents of a templaet file within a themes directory. That part works fine. Inside one of those files is a mix between HTML and PHP variables, for example:
<html>
<title>$title</title>
<link href="$theme['css-path']" type="text/css" rel="stylesheet">
...
</html>
<!-- Just an example. ;) -->
And no matter what combination of eval(), echo and variables I use, I simply cannot get the correct page output WITH the variables parsed. I'm really puzzled... and I know it's possible, just look at vBulletin or MyBB. There are variables in those template files and that software works perfectly.
Any tips on templates would be greatly appreciated.
No, this is a browser feature and there isn't anything you can do to stop it from happening. The browser is just detecting some data that you have already sent, and when you go back, it wants to know if maybe you want to resend the data or not. There's nothing in PHP you can do to prevent this from happening, unless you change your script to not use post data (which I do not recommend).
This is a really strange bug...
I'm doing a 'game' of sorts for Computer Science, and it works wonderfully. We have a main method that initializes things and starts the game loop. The game itself works when GUI.java is executed.
Every method call in the main method is static.
Now, the odd thing is that when that exact same code (copy and paste) is run from a different class, and either executed statically, or even when creating a new object and using that as a reference, both JFrames show up as necessary, but they are EMPTY. Big gaping transparent holes of nothing.
Can someone explain this phoenomenon?
FYI: Here's the main method I'm referring to:
// In class GUI:
public static void main(String[] args) {
init(); //static
Console.run(frame, 808, 635); //Console class is static, frame is static
panel.paintLevel(); // static
panel.paintLevel(); // static
frame.run(); // static
}
And when called externally, either this:
// In External Class:
GUI.init();
Console.run(GUI.frame, 808, 635);
GUI.panel.paintLevel();
GUI.panel.paintLevel();
GUI.frame.run();
or this
// In External Class:
GUI gui = new GUI();
gui.init();
Console.run(gui.frame, 808, 635);
gui.panel.paintLevel();
gui.panel.paintLevel();
gui.frame.run();
does the transparent frame effect.
Let me know if you need more information.
Sorry, that didn't work. In fact, nothing changed about the program. Any other ideas?
I'm learning Java right now, and one of the projects I've been working on as practice lately is just a simple text editor (using Swing). The one thing, though, that I can't for the life of me figure out, is how to add scroll bars to the text box if the text overflows.
Here's some of my code (There's way more, I just simplified what I have right now that makes the frame and text box):
JTextArea t;
JFrame f;
JPanel c;
JScrollPane b;
b = new JScrollPane();
b.setAutoscrolls(true);
f = new JFrame("JNotepad");
f.setBounds(300, 200, 500, 500);
c = new JPanel();
f.setContentPane(c);
t = new JTextArea();
t.setFont(Font.decode("Courier New-14"));
b.add(t);
c.add(b);
f.setJMenuBar(/* Menu bar is "m". This works just fine. */m);
f.setVisible(true);
A little sloppy, I know, but I had to copy and paste and reorganize it from the rest of my code. I can honestly say I don't even have a remote idea as to how you add scroll bars, what's there is just a guess. The notepad works, but the scrollbars don't.
I also have an anaonymous inner class designed to resize the textbox to the size of the form if the mouse is moved over it, because I didn't know how else to do it (there was no "onResizeForm" event, was there?), so if that's interfering, well, let me know and I'll figure something out.
I'm writing a program to communicate with my Cisco switch via COM port using MScomm. I've gotten it to work perfectly, with one exception.
If you've ever dealt with Cisco software before, you know that if there's a long list of things, it wil display "--More--" prompting you to scroll down and recieve the rest of the data. It works just fine, except some of the data gets lost. Here's a reference:
*** Before pressing <spacebar> to retrieve more data: ***
show logging Show system logging information
show mac Show MAC information
--More--
Everything is fine, "More" is displayed and it's telling me there's more data. Fine. *press Spacebar*
*** After pressing <spacebar>: ***
show logging Show system logging information
show mac Show MAC information
--More-- crocode Show microcode versions
show module Show module information
show multicast Show multicast information
Now, before you say anything, please keep in mind that I've already figured out the "". That entire string is a backspace sequence designed to tell you how many characters to backspace. In this case, it tells you to backspace 8 characters to remove the "--More--". I already have this figured out, this is not the problem. But, if we remove the "More" and the backspace sequence, look what we have:
show logging Show system logging information
show mac Show MAC information
crocode Show microcode versions
show module Show module information
show multicast Show multicast information
We're missing data. It SHOULD read:
show logging Show …
Hello everyone.
I have a page that echos success on a successful login, and I want it to then sleep(2); and then redirect to another page. Unfortunately and obviously, the headers are already sent if I'm in the body of the page. So, is there a way (with any language, javascript, mabe?) to redirect after the header information has already been sent? Thanks!
Umm...Yeah, you kinda forgot a " in there, that's why the code looks all messed up. StrikeFreedom, don't copy and paste that, it's not right, anyway. I haven't done a "search" in a database, per se, but I would definately thing that you need to have the user select either if they're searching Artist, Title, or Content, and another thing, what are the "%"'s for?
Should you be selecting the Selex database all the time, or do you want both?
mysql_select_db("selex", $dbcnx);
Microsoft Word Documents are nothing but text underneath a ton of formatting. Just use fopen() or fread() to put it in a variable, then search through it.
If you want a free one, here's a nice list of names:
Sorry if I can't give you links, just Google them, that'll be fine.
Gah! Did I misread (happens a lot), or did we forget the trusty and classic Visual Basic 6?
Option Explicit
Private Sub Form_Load()
Print "Hello, World! in VB6"
End Sub
I know why you're complaining about your POST variables not working, heh!
NEVER do and IfThen Statement with ONE equals sign. This will always evaluate the statement to be true. Do this instead:
<?php
if ($_POST['COL'] !== 'All') {
};
?>
Heh, hope it works now! =)
Right, in the first few lines, I have a few comments.
Firstly, you cannot do this:
<?php -CODE HERE- php?>
// The above example is WRONG. You can do either of the following:
<?php -CODE HERE- ?>
--or--
<? -CODE HERE- ?>
// for code snippets, or...
<?=$var ?>
// to echo a variable.
Second, the reuire_once function was called incorrectly. Here's how to do it:
<?php
require_once('Pager.php');
// ^-----------^---Note the parenthesis. =)
?>
Lastly, your POST variable is called wrong. Try this:
$sql = "SELECT title,year
FROM document AS doc
WHERE year between 1995 and 2005
AND category='" . $_POST['category'] . "';";
Hope my tips helped you. =)
Is there a really simple mod out there for creating subforums? Specifically for 2.0.16
Ummm...Can you specify which forum software you're using? vBulletin has the feature implemented already, but I'm not sure about others.
If you have any useless stuff in headers, like for example....
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"> get rid of it... for some reason it worked for me.
Ahh, yes, that's right, many HTML editing programs, such as Macromedia Dreamweaver add that to every page, so removing it (since it is a header) will allow the Location Header to be sent, even with a relative link.
Gah! Your PHP Code is an absolute disaster, sorry to say, and it hurts my eyes. This might help:
<?php
// Here is the code from my processing page that redirects it:
$user = $_REQUEST['username'];
$pass = $_REQUEST['password'];
$logintype = $_REQUEST['logintype'];
// Gah! ALWAYS, when using preset variables, use
// single quotes inside brackets. PHP is more friendly,
// that way :P Also, are you trying to get this data
// from a form? You might want to change these to POST,
// and set the form in your HTML page to be POST, as well,
// but for now I'll just leave them as they are.
if($pass == '') {
// There is no point using preg if you're going to search for
// a-z and A-Z, it's easier to just use if($pass == '').
$error = 1;
};
if($error == 0) {
if ($logintype == 'admin') {
header('Location: ../LoginAdmin.php?loginresult=badlogin');
// include("../LoginAdmin.php" );
// Why are you including a page here? You've already
// been redirected to the other page!
exit;
// The 'exit;' command does not have parameters, therefore
// do not put parenthesis () after it.
};
exit;
};
?>
If you are not being redirected to that page, you are doing something wrong, and by the looks of your PHP code, you are. :confused:
Also, if this is a user authentication form, I'd suggest using a database with usernames and passwords, simply testing if the user has entered a password is not secure at all, …
Oh, shoot, we're both wrong, heh! ;)
This will most DEFINATELY work.
<?php
if (isset($_POST['add'])) {
include ('config.php');
include ('opendb.php');
mysql_select_db('DB_NAME', $mysql);
// You must tell it what the connection resource is, as well
// as which databse you will be using. Make sure that in opendb.php,
// the function mysql_connect(); is being set to $mysql.
$username = $_POST['username'];
$password = $_POST['password'];
$query = "INSERT INTO user (host, user, password, select_priv, insert_priv, update_ priv) VALUES ('localhost', '" . $username . "', 'PASSWORD(" . $password . "'), 'Y', 'Y', 'Y')";
// You need to concatenate with the '.' command.
// I know this will work, I've used it hunderds of times.
mysql_query($query) or die('Error, insert query failed ');
$query2 = "FLUSH PRIVILEGES";
mysql_query($query2) or die('Error, insert query failed');
include ('closedb.php');
echo "New MySQL user added";
} else {
?>
<html><body>
<form method="post">
<table width="400" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="100">Username</td>
<td><input name="username" type="text" id="username"></td>
</tr>
<tr>
<td width="100">Password</td>
<td><input name="password" type="text" id="password"></td>
</tr>
<tr>
<td width="100"> </td>
<td> </td>
</tr>
<tr>
<td width="100"> </td>
<td><input name="add" type="submit" id="add" value="Add New User"></td>
</tr>
</table>
</form></body></html>
Is there a way to do sigs? I tries to look in the profile thing, and
nothing is listed...
You haven't earned the right yet, all of yuor posts are spam.
Ahh, that helps greatly. Thanks!
I've been thinking for awhile now that I should code a nice news system, and I have the structure all figured out, but what stumped me was: How do you display the articles with the latest first?
I would set up a MySQL table with columns Title, Date&Time, Body, ID, Author, Source (not in that order). How would I then go about retrieving them and listing them in reverse order?
The name of a MySQL table should be private, there is no way to display it, as it is a security risk.
Well, from your post, I'm unclear as to what exactly you want to do, but I hope this helps:
<?php
$var = array('1' => 'foo'
'2' => 'bar'
'heh' => 'Hello, World!');
echo $array['1'] . '-' . $array['2'] . '-' . $array['heh'];
// The following would echo 'foo-bar-Hello, World!';
?>
Well, your code is, shall we say, less than perfect, but, then again, we all have to learn sometime, right? See if this helps:
<?php
if (isset($_POST['add'])) {
include ('config.php');
include ('opendb.php');
mysql_select_db('DB_NAME', $mysql);
// You must tell it what the connection resource is, as well
// as which databse you will be using. Make sure that in opendb.php,
// the function mysql_connect(); is being set to $mysql.
$username = $_POST['username'];
$password = $_POST['password'];
$query = "INSERT INTO user (host, user, password, select_priv, insert_priv, update_ priv) VALUES ('localhost', $username, PASSWORD($password), 'Y', 'Y', 'Y')";
// No single quotes are needed for variables in the statement above.
mysql_query($query) or die('Error, insert query failed ');
$query2 = "FLUSH PRIVILEGES";
mysql_query($query2) or die('Error, insert query failed');
include ('closedb.php');
echo "New MySQL user added";
} else {
?>
<html><body>
<form method="post">
<table width="400" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="100">Username</td>
<td><input name="username" type="text" id="username"></td>
</tr>
<tr>
<td width="100">Password</td>
<td><input name="password" type="text" id="password"></td>
</tr>
<tr>
<td width="100"> </td>
<td> </td>
</tr>
<tr>
<td width="100"> </td>
<td><input name="add" type="submit" id="add" value="Add New User"></td>
</tr>
</table>
</form></body></html>
I currently use Kanoodle, which used to pay me some decent money, but they have seriously lowered their CTR in the past two months for me, and it's hurting. Would the switch to Google be sensible, and would I make more money? (Looking now, I only made $5 in the past month :-| )
I think it's best to build up a bit of feedback buying before you start selling stuff on ebay anyway. I don't bid for things when the seller has 0 feedback.
Agreed, but what's the appropriate amount before you start to sell items? 20? 50? 100?
I really don't see how much more short that could get, you did everything right, and if you're worried about computer load, don't worry, a small application like this has no effect on a computer whatsoever.
I attached your program, but I cleaned it up a bit, added the underscores like you mentioned, etc.
Well, I for one, am hopeful that Microsoft has improved their OS experience, even with the addition of Microsoft Internet Explorer 7 soon to be released.
MediaWiki, although all of its pages are freely editable, yes, they make constant backups to ensure somebody doesn't come in and just delete everything. For your purposes, I'd recommend adding a MySQL column named "approved" or something similar, and writing simple PHP to check if "approved" is TRUE, or is equal to 1. Those that are not approved can be dislayed on a password-protected PHP page which only you can access, like Troy here described (very nicely, might I add), and then a link, possibly, next to each one, something like "Approve | Deny". Deny would change the "approved" column in the database to -1, and Approve might change it to 1.
I have an idea: Make it so that a user can only add one item each time they visit the website or clear their cookies. Here's some code:
<?php
session_start();
if ($_SESSION['spamcheck']) {
die('You have already submitted data to this database!');
// Or put whatever you like as an error message here, if you don't
// use die();, then be sure to use the "exit;" command after you
// display the error.
};
// Add your form code and MySQL processing here.
// Add the following line -after- the MySQL process
// has completed successfully.
$_SESSION['spamcheck'] = TRUE;
?>
I have a few boards running vBulletin 3.0.7, and might I say, that is one little powerhouse. I almost drooled when I saw the AdminCP :o If you can, I would Strongly recommend getting vBulletin. It definately is worth it.
The following are spyware and should probably be deleted:
C:\Program Files\Media Access\MediaAccK.exe
C:\Program Files\Media Access\MediaAccess.exe
O8 - Extra context menu item: &Search - http://bar.mywebsearch.com/menusear...?p=ZNxdm799YYFR
O9 - Extra button: ShopperReports - Compare travel rates - {946B3E9E-E21A-49c8-9F63-900533FAFE14} - C:\Program Files\ShopperReports\Bin\1.0.5.0\ShprRprt.dll
O9 - Extra button: Related - {c95fe080-8f5d-11d2-a20b-00aa003c157a} - C:\WINDOWS\web\related.htm
O9 - Extra button: Messenger - {FB5F1910-F110-11d2-BB9E-00C04F795683} - C:\PROGRA~1\MESSEN~1\MSMSGS.EXE (file missing)
O16 - DPF: {14A3221B-1678-1982-A355-7263B1281987} - ms-its:mhtml:file://C:tsk.mht!http://69.50.166.110/5/s1//q.chm::/file.exe
O16 - DPF: {FD40EC41-D860-4579-8BA4-52671A45C71C} (AxHtChat Class) - http://images.goa.com/it/Woo2/fr/chat/nPaxChat.cab
O4 - HKLM\..\Run: [Media Access] C:\Program Files\Media Access\MediaAccK.exe
R0 - HKLM\Software\Microsoft\Internet Explorer\Main,Local Page = C:\WINDOWS\SYSTEM\blank.htm
O2 - BHO: (no name) - {016235BE-59D4-4CEB-ADD5-E2378282A1D9} - C:\Program Files\CxtPls\cxtpls.dll (file missing)
O2 - BHO: ShprRprts - {2A8A997F-BB9F-48F6-AA2B-2762D50F9289} - C:\Program Files\ShopperReports\Bin\1.0.5.0\ShprRprt.dll
My apologies, they aren't in order.
This is going off of my own experience, if anyone else thinks otherwise, feel free to contradict me.
Might I make a suggestion:
Open up Notepad. Copy and paste this into it:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies]
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\ActiveDesktop]
"NoChangingWallpaper"=dword:00000000
"NoComponents"=dword:00000001
"NoAddingComponents"=dword:00000001
"NoDeletingComponents"=dword:00000000
"NoEditingComponents"=dword:00000000
"NoHTMLWallPaper"=dword:00000001
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"NoDriveTypeAutoRun"=dword:00000000
"NoActiveDesktop"=dword:00000001
"ClassicShell"=dword:00000000
"ForceActiveDesktopOn"=dword:00000000
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System]
"DisableRegistryTools"=dword:00000000
"NoDispAppearancePage"=dword:00000000
"DisableTaskMgr"=dword:00000000
Then, go to Save As... Under file type, click All (*.*) (not *.txt), type in desktop_icons.reg and hit Save. Make sure to backup your registry before doing this, it shouldn't harm anytihng severely, anyways. Then, have Windows open the file. It should ask you if you want to add information to the registry. Hit yes, and it will tell you that it's done. Then, go to your desktop, right-click, and hit "Refresh".
Again, I'm not 100% sure about it, but it might work.
Hello, everyone, I'm Spike. I run a few forum boards myself, so I'm quite acquainted with vBulletin. I really like how you've customized it, though, this looks great.
Let's see...My hobbies include Snow Skiing, SysAdminning, Web Development, and Netowrk Adminnning. :cool: