-
Posts
3,404 -
Joined
-
Last visited
-
Days Won
55
Everything posted by Ch0cu3r
-
Your scrpt gets the msyql username and password from psl-config.php. Make sure you have set the PASSWORD constant in that file to the correct password for sec_user username
-
If you have created a MySQL user called sec_user then make sure you are using the correct password for that user for when you created it.
-
Use web browser engine to extract URLs from a page?
Ch0cu3r replied to KingNeil's topic in PHP Coding Help
I don't get your problem? The basic example provided by simple_html_dom v1.5 lists all links for me for any site include 'simplehtmldom_1_5/simple_html_dom.php'; // get all links from home page of a website $html = file_get_html('http://www.sitename.com'); foreach($html->find('a') as $element) echo $element->href .' <br />'; // echo the link This is basic DOM traversal. I dont understand how using an actual web browsers engine will help you. -
When using include the php code does not execute
Ch0cu3r replied to dario's topic in PHP Coding Help
Then your php files should then be stored in C:/wamp/www . You then open http://localhost to run them If i remember correctly, if WAMP is running there should a green wamp taskbar icon in the taskbar. If it is red or yellow then it is not running or has an encountered an error. -
How do you request next 50 blocks from the API? The API documentation should provide some information about this?
- 1 reply
-
- php
- pagination
-
(and 3 more)
Tagged with:
-
When using include the php code does not execute
Ch0cu3r replied to dario's topic in PHP Coding Help
Looking at the code, you are using includes correctly. The problem that can arise is that PHP cant find the files you are trying to include and so it will either log an error in the servers error log or display an error message, But this to me sounds like you are not running your .php files correctly. I have a feeling you are loading the php files directly into your browser (eg the address bar looks like file://path/to/file.php). If this is true then this not the correct way to run PHP code on your computer. To run PHP code on your computer you need to download PHP and and configue it with a http server. There are packages available you can download and install to allow you to do this. Most popular being WAMP - For Windows Only XAMPP - For Mac, Linux and Windows MAMP - For Mac Only Once you have installed the package for your platform you store the PHP files in the packages document root folder and then to run th php files you goto http://localhost -
No, you can obfuscate it by using using mod_rewrite, eg have urls like site.com/page/123 but it does not make it any securer. Yes make sure you are always validate and sanitizing the user input before using it. Such as if you expecting a number, then make sure you check that it is a number and then use intval to sanitize the number etc. All exploits are caused by simply not doing this. You are simply leaving the door wide open to all sorts of attacks if you don't do this properply. Helpful read http://www.phptherightway.com/#data_filtering
-
$SESSION should be $_SESSION (starts with an underscore) Also make sure you have started the session at the top of your getstaff page You should also be sanitizing your user input before using it in your query $email = mysql_real_escape_string($_POST['l_email']); Passwords should be hashed not stored as plain text in the database
-
You should really be using a TIME data type for your duration column in the database. But to answer your question you can make your friends code into a function function convertToTime($number) { $time = strrev($number); $time = wordwrap($time, 2, ':', true); return strrev($time); } Then when you want to convert the duration you'd call the function echo '<li class="thumbcontent">... <span class="duration">'. convertToTime($runrows['duration']).'</span></li> ';
-
$_SESSION['sId']; will do nothing. If you want to set the sId session varibale you will need to assign it a value, what that value is is upto.
-
So you thought you would post it here...
-
@rich_hemmo: The problem is you are not connected to mysql. You need to call mysqli_connect first before running any queries Also you should atleast validate and sanitize the the user input before using it in your query. And is it necessary to store the users username, password and email twice? Passwords should not be stored as plain text, they should be hashed
-
The way you have posted your reply makes it hard for any one to read. Also when posting code it makes the post more readable if you wrap it in tags. EDIT. I have read your post but I do not see how it relates to the OP.
-
What bottom button? I do not understand your question.
-
How to get this script in a lower version of PHP
Ch0cu3r replied to alpha_01's topic in PHP Coding Help
Your code is PHP5.5 compatible. The problem is more likely an error in the code. Make sure have error reporting enabled, you can do this by openning the php.ini and add the following to end of the file error_reporting = E_ALL displayer_errors = On Save the php.ini and restart Apache. Run your code and post the error messages you get in full here -
Not sure what you're asking but there are some issues I'd like highlight in your code global $_PRODUCTS_IMAGES_DIR, $_PRODUCTS_TABLE; Stop right there. Do not use globals. Any function that requires a variable in order to function should be passed as an argument. This code even necessary? if(isset($_SERVER['REQUEST_URI'])){ if(stristr($_SERVER['REQUEST_URI'], '?')){ $explodeJob = explode('?',$_SERVER['REQUEST_URI']); if(trim($explodeJob[1]) != ''){ $explodeJob[1] = str_replace("-", " ", $explodeJob[1]); $jobSearch=strtolower($explodeJob[1]); }else{ $jobSearch=''; } }else{ $jobSearch=''; } Why not get the query string parameter you're after from the $_GET superglobal? There is no need to parse the url yourself. Next issue $query = mysql_query("SELECT DISTINCT `job` FROM $_PRODUCTS_TABLE WHERE `active`='1' ORDER BY `job` ASC"); while($result = mysql_fetch_object($query)){ $langClass = ''; $langVar = ''; $colour=''; if(strtolower($result->{'job'.languageText()}) == $jobSearch){ $colour = ' style="color:#2BA8C4"'; } $str.='<a href="#"><li'.$colour.' id="'.$i.'">'.$result->{'job'.languageText()}.'</li></a>'; $i++; } return $str; Why you not use MySQL to filter the results based on $jobSearch, eg $jobSearch = mysql_real_escape_string($jobSearch); $query = mysql_query("SELECT `job` FROM $_PRODUCTS_TABLE WHERE `active`='1' AND `job` LIKE '%$jobsearch%' ORDER BY `job` ASC"); There is no need to filter the results using PHP. it is more efficient for MySQL to do this than PHP. This make no sense to be at all. array_push($newImgArr, $singleImg."!!!".$result->id."!!!".$result->client."!!!".$result->job."!!!".$result->description."!!!".$result->overview); ... array_push($newImgArr, $result->image."!!!".$result->id."!!!".$result->client."!!!".$result->job."!!!".$result->description."!!!".$result->overview); You could just push the $result object to the array?
-
What is the output of this printf('<pre>%s</pre>', print_r(htmlentities($WXSIMtitles[$i]), true)); There is most likely some stray characters between the two words which maybe causing the issue with only the first word to be capitalised
-
Are these lines in the right order? $WXSIMtitles[$i] = ucwords($WXSIMtitles[$i]); $WXSIMtitles[$i] = preg_replace('! (\S+)$!',"<br />\\1",get_lang($WXSIMday[$i])); Shouldn't the first line be after the secound? Also is the preg_replace use to convert newlines to <br />. If thats the case you could use nl2br instead
-
yes Whats the problem?
-
Build php on Windows bug #49192
Ch0cu3r replied to Pachecoleal25's topic in PHP Installation and Configuration
Why are you compling PHP on windows? You can get windows versions of PHP from windows.php.net Also when downloading PHP do not use the installer. Simply Download, unzip and extract. PHP is installed. The tricky bit is configuring PHP with a HTTP server. -
First java and javascript are two complete different languages. There are many javascript timer scripts out there. Find one, download it, and play with it so you understand how it works then try and get it to work with your PHP.
-
How to display a variable filename picture in a directory above web?
Ch0cu3r replied to lost_toys's topic in PHP Coding Help
So you're using /site.com/public/www/prod/data/12_24_36_pic.png as the img src? This is wrong, you misunderstood my post slightly. The path used in the img src should be like /data/12_24_36_pic.png (note starts with /data and ends in _pic.png) mod rewrite will capture this url, and pass only theeimage name to image.php, which will then serve the image from /site.com/public/www/prod/data/ -
This cant be done with PHP alone. The countdown will have be handled by javascipt. You'd only use PHP to initiate the timer What do you mean? It is listed in the PHP Coding Help forum
-
How to display a variable filename picture in a directory above web?
Ch0cu3r replied to lost_toys's topic in PHP Coding Help
So the image path is defined from another script? And you want to pass that path onto image.php to display the image which is stored outside of the image root. You could use mod_rewrite, for example output an image path like this in a img tag <img src="/data/xxx_yyy_zzz_pic.png" /> Now using mod_rewrite and can capture any url that starts with /data/ and ends in _pic.png and pass the image filename to image.php, which willl then serve the image from /site.com/public/www/prod/data/. So add the following to a .htaccess (that is the actual name) file in the htdocs folder rewriteEngine On rewriteRule ^data/([\d+]_[\d+]_[\d+]_pic.png)$ image.php?img=$1 [NC,L] Now a slight modification to requinix's code would be <?php $img_path '/site.com/public/www/prod/data/' . basename($_GET['img']); // make sure the requested image exists in /site.com/public/www/prod/data/ if(file_exists($img_path)) { // serve the image header("Content-Type: image/png"); header("Content-Length: " . filesize($Img_path)); readfile($img_path); exit; } -
Why isn't this Regex capturing everything between the <body> tags?
Ch0cu3r replied to MySQL_Narb's topic in Regex Help
In javavscrpt there is no s flag so the dot includes newlines characters. Insead you need to use [^] to match any character not a dot Edit: Working example http://regexr.com/38n74 Umm, the DOM? body = document.getElementByTagName('body'); alert(body[0].innerHTML);