![](https://forums.phpfreaks.com/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
Alex
Staff Alumni-
Posts
2,467 -
Joined
-
Last visited
Everything posted by Alex
-
Your directory structure is like this, correct? include connection.php content file1.php If so to access connection.php the correct path would be ../include/connection.php
-
You should check out some basic mysql tutorials. Take a look at http://www.phpfreaks.com/tutorial/php-basic-database-handling
-
require '../include/connection.php'; - ../ is used to go up a level in a directory structure.
-
Im making a registration script and having problems
Alex replied to JamesThePanda's topic in PHP Coding Help
mysql_query returns false on failure. You're also using a lot of unnecessary single quotes. $result = mysql_query("INSERT INTO memtable (name, password) VALUES('$username1','$password1')"); if(!$result) { echo "There was an error!: " . mysql_error(); } -
foreach(scandir($dir) as $folderItem) { if(is_dir($folderItem) && substr($folderItem, 0, 1) == '_') continue; // First character in the folder name is _, so skip to the next iteration of the loop } is_dir substr You were using substr() wrong, the way that you were using it would return everything but the first character, see the manual for more information.
-
If you want to allow both lower and uppercase you can use the i modifier to enable case insensitivity. $newgroupname = preg_replace('/[^a-z0-9]/i', '', $groupname);
-
Well the parse error is probably because you're missing a ; at the end of this line: $comp = $_GET['comp'] To check if a variable is set you should use isset Ex: if(isset($_GET['comp'])) { // .. } else { // .. }
-
Do you only want the color to be a word like 'red', 'green', etc? If so you can use use \+)\](.+)\[\/color\]
-
Frameworks have their purpose, but personally I don't like them so much. They include a lot of stuff that you'll never use, and I don't like how you need to use a framework for at least a few months to actually be proficient in it. I've tried several frameworks, but I like using and developing my own minimalistic framework. You might argue that I'm reinventing the wheel, but I highly prefer spending the small amount of time reinventing to my specifications and understanding all the ins and outs of it instantaneously rather than having to study something unfamiliar for months. With frameworks you'll always have complaints, which is really why I decided to create my own.
-
Check the manual, isset. Simply put it allows you to check if a variable is..well set without throwing a notice if it isn't.
-
isset Example: if(isset($_POST['myHiddenField'])) { // ... }
-
The only thing I could think of is if you have an array in the $_POST superglobal, then you'll get that error message. Like if you have a form with something like this: <input type="text" name="var[]" /> <input type="text" name="var[]" /> Where $_POST['var'] would be an array and would throw E_NOTICE Array to string conversion when you try to run it through stripslashes()
-
We really can't offer much help without seeing code. Most likely it's some kind of uncaught exception that is caused by a bot being able to access some file in a way that you would not normally have anticipated.
-
That's HTML/CSS, not PHP. Example: echo "<span style='color: red;'>Red Text!</span>";
-
By the way, there's a topic solved feature, you can mark your topic as solved with the button at the bottom left of the page.
-
What in that code do you think is clashing?
-
Something like this should do (Just make sure you replace the table name with your own): $result = mysql_query("SELECT option_name, option_value FROM table"); while($row = mysql_fetch_assoc($result)) { $config[$row['option_name']] = $row['option_value']; } You can then access your configuration details in the associative array $config like such: $config['site_title'], $config['site_slogan'], etc..
-
Change $Name = $col[0]; to $Name = $col[$i];
-
Yea, those two lines aren't supposed to be there. When I posted the query before that's all that was supposed to be in it, you can completely remove those lines. (Again) Based on that screenshot all I see is 1 record with the Name 'Eric_Wright', and do you even have a column named 'Linked'? I can't tell from the screenshot.
-
Based on that screenshot it doesn't look like you have a record with the Name 'PN', so of course no records will be updated.
-
A record is just a row in the database, you do have rows already inserted, right?
-
Are you sure the column names in the query are correct (they are case sensitive), and that there is actually a record with the Name 'PN'?
-
You're also not using the correct syntax for updating (I edited my last post already).
-
You're missing a $ for the variable $sql on this line: mysql_query(sql); You're also using wrong syntax for updating a database. Try: $sql = "UPDATE players SET Linked='1' WHERE Name='PN'";
-
[SOLVED] Clear contents of txt without deleting file? \:
Alex replied to newbtophp's topic in PHP Coding Help
$fp = fopen('somefile.txt', 'w'); fclose($fp);