wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
[SOLVED] every fifth entry create a break
wildteen88 replied to dennismonsewicz's topic in PHP Coding Help
Setup a counter, increment the counter in the loop. Add an if statement which checks to see if the counter is at 5, if it is reset the counter and echo the a newline. Otherwise increment counter: echo '<table align=center border=0 width=650 cellpadding=4 cellspacing=0 class=imgtable> <tr> <td><u><b>Image</b></u></td> </tr> <tr> <td valign="top">'; //And we display the results $i = 0; // initialise counter while($result = mysql_fetch_array( $data )) { $kbsize = $result['size'] / 1024; //$name = str_replace($find, "<span class='yellowbg'>$find</span>", $result['name']); $size = str_replace($find, "<span class='yellowbg'>$find</span>", $kbsize); $type = str_replace($find, "<span class='yellowbg'>$find</span>", $result['type']); $categories = str_replace($find, "<span class='yellowbg'>$find</span>", $result['categories']); $id = $result['id']; $filecount = count($result['name']); $typenoimage = str_replace("image/", "", $type); echo '<img src="imageuploads/thumbs/' . $result['name'] . '" alt=' . $result['name'] . ' border=0>'; // check if $i is equal to 5, if it is echo line break and reset counter if($i == 5) { $br = "<br />"; $i = 0; // reset counter } else $i++; // increment counter } -
if you only want to return the first item from the array returned by $this->input->files('file') use array_shift, eg: $filename = array_shift($this->input->files('file')); array_shift will remove the first item from the array and return its value.
-
The XAMPP tar.gz file should get extracted to /opt and not your desktop. The installation instructions for XAMPP is here.
-
Windows doesn't use User/group permissions (well Vista does but very confusing, however shouldn't affect Apache) This appears to be an Apache configuration issue. Can you access http://localhost/wordpress/index.php if you can then you'll need to enable Indexes
-
You may need to provide the file name perhaps in the action attribute in the form tag? edit, Seems to be an IIS configuration issue. Have a read of the following http://www.somacon.com/p126.php
-
You'll need to read your book further as more code is required for it to parse the template, store_front.tpl
-
To stop users seeing directory indexes just add a blank index.html or index.php file.
-
Try: http://homepage.ntlworld.com/cshepwood/tshirtshop.rar
-
Rather than using the following to get the file extension: $file_extention = substr("$image_file_name", - 4); $file_extention = strtolower($file_extention); Use the pathinfo function: $file_extention = pathinfo($image_file_name, PATHINFO_EXTENSION);
-
Can you attach your php scripts here for me to download so I can review them To add a code box, wrap your code in code tags ( , eg: your code here will produce your code here
-
You cannot use cookies as soon as they are set, eg: setcookie('cookiename', 'cookie_value', time()+3306); echo $_COOKIE['cookiename']; You'll notice no value is display when you run that code on the same page. If you refresh the page the cookie value will be shown. This is due to the way the http protocol works. When PHP see's the setcookie function, the server will send a cookie header which will tell the browser to set the cookie you setup in the script. However the browser will not send the cookie data back to server after setting the cookie. Web browsers will only send cookie data per http request, so when you refresh the page the browser will re-request the current page again and thus this time send the new cookie data in the header. You'll then be able to retrieve the 'cookiename' cookie in your script.
-
Yes thats correct. Does it work?
-
All this should be explained in the book. Did you try my suggestion, I'll retype it so its more clear.
-
Use $_GET['file'] to retrieve the url variable file. Then use include. Example code: if(isset($_GET['file'])) { if(file_exists($_SERVER['DOCUMENT_ROOT'] . $_GET['file'])) { include $_SERVER['DOCUMENT_ROOT'] . $_GET['file']; } }
-
I suggest you to define a constant called SITE_ROOT, like so: define('SITE_ROOT', $_SERVER['DOCUMENT_ROOT']); And that line before line 3 in include/config.php That should sort the errors out.
-
The reason for the error in config.php is becuase your parenthesis '(' and ')' don't match up on line 5: define('PRESENTATION_DIR', SITE_ROOT . '/presentation/'; Notice you dont have a closing brace at the end of that line, it should be: define('PRESENTATION_DIR', SITE_ROOT . '/presentation/'); As for the error in index.php, line 3 has missing semi-colon at the end: require_once 'include/config.php' Line 3 should be: require_once 'include/config.php'; These are very basic syntax errors.
-
This is a bug in PHP, example: session_start(); $_SESSION['test'] = null; $test = 'foo'; Even if register_globals is off PHP will report the session side-effect error. You can safely disable the session.bug_compat_42 setting by changing it in the php.ini, or add: <?php ini_set('session.bug_compat_42', 0); ?> To your script.
-
Post the lines before the require_once line you most probably missing a semi-colon at the end of a line.
-
I suggest you keep the connection details within the connection.php and any other variables required by your app too. That way if you need to change the connection info for the database you'll just need to edit one script rather than a whole load of scripts.
-
Why are you connecting the mysql server twice: $con = mysql_connect($host,$dbUser,$dbPass); $conn = mysql_connect($host,$dbUser,$dbPass) or die(mysql_error()); Chnage it to: $con = mysql_connect($host,$dbUser,$dbPass) or die(mysql_error()); Alos no need for this code either: // Connect to server and select databse. if (!$con) { die('Could not connect: ' . mysql_error()); } else { if (!mysql_select_db($db, $con)){ echo 'Could not connect to database.'; exit; } } You have connected/selected database in scripts/connection.php Also that error/notice you are retrieving is coming from different script, display.php Edit Didn't see your second post. These lines: $user = $_SESSION['myusername']; if(!session_is_registered(myusername)){ header("location:index.php"); } should be: if(!isset($_SESSION['myusername'])) { header("location:index.php"); exit; } $user = $_SESSION['myusername'];
-
Umm not quite getting you. From my testing my code does this are you using my updated PHP and HTML code? Each search word must go on a separate line(rather than separated by a space) in the textarea.
-
You should always restart the server in order for the changes you made in the php.ini to take affect.
-
showing non-english text after using htmlentities() !!
wildteen88 replied to hassank1's topic in PHP Coding Help
If you want to remove all html tags you can just use strip_tags function. htmlentities will convert all characters which have an html entity equivalent will be converted. If you only want to convert only html characters then use htmlspecialchars -
MySQL not showing up in phpinfo
wildteen88 replied to peranha's topic in PHP Installation and Configuration
This is most probably a bug in your code. Make sure you are using full PHP tags (<?php ?> or <?php echo ?>) in your code and not tags such as <? ?> or <?= ?>