« first day (995 days earlier)      last day (3122 days later) » 

6:28 AM
<script>
$(function(){
$('body').append('<a href="#" id="scrolltotop">Scroll to top</a>');
$(window).scroll(function(){
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
if(scrollTop > 50) {
$('#scrolltotop').css('bottom', 0);
} else {
$('#scrolltotop').css('bottom', -100);
}
});
$('#scrolltotop').click(function(){
$('html:not(:animated),body:not(:animated)').animate({ scrollTop: 0}, 500 );
return false;
});
});
</script>
 
1 message moved from JavaScript - Scripting Javas
1 message moved from JavaScript - Scripting Javas
 
 
3 hours later…
user3119231
9:39 AM
function countDaShit(){
	$db = new PDO("mysql:host=$db_host;dbname=$db_name;charset=utf8", "$db_user", "$db_pass");
	$query = $db->prepare("SELECT * FROM table WHERE Deleted = 1 LIMIT 1");
	$query->execute();
	$rows = $query->fetch();
	$count =  count($rows);
	return $count;
	$db = null;
}
 
user5020521
wait for it @Maurize this is what I need and thank you but
 
user5020521
may I show thee what happens in my php?
 
user3119231
echo(json_encode($count));
 
user3119231
then it will be in ajax.responseText
 
user3119231
I don't need any stringify
 
user5020521
9:42 AM
wait guys
 
user5020521
may I show you my php?
 
user3119231
In an onlineservice
 
user5020521
<?php
    //call the connection file
    require 'connessione.php';
    //errors enabled
    error_reporting(-1);
    ini_set('display_errors', 'On');
	var_dump($_POST);
	$myId = intval($_POST['idRecord']);
    try {
		$dbh = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
        // set the PDO error mode to exception
        $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
		$del = $dbh->prepare("DELETE FROM tagesroma WHERE id= '" . $myId . "'");
		$del->execute();
 
user5020521
am I on the right way?
 
user5020521
this is long before your suggestion @Maurize
 
user3119231
9:44 AM
<?php
    require 'connessione.php';
	$dbh = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
	$del = $dbh->prepare("DELETE FROM tagesroma WHERE id= '" . $myId . "'");
	$del->execute();
	$count = $del->rowCount();
	$dbh = null;
	echo json_encode($count);
?>
 
user3119231
works in my case.
 
@Riccardo990 Try to not past big code and use an onlineservice (like pastbin) for things like that.
 
user5020521
you're right @dievardump I'm sorry for that
 
user3119231
especially add the code to pastebin if it is NOT JS
 
user5020521
@Maurize why did you quit php before the json_encode?
 
9:46 AM
No, add the code to pastebin if it's big code. JS or not.
 
user5020521
did you quit connection*
 
user5020521
you set dbh to null and then you encoded the json
 
user3119231
because you don't need the database anymore if you declared the variable before.
 
user3119231
It will exist anyway.
 
user5020521
so your final suggestion is that I'mma get rid of try catch
 
user3119231
9:47 AM
always close the connection as soon as possible ~
 
user3119231
you don't need this try shit -> only if you are not sure that connection exists.
 
user5020521
matter of fact I quit connection after the catch
 
user5020521
so now I'mma get rid of it
 
@Riccardo990 : don't close your php files if you do not need ti do it. close your connectiions before echoing anything. Verify that the user who request this URL has the right to delete your thing. I do not see any Session checking or anything
 
user5020521
that's why i'm not yet a php experienced
 
user3119231
9:49 AM
You test it locally like in xammp right? So you will see the errors anyway. No need for try - catch thing. PDO is a good way to secure networking BUT make sure you test variables ( isset($_POST["id"] .. ect.
 
user3119231
PHP is my main job :P
 
user5020521
@Maurize I'm not on xamp i'm on my own web server
 
user5020521
I've already told something to id I used intVal function
 
user3119231
Then add the line: $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 
Create some "helper" for your connection. You really don't want to have to new PDO, setAttributes etc... every time. Just create
 
user3119231
9:50 AM
This is enough for giving out errors.
 
Create some "helper" for your connection. You really don't want to have to new PDO, setAttributes etc... every time.
 
user5020521
and then in my DELETE i catch the invVal value
 
user3119231
this is one of my smartest ways to manage database
 
user3119231
@Riccardo990 but enough from PHP - We are in JS room.
 
user5020521
@Maurize I'll get rid of try catch but one thing
 
user5020521
9:52 AM
onee last thing
 
No
go in the php room
 
user5020521
why did you get rid of intVal too?
 
user5020521
that's the last one
 
user3119231
Tell us the last thing. But then, never talk about php here, again.
 
user5020521
just did
 
9:53 AM
Man what you ask is the basis of every PDO tutorial
Just freaking RTFM
 
52 messages moved from JavaScript - Scripting Javas
 
10:15 AM
var num=8;
var b=1;
for(a=1;a<=5;a++){
document.write(b+",");
b=b+num;
num=num*2;

}
 
1 message moved from JavaScript - Scripting Javas
 
 
4 hours later…
user5020521
2:07 PM
array(1) {
["idRecord"]=>
string(2) "65"
}
1int(1)
 
1 message moved from JavaScript - Scripting Javas
 
2:44 PM
0
Q: Macro that generates a function, with arguments determined by the macro

Jon HaddadIs it possible to write a macro that generates a function? Is it possible for the number of arguments to this function to be a determined by the macro? For instance, i'd like to write something to make using prepared statements in the Cassandra driver easier. let prepared = prepare!(session, "...

 
 
3 hours later…
5:55 PM
0
Q: Rust - defining integer subrange

Danny CohenHow do I limit an integer definition to a sub-range of itself ? As an example, if I have an u8 called my_var, I want to define it as: let mut my_var: u8 [0..7] = 4; Pascal and Delphi have that feature, so I wonder how it is done in Rust. http://www.delphibasics.co.uk/Article.asp?Name=Sets

 
 
2 hours later…
8:31 PM
0
Q: Rust: sharing mutable self between multiple threads

Ben RuijlI have a server that accepts connections from multiple clients. Each client could send a message to the server, which is broadcast to all other clients. The problem is that the function that handles each connection should have a reference to the server. However, I want to handle the connections i...

 
 
3 hours later…
11:15 PM
AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
HELPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
IS STUCKKKKKKKKK
HELPPPPPPPPPPPPPPPPPPPPPPPP
 
5 messages moved from JavaScript - Farm Animals of War
 

« first day (995 days earlier)      last day (3122 days later) »