mrfdes
Members-
Posts
50 -
Joined
-
Last visited
About mrfdes
- Birthday 06/09/1958
Profile Information
-
Gender
Male
-
Location
Vlaanderen/VK
mrfdes's Achievements
Newbie (1/5)
0
Reputation
-
Van Oostende, maar ik woon al 20 jaar in Engeland.
-
Thank you, Ignace. I am reading through it, but, to be quite honest, it does not look like a PHP tutorial to me. Some bits might as well have been written in Chinese. It gives some short examples, but it looks very complicated to me. Thank you.
-
Thank you for that Jacques. But, "So why use MySQLi?", well, because I don't know any better. The course I am following at the moment doesn't even mention mysqli, let alone PDO. Like I said, I am a beginner, and a lot of things still look/sound extremely complicated tome. Thank you for your input anyway.
-
What I mean is: when I changed mysql_select_db("jingleko_reloader", $con) or die("Couldnt Select a DB - ".mysql_error()); to mysqli_select_db("jingleko_reloader", $con) or die("Couldnt Select a DB - ".mysql_error()); I got the error 'Could not connect to db', so I had to put the database name in the mysqli_connect as 4th parameter. Strange, but it is probably me. Thank you.
-
Thanks. I have changed to mysqli now. PDO is still a bit beyond me, I'm afraid, but I am working on that. By the way, it looks like some mysqli statements are no longer supported when you change from mysql to mysqli. But, thank you all for your very useful advice.
-
WOW! That did the trick. I will now try to work out why the count (or absence thereof) messed up the whole script. Thank you so much gentlemen. More stuff to study then.
-
But where??? I have set up a script for people to remove themselves from a mailing list. It worked fine so far, but when I added a possibility to show a message the entered email addres did not exist, things went wrong. The script still runs, there are no errors, but when the user enters a non-existing email address, it still says "You have been removed". Everything seemed to go well until I added a button to a URL (echo'd) rather than a plain link. I have checked and rechecked, re-examined the flow, but I cannot find where I went wrong. One further thing: the people get sent to this page by a one field form on a HTML page, with method "post". Anyway, here is the script: <HTML> <HEAD> <TITLE>Vlaanderen-Flanders</TITLE> </HEAD> <BODY> <?php // Always try to connect and select the DB before anything else $con = mysql_connect("localhost","jingleko_reload","*******") or die("Couldnt Connect to DB - ".mysql_error()); mysql_select_db("jingleko_reloader", $con) or die("Couldnt Select a DB - ".mysql_error()); // Set post var $Epost = trim(addslashes(strip_tags($_POST['Epost']))); // Look for it in DB $query = "SELECT Epost FROM newsletter WHERE Epost='".$Epost."'"; $result = mysql_query($query); //If found, do next thing if(isset($_POST['Epost'])) { mysql_query("DELETE FROM newsletter WHERE Epost='$Epost'") or die (mysql_error()); echo "<div align=\"center\"><img src=\"Pics/Vlaamse Leeuw.jpg\" width=\"114\" height=\"127\" border=\"0\"></div>"; echo "<p align=\"center\"><b>Thank you, you are now removed from the list.</b></p><br>"; echo "<p align=\"center\"><a href=\"index.htm\"><img src=\"Pics/begin.gif\" width=\"95\" height=\"30\" border=\"0\"></a></p>"; } else { echo "<div align=\"center\"><b><font color=\"red\">This address does not exist</font></b></div><br>"; echo "<div align=\"center\"><a href=\"eruit.htm\"><img src=\"Pics/herbegin.gif\" width=\"95\" height=\"30\" border=\"0\"></a>"; echo "<a href=\"index.htm\"><img src=\"Pics/begin.gif\" width=\"95\" height=\"30\" border=\"0\"></a></div>"; } mysql_close($con); ?> </BODY> </HTML> Any ideas, please? Sometimes when I altered the code, I just got a blank page. Thanks in advance.
-
Thank you ever so much, Psycho, I REALLY tried (almost) everything. While it is good for the learning process to "learn from your mistakes" and watch closely what the error messages say, it can be quite stressful. Nevertheless, I have learned more stuff again, and this is a motivation to carry on with my course even more intensely. Thank you again.
-
I don't know what to expect, as I said before, I am a COMPLETE beginner.
-
I did that with the following lines: $query="SELECT Song FROM stemming WHERE Nr=$songSafeHtml"; $result=mysqli_query($link,$query); $output = "You voted for <b>$songSafeHtml." ".$result</b><br> U het gestem vir <b>$songSafeHtml." ".$result</b></br>"; and it gives me: Catchable fatal error: Object of class mysqli_result could not be converted to string in /home/jingleko/public_html/vlaamseradio.tk/top10/top10stem.php on line 71 Really no idea now.
-
I also tried to put the URL to http://www.vlaamseradio.tk/top10/top10stem.php?Nr=&Song= but that did not do any good either. I got the message the song did not exist. Any further ideas, please? Thanks.
-
I have done this, the URL was changed to http://www.vlaamseradio.tk/top10/top10stem.php?Nr= where Nr is the song number (the ID). The script became: <?php //Check if the user had voted in the last 24 hours if(isset($_COOKIE['voted'])) { $expireString = date('m-d-Y h:i:s', $_COOKIE['voted']); $output = "Sorry, you can only vote once every 24 hours. You can vote again after $expireString"; } else { //Start session and enable error reporting session_start(); error_reporting(E_ALL | E_STRICT | E_NOTICE); ini_set('display_errors', '1'); //Connect to DB $host="localhost"; $user="jingleko_reload"; $pwd="*******"; $dbname="jingleko_reloader"; $link = mysqli_connect($host,$user,$pwd,$dbname) or die(mysqli_error()); //Update count for selected song: THIS IS WHERE I MADE THE CHANGES $number = mysqli_real_escape_string($link,$_GET['Nr']); $query = "UPDATE voting SET Votes = Votes+1 WHERE Nr = '$number'"; $result = mysqli_query($link, $query); if (!$result) { //Query failed #die(mysqli_error()); //Uncomment for debugging only $output = "There was a problem processing your request."; } elseif(!mysqli_affected_rows($link)) { //No records were updated $output = "The song you selected doesn't exist." } else { //Vote was registered $songSafeHtml = htmlspecialchars($_GET['Song']); $output = "You voted for <b>$songSafeHtml</b><br> U het gestem vir <b>$songSafeHtml</b></br>"; //Set cookie to prevent multiple votes $expire = time() + (60 * 60 * 24); //Set expiration for 24 hours setcookie('voted', $expire, $expire); //Send confirmation email $to = "beheer@vlaamseradio.tk"; $subject = "There was a vote"; $message = "Someone voted for $songSafeHtml."; $header = "From: systeem@jinglekot.cu.cc \r\n"; $retval = mail($to, $subject, $message, $header); } } ?> <html> <head></head> <body> <?php echo $output; ?> </body> </html> I indicated the changes in the comments. It works as it should, however, I have been looking for a way to get the songname too, for the purpose of displaying "You have voted for 'This or that song'. Thank you" after the vote has been registered, but I am not getting there (don't forget I am a complete beginner). So, how can I get the field 'Song' to display too? Like I said, it is only for display purposes, nothing else needs to happen, as now it says (obviously) You voted for "number", which does not say much. . Thanks.
-
Yes, I use a link for the voting. I shall give it a try using the id. Thanks.
-
Hi, I have found a glitch in the script: if someone votes for a certain song which I have in the list twice, performed by different artists, both the song titles get a vote. I have tried a number of things so that the script recognises the field "Artist" as well as "Song" and only votes for the chosen song by the particular artist, but I do not seem to be getting anywhere. Can anyone point me in the right direction please? Thank you.
-
Changed the echo to $output = Wonder if that makes any difference.