Skip to content

Instantly share code, notes, and snippets.

array(33) { ["HOME"]=> string(12) "/nonexistent" ["USER"]=> string(3) "www" ["FCGI_ROLE"]=> string(9) "RESPONDER" ["QUERY_STRING"]=> string(0) "" ["REQUEST_METHOD"]=> string(3) "GET" ["CONTENT_TYPE"]=> string(0) "" ["CONTENT_LENGTH"]=> string(0) "" ["SCRIPT_NAME"]=> string(1) "/" ["REQUEST_URI"]=> string(1) "/" ["DOCUMENT_URI"]=> string(1) "/" ["DOCUMENT_ROOT"]=> string(8) "/var/www" ["SERVER_PROTOCOL"]=> string(8) "HTTP/1.1" ["REQUEST_SCHEME"]=> string(4) "http" ["GATEWAY_INTERFACE"]=> string(7) "CGI/1.1" ["SERVER_SOFTWARE"]=> string(11) "nginx/1.9.2" ["REMOTE_ADDR"]=> string(8) "10.0.2.2" ["REMOTE_PORT"]=> string(5) "49342" ["SERVER_ADDR"]=> string(9) "10.0.2.15" ["SERVER_PORT"]=> string(2) "80" ["SERVER_NAME"]=> string(9) "localhost" ["REDIRECT_STATUS"]=> string(3) "200" ["SCRIPT_FILENAME"]=> string(18) "/var/www/index.php" ["HTTP_HOST"]=> string(9) "localhost" ["HTTP_CONNECTION"]=> string(10) "keep-alive" ["HTTP_CACHE_CONTROL"]=> string(9) "max-age=0" ["HTTP_ACCEPT"]=> string(74) "text/html,application/xh
array(32) { ["HOME"]=> string(12) "/nonexistent" ["USER"]=> string(3) "www" ["FCGI_ROLE"]=> string(9) "RESPONDER" ["QUERY_STRING"]=> string(0) "" ["REQUEST_METHOD"]=> string(3) "GET" ["CONTENT_TYPE"]=> string(0) "" ["CONTENT_LENGTH"]=> string(0) "" ["SCRIPT_NAME"]=> string(12) "/lorem/ipsum" ["REQUEST_URI"]=> string(12) "/lorem/ipsum" ["DOCUMENT_URI"]=> string(12) "/lorem/ipsum" ["DOCUMENT_ROOT"]=> string(8) "/var/www" ["SERVER_PROTOCOL"]=> string(8) "HTTP/1.1" ["REQUEST_SCHEME"]=> string(4) "http" ["GATEWAY_INTERFACE"]=> string(7) "CGI/1.1" ["SERVER_SOFTWARE"]=> string(11) "nginx/1.9.2" ["REMOTE_ADDR"]=> string(8) "10.0.2.2" ["REMOTE_PORT"]=> string(5) "49585" ["SERVER_ADDR"]=> string(9) "10.0.2.15" ["SERVER_PORT"]=> string(2) "80" ["SERVER_NAME"]=> string(9) "localhost" ["REDIRECT_STATUS"]=> string(3) "200" ["SCRIPT_FILENAME"]=> string(18) "/var/www/index.php" ["HTTP_HOST"]=> string(9) "localhost" ["HTTP_CONNECTION"]=> string(10) "keep-alive" ["HTTP_ACCEPT"]=> string(74) "text/html,application/xhtml+xml,app
else{
$(".error").hide();
clearTimeout(close_error_msg);
$("#form-"+pure_id).submit(function(e){
e.preventDefault(e);
comment(pure_id);
});
}
function comment(pure_id){
QUERY 1:
INSERT INTO votes (post_id, user_id, value, date_time)
SELECT :pt,:ui,:v,:dt
FROM $table_name t
WHERE t.id=:pt limit 1
QUERY 2:
INSERT INTO votes (post_id, user_id, value, date_time)
SELECT :pt,:ui,:v,:dt
// Valid ---------------- without subdomain
www.example.com
http://example.com
http://www.example.com
https://example.com
https://www.example.com
// Valid ---------------- with subdomain
www.sub.example.com
http://sub.example.com
SELECT pr1.id AS user_id,
pr1.title AS user_name,
pr2.id AS liker_id,
pr2.title AS liker_name,
x.which AS which_table
FROM (
SELECT rid, rootid, 'vote' which FROM p_likes
UNION ALL
SELECT rid, rootid, 'comment' which FROM p_comments
UNION ALL
function removeWrongClass(el){
el.removeClass('wrong');
}
$(".ask_q_title_input").on('focus', function(){ removeWrongClass($(this)) });
$("#qandatextarea").on('focus', function(){ removeWrongClass($(this)) });
$(".make_bounty > a").on('click', function(){ removeWrongClass($('.make_bounty')) });
$(".chosen-single").on('click', function(){ removeWrongClass($(this)) });
$("#ask_q_tags").on('click', function(){ removeWrongClass($(this)) });
SELECT q.type,
q.author_id author,
q.deleted,
q.deleter_id,
COUNT(DISTINCT a.id) answers_num, -- it will be 0 for answers
COUNT(DISTINCT v.id) votes_num
FROM qanda q
LEFT JOIN qanda a ON q.id = a.related
LEFT JOIN votes v on q.id = v.post_id
WHERE q.id = ?
@sajadshafizadeh
sajadshafizadeh / input.scss
Created November 10, 2022 10:16
Generated by SassMeister.com.
.parent{
.child {
color: red;
}
}
/* ----------- */
.parent{
& .child {
1. Create a database connection:
First, you need to create a connection to the MySQL database using PHP. You can do this using the PHP mysqli_connect() function, which takes four arguments: the database host, the username, the password and the name of the database.
$conn = mysqli_connect("hostname", "username", "password", "database_name");
2. Check the connection:
Once the connection has been established, you can check whether it was successful by using the mysqli_connect_errno() function. This will return 0 if the connection was successful, or another error code if there was an error.