wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
[SOLVED] Chainging an integer to a minus number
wildteen88 replied to Siggles's topic in PHP Coding Help
Use -$var -
im thinking about quitting php please help
wildteen88 replied to silverglade's topic in Miscellaneous
Look into creating guestbooks/shoutboxes with a mysql/flat file database. Once you've done then add extra features to it such as an Admin backend. After that see if you can expand the project a bit more to a basic content management system. Basically start of with something simple and just keep expanding it. This is how I started with PHP. -
[SOLVED] properly setting session var (PHP5)
wildteen88 replied to CaptainChainsaw's topic in PHP Coding Help
No you should not use session_register or session_is_registered, these are depreciated. You should only use these variables if register_globals is enabled (which it shouldn't) CaptainChainsaw you're setting your session variables correctly, however $_SESSION['username']=''; is not needed. -
Sorry by glob I meant dir. I always get glob and dir mixed up.
-
You'd use explode to separate each line. eg $txt = $_POST['your_textarea']; // standardize new lines $txt = str_replace(array("\r\n", "\r"), "\n", $txt); $lines = explode("\n", $txt); foreach($lines as $line) { echo $line . '<br />'; }
-
Umm, $myvar is your actual variable, the () is so PHP calls the function eg $var = 'hello'; function hello() { return 'hello world'; }; echo $var();
-
Use $mvar(); However why would want to store function names in a variable? Make sure these variables are not set by the user otherwise you could cause security exploits in your code.
-
The -> is used to access methods/properties within an object. An object is created when a class is initialized or from a function which returns an object (such functions are glob or mysql_fetch_object)
-
While you where away I have managed to get your PHP Fusion modification working with PHP Fusion 7 RC2. In fact AvatarGallery6 does work with RC2 (only a few changes where actually needed). As the code for AvatarGallery6 is a bit messy, I replaced it with the code I have already provided you, took a bit of debugging but I got there in the end. Attached is version7 (version6 is included too, if you wan to run version6 go to your-site.com/infusions/avatar_gallery/avatar_gallery6.php) [attachment deleted by admin]
-
I didn't mean save the image in the database, but the file path to the image (this is how its done already looking at your code snippet and is lso how my code works too, when a user selects an avatar two variables are passed which are $_POST['avatargallery'] and $_POST['avatarselect']. $_POST['avatargallery'] holds the selected avatar category (eg Diablo2, Mario etc) $_POST['avatarselect'] holds then name of the selected image. With these two variables the path to the image is constructed like so: $avatar_path = AVATAR_FOLDER . $avatar_category . '/' . $avatar_image; You then use $avatar_path in your query to update the 'user_avatar' column. My code does not re-upload the selected image.
-
Your protect() function doesn't return a value and thus you get errors no matter what you fill your form with. function protect($String) { // check weather magic_quotes is enabled if(get_magic_quotes_gpc()) { $String = stripslashes($String); } // escape harmful characters $String = mysql_real_escape_string($String); // remove HTML tags $String = strip_tags($String); // in order for a function return anything you'll // need to use the 'return' keyword return trim($String); } I have reconstructed your function, you'll noticed I removed addslashes. You do not need to use this function, if you're using mysql_real_escape_string
-
Not sure what you mean, but it has nothing to do with my code. It must be to do with what you're doing, you'll need to post the relevant code to your problem
-
Why do you have to rename the selected avatar file to username[X].gif (X being a number). I've not used PHP Fusion, is this some sort of standard thing? It will be much easier if you just updated the database with the selected avatar, rather having to rename/move files, which just over complicates things really.
-
The description for the nl2br function explains it quite well. Also you might want to look into incorporating a Rich Text editor (such as FCKEditor or TinyMCE) rather than BBCode. Because if you're going to add BBCode you may as well teach your client HTML, as BBCode is basically HTML.
-
Agreed thread is going of topic. Thread locked.
-
Lets get some facts straight short tags has been disabled by default . It has never been enabled on a fresh install of php. By a fresh install, I mean installing PHP manually. Not a an install from XAMPP or WAMP or whatever pre-configured package you use. These packages have nothing to do with the PHP Foundation.
-
IGNORE ME
-
You'd setup counter to do that, to do so you'd first need to initiate a variable, eg p$i = 0; This will go before your while loop. Now the rest of the code goes within your while loop. Which will be // if $i is dividable by 3, echo a new table row if($i%3 == 0) { echo "</tr>\n<tr>\n"; } // increment counter $i++; Your code with admendments echo '<table border="0" cellspacing="1" cellpadding="3"> <tr>'; // initiate counter $i = 0; while($row = mysql_fetch_array($result)) { echo '<td align="center" width="27%" style="color: white">'. $row['Image'] . "<br />\n". $row['Link'] . "<br />\n". $row['Title'] . "<br />\n". $row['Medium'] . "<br />\n". $row['Size'] . "</td>\n"; // if $i is dividable by 3, echo a new table row if($i%3 == 0) { echo "</tr>\n<tr>\n"; } // increment counter $i++; } echo '</tr> </table>';
-
Is that only line you added? You'll need another line too which is LoadModule, eg LoadModule php5_module "C:/php/php5apache2_2.dll Save the httpd.conf and restart Apache.
-
You'll have to create a function for this. You'll have to loop through the array and search for the requested id. I have come up with this function array_multi_search($search, $array) { $r = null; foreach($array as $key => $value) { if($key == 'id' && $value == $search) { unset($array['children']); return $array; } elseif(is_array($value)) { $r = array_multi_search($search, $value); if(is_array($r)) { return $r; } } } return false; } $result = array_multi_search(3, $arr); echo '<pre>' . print_r($result, true) . '</pre>'; $result = array_multi_search(7, $arr); echo '<pre>' . print_r($result, true) . '</pre>'; change $arr to your array variable name.
-
What version of windows do you have installed? I'd recommend you to change the path in which sessions are written to, open the php.ini (accessible by WAMP's taskbar icon), scroll down and find the following line ;session.save_path = "/tmp" Remove the semi-colon ( ; ) from the start of the line and change /temp to C:/wamp/temp Save the php.ini and create a temp folder in C:\wamp. Afterwards restart WAMP
-
New lines (\r\n \n or \r) are not displayed, you need to use the <br /> tag to display a new line. echo "$row[description]<br />\n";
-
[SOLVED] PHP Include inserts unknown charachters
wildteen88 replied to nullpointer's topic in PHP Coding Help
The characters  usually means PHP is outputting the BOM, this only happens when files are saved as UTF-8 To fix this you should save you files as "UTF8 without BOM" (this should be a setting in your text editor/save dialog). Or save the file as ASCII instead. -
Because your include starts with a forward slash, this tells PHP to load the requested file from the root of the filesystem (eg C:\) not the root of your websites root directory. I'd change this line <?php include ("/menus/botmenu.html"); ?> to <?php include $_SERVER['DOCUMENT_ROOT'] . '/menus/botmenu.html'; ?> Now PHP will include the file from your websites root directory.