header('Content-Type: text/html; charset=iso-8859-1');
set up htaccess
RewriteEngine on RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization},last]ErrorDocument 404 /404.php
// NEW way connection
$mysqli = mysqli_connect("localhost","brugernavn","password","databasenavn");
mysqli_set_charset($mysqli,"utf8");//do the magic...(æøå)
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}else{echo "Connect to MySQL";
}
//if (mysqli_num_rows($query) > 0) {
//while ($data = mysqli_fetch_array($query)){
#############################################
UPDATE bel_posts SET guid = REPLACE(guid, 'https://hans-holger.dk/z-bellingevej', 'https://bellingevej34.dk') WHERE guid LIKE 'https://hans-holger.dk/z-bellingevej/%'; #----------------------------------------------------------------
--Akeeba Backup for Joomla! throws an AJAX Error, 500 Internal Server Error-- Special notes for one.com customers If your site is hosted on one.com please follow these instructions if the above doesn't work: Run the Configuration Wizard but do not take a backup yet Go to Akeeba Backup's Configuration page and set the following parameters: Logging Level: Only errors (however, if you want to ask for support in our ticket system you must switch it back to All Information and Debug and try taking a new backup before posting us your log file) Click the Configure button in the Archiver Engine and set the "Part size for split archives" to 127Mb or less. Minimum execution time: 10 seconds Maximum execution time: 7 seconds Execution time bias: 50% Please note that the above settings do cause the backup to run at half speed, but this is required for your backup to run under smoothly on one.com. We'd like to thank one.com's tech support for testing and providing these safe settings. #----------------------------------------------------------------
///////////////// NEW MYSQLI CONNECT //////////////////
$dbconnect = mysqli_connect("localhost","my_user","password","my_db");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL:" . mysqli_connect_error();
}else{echo "Connect to MySQL";
}
///////////////// MYSQLI DELETE //////////////////
mysqli_query($dbconnect,"DELETE FROM table WHERE id = '$id'")OR DIE(mysql_error());
///////////////// MYSQLI SELECT //////////////////
$sql=mysqli_query($dbconnect,"SELECT * FROM table");
if(mysqli_num_rows($sql)){
while($row=mysqli_fetch_array($sql)){
}//while loop
}//if num rows...
///////////////// MYSQLI SELECT //////////////////
$query = mysqli_query ($dbconnect,"SELECT * FROM molly ORDER BY sort DESC");
if (mysqli_num_rows($query) > 0) {
while ($data = mysqli_fetch_array($query)){
}//while loop
}//if num rows...
//////////////// MYSQLI UPDATE /////////////////
$sql = "UPDATE table_name SET file_name='$filename', path='$path' WHERE id='$id'";
if (mysqli_query($dbconnect, $sql)) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . mysqli_error($conn);
}
#----------------------------------------------------------------
Example (MySQLi Procedural)
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT id, firstname, lastname FROM MyGuests";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
}
} else {
echo "0 results";
}
mysqli_close($conn);
?>
#----------------------------------------------------------------
DATABASE CONNECTION:.................
$dbc = mysqli_connect("server","brugernavn","password","databasenavn");
SELECT:.................
$q = "SELECT overskrift, txt FROM news ORDER BY id DESC LIMIT 0, 3";
$result = mysqli_query($dbc,$q);
while($data = mysqli_fetch_array($result)){}
INSERT:.................
$q = "INSERT INTO news (overskrift, txt) VALUES ('$overskrift', '$txt')";
$result = mysqli_query($dbc,$q);
DELITE:
$q ="DELETE FROM news WHERE id = $id";
$result = mysqli_query($dbc,$q);
UPDATE:.................
$q = "UPDATE news SET overskrift = '$overskrift', txt = '$txt' WHERE id = $id";
$result = mysqli_query($dbc,$q);
SELECT - LIKE:.................
$q = "SELECT navn, telefon FROM telefon WHERE navn LIKE '%$soeg%' OR telefon LIKE '%$soeg%' ORDER BY navn ASC";
$result = mysqli_query($dbc,$q);
if(!mysqli_num_rows($result)>0){
echo "Intet resultat ved søgningen";
}else{while($data = mysqli_fetch_array($result)){
}}
// Perform a query, check for error
if (!mysqli_query($dbconnect,"INSERT INTO carousel_upload_data (gal_id,file_name)
VALUES ('$gal_id','$name' )"))
{
echo("Error description: " . mysqli_error($dbconnect));
}
----------------------------------------------------------------
date_default_timezone_set("Europe/Copenhagen");
$timestamp_create=time();
$now=date('Y-m-d H:i:s', $timestamp_create);//(the MySQL DATETIME format)
#----------------------------------------------------------------
#Force www:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]
#----------------------------------------------------------------
#Rewrite everything to https
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#----------------------------------------------------------------
#Force non-www:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
#----------------------------------------------------------------
0) Side skal gemmes som "Encodning utf-8" (notepad++)
1) Alm php fronend side skal ikke have //header('Content-Type: text/html; charset=iso-8859-1'); eller //header('Content-type: text/html; charset=utf-8');
2) Alm Html head skal indeholde
3) Database sættes til (under Collation:) latin1_danish_ci
4) Database forbindelse sættes med brug af $con=mysqli_connect("localhost","user","password","database_name");
mysqli_set_charset($con,"utf8");
5) Nu kan der skrives æøå direkte på siden og i databasen
#----------------------------------------------------------------
Man kan se Joomla version ved at tilføje dette efter hjemmeside url 'administrator/manifests/files/joomla.xml'
Man kan resette Joomla user 'UPDATE `j3_users` SET `password` = MD5( 'new_password' ) WHERE `j3_users`.`username` = "admin" ;'
UPDATE `j3_users` SET `password` = MD5( 'new_password' ) WHERE `j3_users`.`username` = "admin" ;
INSERT INTO j3_users (name, username, password,) VALUES ( 'test', 'test', MD5('test') );
INSERT INTO j3_user_usergroup_map (user_id, group_id) VALUES ( 2, 8 );
INSERT INTO `j3_users`(`name`,`username`,`password`)VALUES('test','test','098f6bcd4621d373cade4e832627b4f6');
UPDATE `joomla3`.`j3_user_usergroup_map` SET `group_id` = '8' WHERE `j3_user_usergroup_map`.`user_id` =1 AND `j3_user_usergroup_map`.`group_id` =1;
INSERT INTO `jos_users`
(`id`, `name`, `username`, `email`, `password`, `usertype`, `block`, `sendEmail`,
`registerDate`, `lastvisitDate`,`activation`,`params`)
VALUES ('40', 'Administrator2', 'admin2', '[email protected]',
'd2064d358136996bd22421584a7cb33e:trd7TvKHx6dMeoMmBVxYmg0vuXEA4199',
'Super Administrator', 0, 1, '0000-00-00 00:00:00', '0000-00-00 00:00:00',"","");
INSERT INTO `jos_user_usergroup_map` (`user_id`,`group_id`) VALUES (40, 8);
At this point, you should be able to log into the back end of Joomla! with the username of "admin2" and password of "secret". After logging in, go to the User Manager and change the password to a secure value and the e-mail to a valid e-mail address.
#----------------------------------------------------------------