wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
You've setup your q3 field as INT. You'll want to set it to VARCHAR instead. To change the type run this query ALTER TABLE `database`.`emailquestionnaire` MODIFY `q3` VARCHAR(100)
-
How have you setup your database schema? Your code is fine, although placing raw _POST data into your query is not recommended, as it can lead to sql injection attacks. You should look into sanitizing your users input before adding it to your database.
-
you can use substr, for example to only show the first 100 characters use echo substr($row["description"], 0, 100);
-
You can use number_format.
-
You may find it more particle to use HEREDOC syntax: if ($fp) { $content = <<<PHPCODE <?php /* Database Host Name */ \$db_host = '{$post_details['db_host']}'; /* Database Username */ \$db_username = '{$post_details['db_username']}'; /* Database Login Password */ \$db_password = '{$post_details['db_password']}'; /* Database and Session prefixes */ define('DB_PREFIX', '{$post_details['table_prefix']}'); ## Do not edit ! define('SESSION_PREFIX', 'probid_'); /* Database Name */ \$db_name = '{$post_details['db_name']}'; ?> PHPCODE; fputs($fp, $content); fclose($fp); }
-
Just wrap the function around the variable you want to alter. Example $var = stripslashes($_POST['name']); Documentation on stripslashes.
-
You'll need to write separate rules for each url you're trying to match.
-
You'll need to install PHP with an HTTP server too, eg IIS or Apache. Unless you're confident with the command line to run your php scripts. In which case open the command line and type in php -v You may need to change directory to where PHP is installed for the command to work. The way I recommend to setup PHP on Windows is the following. Personally I do not recommend the use of the PHP installer. I'd recommend you to uninstall PHP, delete any files left over. Go to http://windows.php.net/ and download the VC6 x86 Thread Safe zipped package. Extract the zip to C:\Server\PHP. Download Apache 2.2 MSI Installer from http://httpd.apache.org Install Apache to C:\Server\Apache (using custom install). Once installed. Open Apaches httpd.conf file (located in C:\Server\Apache\conf). Add the following lines at the end of the file LoadModule php5_module "C:/Server/PHP/php5apache2_2.dll" PHPIniDir "C:/Server/PHP" AddType application/x-httpd-php .php Save the httpd.conf Next you'll want to go to C:\Server\PHP and find the file name php.ini-recommended and rename it to php.ini Now you'll want to add C:\Server\PHP to the PATH Environment Variable. Restart Windows. You have now installed PHP and configured Apache with PHP. To test go to C:/Server/Apache/htdocs Delete any files already in that folder and create a new file called info.php with the following code <?php phpinfo(); ?> Ensure Apache is running (there should an Apache icon present in the taksbar, with a green triangle which indicates Apache is running). Open you browser and go to http://localhost/info.php You should see a page displaying your current php version with details about its settings and environment. Everything is now setup and is working correctly. To configure PHP edit the php.ini in C:/Server/PHP/php.ini. Remember whenever you make any changes to the httpd.conf or php.ini you will need to restart Apache for the changes to take effect.
-
You're not calling the function correctly $postje = $rows['post']; bbcode_format($postje); . It needs to be $postje = bbcode_format($rows['post']); Please read the document on the use of functions here http://php.net/manual/en/language.functions.php
-
At the moment it sounds like you're not sanitizing your users input. Failing to to do this will make your script prone to SQL Injection attacks. To help prevent this you should use mysql_real_escape_string at minimum. Allowing users to post HTML in your guestbook doesn't sound like a good idea either. If you're going to allow HTML to be posted you should limit them to certain HTML tags such as <b>, <i>, <u> etc. You can implement this using strip_tags. The alternative is to use BBCode tags such as [, , and etc. There are many tutorials on the net making your own BBCode Parser.
-
Where is the variable $validid being defined? Need to see more code.
-
Variables are not parsed within single quotes, replace them with double quotes header("Refresh: 1; URL=klant_actions?klant_id=$validid");
-
If you're making a link to file2 in file1 <a href="/Game/logout.php">Logout</a>'; OR <a href="../Game.logout.php">Logout</a>'; If you going to file1 in file2, you use <a href="/Game/S1/main.php">Home</a>';
-
Undefined Constant Error on local testing server
wildteen88 replied to mikeskinner's topic in PHP Coding Help
Seems you're dealing with a poorly designed PHP application. To stop the notice message (not an error) from appearing you can change this line if (USE_BASE_ROOT === false) { to if (defined('USE_BASE_ROOT') && USE_BASE_ROOT === false) { -
nl2br converts newlines into <br /> tags. Eg it converts this Some text here Blah blah What ever To the following: Some text here<br /> <br /> Blah blah<br /> <br /> What ever If the text in your database doesn't have any new lines then your code will not work. You may want to limit the text by the number of words or characters instead.
-
It most probably uses AJAX (javascript XMLHttpRequest Object). You'll find may examples all over the net. Search google for Ajax.
-
.htaccess mod rewrite help pls!
wildteen88 replied to thewooleymammoth's topic in Apache HTTP Server
These rules need to be in reverse order RewriteRule ^(.*.)/$ index.php?page=$1 RewriteRule ^(.*.)/(.*.)/$ index.php?page=$1&v2=$2 RewriteRule ^(.*.)/(.*.)/(.*.)/$ index.php?page=$1&v2=$2&v2=$3 Also you should set the Last flag too ([L]) after your rules. I'd set your rules as the following # Matches /tom/2/abc123/ RewriteRule ^([a-z\-_]+)/([0-9]+)/([a-z0-9\-_]+)/$ index.php?page=$1&v2=$2&v2=$3 [NC,L] # Matches /tom/2/ RewriteRule ^([a-z\-_]+)/([0-9]+)/$ index.php?page=$1&v2=$2 [NC,L] # Matches /tom/ RewriteRule ^([a-z\-_]+)/$ index.php?page=$1 [NC,L] ([a-z0-9\-_]+) - Matches any character that is a letter (a to z), or a number (0 to 9), a hyphen or an underscore ([a-z\-_]+) - Matches any character that is a letter (a to z), a hyphen or an underscore ([0-9]+) - Matches any character that is a number (0 to 9) -
If you have access to Apaches httpd.conf you can use the following directive AddType application/x-httpd-php .php .it Files ending in .it will now be parsed by PHP.
-
possible to phase a define in variables
wildteen88 replied to Death_Octimus's topic in PHP Coding Help
Do you mean $request['priority'] holds the value 'priority_3' (or priority_2 or priority_1 etc). And you want to call the constand priority_3 (or 2 or 1 etc). You can use the function constant to call a constant For example define("Priority_3","<span class=\"priority_3\">Normal</span>", true); $request['priority'] = 'Priority_3'; echo constant($request['priority']); -
Problem getting variable When using function.
wildteen88 replied to eli312's topic in PHP Coding Help
You will need to pass the $session variable as an argument to your site_layout function, or use the dirty fix and define $session as global in your site_layout function This is explained in the link the I provided earlier about variable scope. Some info on function arguments http://www.php.net/manual/en/functions.arguments.php -
possible to phase a define in variables
wildteen88 replied to Death_Octimus's topic in PHP Coding Help
You need to be more specific with your question. Does not make sense. Do you know what define does and how to use constants. -
Problem getting variable When using function.
wildteen88 replied to eli312's topic in PHP Coding Help
You have a variable scope issue: http://php.net/manual/en/language.variables.scope.php What I would recommend you to do is to send any variables you wish to use in the template you're including to your site_layout function. For example <?php // Includes the layout pages function site_layout($template="",$_vars=array()) { if(is_array($_vars) && count($_vars) > 0) extract($_vars); include('layout/'.$template.".php"); } // define all variables we use in the template in the $data array, ge // $data['var_name'] = 'value'; $data=array(); $data['hello_world'] = "helloWorld!"; ?> Call variable from page: <?php echo $data['hello_world'];?> <br/> <br/> Call layout From function: <?php site_layout("test2", $data);?> Now in your template file you can use $hello_world -
Could you post some example data for both arrays. I cant understand clearly what you're trying to do. But from what I can tell, you're basically wanting to check if an item in $refnr is in the array $senr?if thats the case then the function in_array meybe what you're after. Without knowing how your arrays are constructed and what they contain I cant tell you exactly what to do.
-
What the above code does is check to see that the arguments passed to the function (in your case the variables $ids and $idc) hold a numeric value. If they both don't hold a numeric value then the function will return a false value. No code after the if will be processed however if they both hold a numeric value then the function will ignore the code in the if statement. To understand how return works please read the documentation here. You may also find the following useful. http://uk3.php.net/manual/en/language.functions.php
-
Am I right in guessing you want to parse the XML above and insert each item (<name> and <category>) into the database? You can parse XML easily with simpleXML <- click for examples and documentation on the use of simpleXML If you're familiar with how to use MySQL with PHP you should be able to work out how to insert each item in to a MySQL database, once you have understood the basics of simpleXML.