-
Posts
3,404 -
Joined
-
Last visited
-
Days Won
55
Everything posted by Ch0cu3r
-
php function for bootstrap sidebarmenu
Ch0cu3r replied to Gerrit_van_Weele's topic in PHP Coding Help
If you are having technical issues or need help using the template then I suggest you contact the author of template you bought it from. -
$dom->loadHTML should of been $doc->loadHTMLFrom Set the $url variable to be your webpage $url = 'http://site.com/page.html'; $doc = new DOMDocument(); $doc->loadHTMLFile($url);
-
Here your second foreach loop foreach($x_value as $x => $x_value) { The second $x_value will be overwriting the value of first $x_value. This will be causing problems looping the array of results. Try renaming the second $x_value to be $value you then need to use $value inside the second foreach loop, rather than $x_value if that does not fix the problem then can you show us the output of echo 'Response Data: ' . print_r($apiResponse['response']['data'], true);
-
Looking at the HTML you provided each team info is contained in these parent divs <div class='Grid-bind-start Grid-h-mid Nowrap'> and <div class='Grid-bind-end Grid-h-mid Nowrap'> I would use xpath to get the contents of these divs. Once you have the team info you would store each team info in an array. Then use array_chunk to pair up the teams, after loop over the paired teams array to output team vs team. $doc = new DOMDocument(); $doc->loadHTML($url); $xpath = new DOMXPath($doc); // return the content of these divs // <div class='Grid-bind-start Grid-h-mid Nowrap'> // <div class='Grid-bind-end Grid-h-mid Nowrap'> // these are the parent divs that contain the team score and name along with other information $query = "//div[starts-with(@class, 'Grid-bind-') and contains(@class, 'Grid-h-mid Nowrap')]"; $entries = $xpath->query($query); $teams = array(); foreach ($entries as $entry) { // remove whitespace and replace with a comma $score_team = preg_replace('~\s{2,}~', ',', trim($entry->nodeValue)); // the team score, and name with outher info is now seperated by a comma // use explode to split the data into an array // the team score will be the first item // the team name is the third item list($score, $team,) = explode(',', $score_team); // add team name and score to a teams array $teams[] = $team . ' ' . $score; } // pair up the teams in the teams array $pairedTeams = array_chunk($teams, 2); // output team VS team foreach ($pairedTeams as $teams) { echo implode(' VS ', $teams) . '<br />'; }
-
What is the contents of $_POST? var_dump($_POST);
-
Why are you storing your dates into two different fields one being varchar and the other being of date type. If you are going to store the date in a date type field then it must stored in YYYY-MM-DD format. If you attempt to store the date in a different format mysql will always truncate the date to 0000-00-00 If you want to the date to be formattted when you get it out the table you can use MySQL date_format function in your select query or use PHP's built in DateTime::format when you retrieve the date from your query.
-
Im struggling to understand too. I have gone to your website but I do not get the "Menu error." shown on any tab? If you are developing locally how are we supposed to see the error on your live site?
-
Not sure what to suggest as I have just installed that map plugin on my existing wordpress installation, added draggable: false to options in the wpgmappity_shortcode_mapjs function can confirm this did prevent the map from scrolling.
-
The code you posted already has draggable set to false on line 87 $content .= " draggable : false,\n"; Is that option not being output when view your page source code?
-
How to et 1 or more url through my htaccess allow/disallow ip?
Ch0cu3r replied to bambinou1980's topic in Apache HTTP Server
If you only want certain ip addresses from accessing a certain file then you need to define the allow from directive inside a <Files></Files> block <Files "filename-here-to-be-ip-protected.extension"> Order deny,allow Deny from all allow from xxx.xxx.xxx.xx #Fred allow from xxx.xxx.xxx.xxx #Ben </Files> Replace filename-here-to-be-ip-protected.extension with the file you want ip protected. -
Sorry misread your last post. To remove the button you should be able to do success: function(data) { // data is not empty, increment limit if(data.length != 0) { limit++; } else { $(this).hide(); } }
-
Why would there be no button? Is there more code that removes the button?
-
How can i remove the SQL injection vulnerability in this code.
Ch0cu3r replied to Kashmenon's topic in PHP Coding Help
Your code lacks any data validation and/or sanitation so there is no surprise your site is constantly under sql injection and most likely other forms of attacks. Whenever you receive any type of user input ($_GET, $_POST, $_COOKIE etc) you must validate it, checking to make sure it does exist and checking the value is what you expect it to be if you know the format of the data. Such as if you require a date then validate it is a date and it is in the format you require, such in ie YYYY/MM/DD format or MM/DD/YYYY/ format. If you require a number then validate that it is a number. If you require a certain value then check that it is that value. For input your cant check the format of such a persons name, contents of a blog post etc then the only validation you can apply is checking it does exist. What you must do though is sanitize it. If you are displaying the input on your webpage then apply htmlentities to prevent XSS (cross-site scripting). To prevent SQL injection the use your database api escape method, ie for mysqli use mysqli_real_escape_string or better yet use prepared statements. Try not to use $_REQUEST in your, it will receive input from $_GET, $_POST and $_COOKIE at the same time. You should always use the appropriate super global variable for where your data is coming from, such as if the data is from the querystring in the url then use $_GET. If its from a form using the post method then use $_POST. If the data is from a cookie then use $_COOKIE. -
Try changing the format_bbcode function to be function format_bbcode( $text ) { $search = array( '#\[url=(http|https|ftp)://(.+?)\](.+?)\[/url\]#i', '#\[url\](http|https|ftp)://(.+?)\[/url\]#i' ); $text = preg_replace_callback($search, function($m) { $url = $m[1] . '://' . $m[2]; $link_text = isset($m[3]) ? $m[3] : $url; return trunc_url($url, $link_text); } , $text); return $text; }
-
Just setup a virtualbox to tried out webmin and I managed to successfully import the jobberbase.sql file with no errors. All I did was Create a new database called jobberbase. Clicked the jobberbase database icon. Clicked Execute SQL button Selected "Run SQL from file" tab Uploaded jobberbase.sql using From uploaded file option Pressed Execute Output (take note of last line) Output from uploaded SQL commands .. No output generated 18 tables were created. 12 records were inserted. Returned to the database list and selected the jobberbase database icon. All the tables are now listed. Yes, port 3306 is the default port. You should not need to modify this unless your host has specified a different port. The only option you need to change is the db_user and db_password which wlll be the mysql username and password you used when created your jobberbase database. The other option you will need to set is 'app_url' => 'http://localhost/jobberbase/trunk/public/', Which will be the url to jobberbase on your website.
-
If you can create multiple databases then you do not need to follow the instructions for single database hosting. Just following the instructions for multiple database hosting
-
No You are getting that error because something in your sql dump is trying to use the table named _original_sql_jobberbase in the database named f-s-j - this is what 'Table 'f-s-j._original_sql_jobberbase' doesn't exist' means Are you sure you are supposed to import the the _original_sql_jobberbase table into your jobberbase database?
-
According to webmin docs here for backing up and restoring a database you login to webmin, select SQL Server from the servers list then click the Execute Sql button. On that page there is a "From local file" or "From uploaded file" button for selecting your sql file to setup your database.
-
1. $dbh->prepare() is for initializing a prepared statement. For each values used in the query you should be calling bindParam 2. Have your php script to not output the result if we are on the last page. In your javascript code you will only increment limit when data is not empty // only output the result if we are not on the last page if($_POST['page'] != $total_number_of_page) { echo json_encode($result); } In your javascript success: function(data) { // data is not empty, increment limit if(data.length != 0) { limit++; } }
-
You need to surround $type with quotes in the query $sqlContent="SELECT make, model, year, rideid FROM ride1 WHERE type = '$type'";
-
No you need to have different handles. The second $handle (for reading the referrals directory) will be overwriting the first $handle (for reading the referrals_bridge directory). @ginerjm The PHP manual recommends you write it that way.
-
php code isn't getting executed,only the code in form tags are?
Ch0cu3r replied to snb2990's topic in PHP Coding Help
Most likely because you have named your name input field Name but in your code your checking to see if $_POST['name'] exists (or in other words a field called name ) Field names are case sensitive. Name is not the same as name -
Parse error: syntax error, unexpected 'INSERT' (T_STRING)
Ch0cu3r replied to kjetill6's topic in PHP Coding Help
On line 8 you are not closing the string with a double quote " $info6 = "skap1'; ^ | this needs to be a double quote " PHP is case sensitive when it comes to variables, so $_post is not the same as $_POST. When using super global variables the variable name must be in uppercase. You would only use lowercase variables if you have defined a variable in lowercase Also when using variables, try to use meaningful names which will describe the data being stored. For example the variables $info2, $info3, $info4, and $info5 are not meaningful on their own, I am forced to look further down the code to know what they are being used for. I see they are used for logging into mysql on line 9. As these contain credentials for logging into mysql it willl better to name these as $hostname, $username, $password, and $database. $info6 will be better to be named as $table. But I do not see why you are storing the table name in a variable? The table name should be written in the query Before using the $_POST values in your query you should first validate the data, ie checking to see if it does exists and contains what your expect it to be. If the does not meat your requirements you should not be executing the query, instead ouput an error. You should also sanitize the data or use a prepared query Example of how your code should be <?php // variables containing mysql credentials $hostname = "localhost"; $username = "root"; $password = "123"; $database = "rom 206"; // connect to mysql $link = mysqli_connect($hostname, $username, $password, $database); // on HTTP POST request (ie when form has been submitted) if($_SERVER['REQUEST_METHOD'] == 'POST') { $error = array(); // do basic validation, checking to see if the data exists and is not empty if(isset($_POST['Strøm']) && !empty(trim($_POST['Strøm']))) { $strom = $_POST['Strøm']; } // validation failed, set error message else { $errors[] = 'Please enter a value for Strøm'; } // do basic validation, checking to see if the data exists and is not empty if(isset($_POST['Spenning']) && !empty(trim($_POST['Spenning']))) { $spenning = $_POST['Spenning']; } // validation failed, set error message else { $errors[] = 'Please enter a value for Strøm'; } // check to make sure there are no errors after validation if(empty($errors)) { // use prepared query for inserting the database $stmt = mysqli_prepare($link, "INSERT INTO skap1 (`Strøm`, `Spenning`) VALUES (?, ?)"); // make sure mysqli_prepare did not return an error if($stmt) { // bind the variables to the query mysqli_stmt_bind_param($stmt, 'ss', $strom, $spenning); // execute insert query mysqli_stmt_execute(); // check to make sure the query did insert a row if(mysqli_stmt_affected_rows ($stmt)) { echo "Data registering"; } } // mysqli_prepare returned an error else { // output error trigger_error('Query error: ' . mysqli_error($link)); } } // $errors is not empty, output validation errors else { echo 'Cannot insert data!<br />' . implode('<br />', $errors); } } -
MSSQL If select returns row then run update sql statement
Ch0cu3r replied to kat35601's topic in PHP Coding Help
You need to use a period not a comma between "Error in SQL" and odb_errormsg() when calling trigger_error trigger_error("Error in SQL: ".odbc_errormsg()); Also you do not need the curly braces around echo 'Updated' echo "Updated"; -
Error in my select and SET query - Help please
Ch0cu3r replied to bambinou1980's topic in PHP Coding Help
Why are you using a SET clause in a SELECT query? SET is used for setting values in UPDATE and INSERT queries, not SELECT queries What are you storing in the has_reseller_been_paid column?