Quantcast
Channel: Programming Forums
Viewing all 51036 articles
Browse latest View live

strupr use creates error Is string.h actually loaded?

$
0
0
Hi
I'm trying to learn c. I'm following a tutorial . It is introducing the various string methods. The program is as follows:
[code]

#include <stdio.h>
#include<string.h>
void main ()
{
char fname[30]="Mohn", lname[30]="Smith";
printf("Length of fname = %d",strlen(fname));
printf("Upper case of fname = %d",strupr(fname));
}

[/code]
When I run this I get the error
/home/mj/My_C_programs/23_StringFunctionExample2.c|7|undefined reference to `strupr'|

Googling says the strupr function is in string.h. I don't get the error until the printf line. If I comment the printf line out it runs. The line is basically a copy of the line above with just the method changed I realize that I must be missing something obvious but I don"t see it and I've spent quite a bit of time examing it. It appears that string.h isn't loaded I am using Release 16.01 rev 10692 (2016-01-23 15:52:29) gcc 7.2.0 Linux/unicode - 64 bit codeblocks as the ide. Thanks

build log as follows

-------------- Build file: "no target" in "no project" (compiler: unknown)---------------

gcc -pg -m64 -g -c /home/mj/My_C_programs/23_StringFunctionExample2.c -o /home/mj/My_C_programs/23_StringFunctionExample2.o
/home/mj/My_C_programs/23_StringFunctionExample2.c: In function ‘main’:
/home/mj/My_C_programs/23_StringFunctionExample2.c:6:32: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘size_t {aka long unsigned int}’ [-Wformat=]
printf("Length of fname = %d",strlen(fname));
~^ ~~~~~~~~~~~~~
%ld
/home/mj/My_C_programs/23_StringFunctionExample2.c:7:35: warning: implicit declaration of function ‘strupr’; did you mean ‘strstr’? [-Wimplicit-function-declaration]
printf("Upper case of fname = %d",strupr(fname));
^~~~~~
strstr
g++ -o /home/mj/My_C_programs/23_StringFunctionExample2 /home/mj/My_C_programs/23_StringFunctionExample2.o -pg -m64
/home/mj/My_C_programs/23_StringFunctionExample2.o: In function `main':
/home/mj/My_C_programs/23_StringFunctionExample2.c:7: undefined reference to `strupr'
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 2 warning(s) (0 minute(s), 0 second(s))

How to deploy Django application on apache2 server[OS Ubuntu 16.04]

$
0
0
Hello All,

I have refereed this tutorial for deploying Django project on apache2 server with Ubuntu 16.04 OS.

No luck, i am not getting Django success page on entering localhost/ip_address in my browser. Instead have this error.

Not Found
The requested URL / was not found on this server.

Apache/2.4.29 (Ubuntu) Server at localhost Port 80


Is there are any hacks for this?

need help with 5x5 multiplication table

$
0
0
so we have this activity given by our professor about making a 5x5 multiplication table, the output should be like this:
0 1 2 3 4
1 1 2 3 4
2 2 4 6 8
3 3 6 9 12
4 4 8 12 16


and so i typed in the code:
#include <iostream>

using namespace std;

int main(){

 int A, B;
 int C[10] = {1,2,3,4,5,6,7,8,9,10};
 int D;

 cout << "enter number for table [1-10 only]:";
 cin >> input;

 for(A=0; A<=D; A++)
  {
  for(B=1; B<=D; B++)
  {
   cout << (A*B)/>/>;
  }
  cout<<endl<<endl;
 }

 system("pause");
 return 0;
}

:code:
---------
and the OUTPUT is:
0000
1234
2468
36912
481216

and yes, i know i got the variable C in there but i'm confused as to where i'm supposed to place it in the code. My apologies, programming is not one of my strengths.

Exception check

$
0
0
Hi, I have a general question. If I write a method that throws exceptions and another method calls it, can I check if any exception is thrown? Usually I like to handle exceptions separately but let's say I want to terminate the method if any exception had been thrown. It won't work if there had been an exception. Is that possible?

Trouble with while loop counting repeated words

$
0
0
I began to study from a newer c++ book and I decided to make sure I understood two of the topics before advancing in the book. So, I used an exercise from a previous book that taught c++ 98 and wanted to use what I learned in my new book in that program exercise.

I wanted to make a program that would count the number of times a word (which was entered by the user) was repeated. In my newer book he covered templates and auto so I thought I would use them.

My problem is that when I try to compile it I get the error message
main.cpp|222|note: cannot convert 'len' (type 'int') to type 'std::nullptr_t'|
I thought of converting the string to an int using stringstream but that didn't work. I've tried different ways to solve the problem and I'm out of ideas. Could I get a hint?



#include<iostream>
#include<string>
#include<sstream>
template<typename T>

void WordCount(T& word, T&look)
{
    auto counting = 0;//counts number of times word appears in string
    int x = 0;
    int len = word.size();
    std::cout << "The sentence entered has " << len << " characters in it." << std::endl;
    stringstream len(s);
    while(x < len)
    {
        if(len == look)
            counting++;
    }


}
int main()
{
    std::string word;//word user enters
    std::string look;//used to find repeated words
    std::cout << "Enter a sentence to see how many times\n"
        << "the same word appears in it." <<std::endl;
    std::getline(std::cin,word);
    std::cout << "Enter the word you want to see the number\n"
        << "of times was repeated in the sentence." <<std::endl;
        std::cin >> look;
    WordCount(word,look);
}

PHP runs with ajax no errors in network tab

$
0
0
Hello all,
I have a php file connecting to phpmyadmin on xampp. I set the localhost password to ‘password’ I run the script with ajax and it does work because I tested it with a filecreate. I get NO errors and all I want to do is check and see if the email exists and if not then create a row in the database.

<?php
// Connect to Phpmyadmin database localhost.
$hostname = "localhost";//"";127.0.0.1
$username = "root";
$password = "password";//"password";
$dbname = "test";

$conn = new mysqli($hostname, $username, $password, $dbname);
if($conn -> connect_error) {
	die("Connection failed: " . $conn -> connect_error);
}
// USED to CHANGE the db. - (mysqli_select_db($con, "test") or die());

/* Check to make all fields entered -make sure submitted- #2*/
if(isset($_POST["register"])) {
	if(!$_POST["email"] | !$_POST["password"] | !$_POST["password2"]) {
		die("You did not fill in all the fields");
	}

/* do escape strings for SQL injection */
$emailsafe = mysqli_real_escape_string($conn, $_POST["email"]);
$passsafe = mysqli_real_escape_string($conn, $_POST["password"]);
$pass2safe = mysqli_real_escape_string($conn, $_POST["password2"]);

/* Check and see if email EXISTS in db. */

/* Insert email in db if does not exist */
$sql = "SELECT email FROM users WHERE email = '$emailsafe'";//limit 1
$result = $conn->query($sql) or die("invalid email check " . mysqli_error($conn));
$numrows = mysqli_num_rows($result);
if($numrows != 0) {
	die("Sorry the email " . $_POST["email"] . "is already in use");
}
// check if passwords both match
if($_POST["password"] != $_POST["password2"]) {
	die("Passwords did NOT match");
}
// if passwords match encrypt
$hashedpass = password_hash($passsafe, PASSWORD_DEFAULT);
// With everything escaped and hashed INSERT into db.
$sqlINSERT = "INSERT INTO users(email, password) " .
	"VALUES('" . $emailsafe ."','". $hashedpass ."')";
if($query = $conn->query($sqlINSERT)=== TRUE) {
	echo '<script type="text/javascript">alert("Successfully INSERTed");</script>';
} else {
	die("Unsuccessful");
}
$conn->close();
?>

modifiable lvalue?

$
0
0
not rlly sure if someone posted teh same problem but i got this table im working on

#include <iostream>
using namespace std;
int main(){

 int y, x;
 int C[10][10] = {{0,1,2,3},{4,5,6,7},{8,9,10}};
 int z;

 cout << "enter num [1-5]: ";
 cin >> z;

 for(y=0; y<=z; y++){
	 C[y] = y;
	 cout << C[y];
	for(x=1; x<=z; x++){
		C[x] = x;
		cout << C[x];
	}
 cout <<endl;
 }

 for(y=0; y<=z; y++){
	 for(x=1; x<=z; x++){
		 C[y][x] = y*x;
		 cout << C[y][x] <<" ";
	 }
	 cout <<endl;
 }

 return 0;
}



and in this part:
for(y=0; y<=input; y++){
	 C[y] = y;
	 cout << C[y];
	for(x=1; x<=input; x++){
		C[x] = x;
		cout << C[x];
	}
 cout <<endl;
 }


The C is highlighted and said that it is not a modfiable lvalue? i never seen it befor looking it up online dont rlly help much hope you guys can help :helpsmilie:/>

for(y=0; y<=z; y++){
	 C[y] = y;
	 cout << C[y];
	for(x=1; x<=z; x++){
		C[x] = x;
		cout << C[x];


srry typed th e wrong code lol

calling procedure "inputbox" 4 times

$
0
0
supposed to find the average of 4 numbers using the inputbox procedure, it's not allowing me to go from string to double in the last line of code

i have:

[Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim FirstNumber As String
Dim SecondNumber As String
Dim ThirdNumber As String
Dim FourthNumber As String

FirstNumber = (InputBox("Please enter a number.", "Get number."))

SecondNumber = (InputBox("Please enter a number.", "Get number."))

ThirdNumber = (InputBox("Please enter a number.", "Get number."))

FourthNumber = (InputBox("Please enter a number.", "Get number."))





TextBox5.Text = (CDbl(((((InputBox("Please enter a number.", "Get number."))) + ((InputBox("Please enter a number.", "Get number.")))) + (((InputBox("Please enter a number.", "Get number."))) + ((InputBox("Please enter a number.", "Get number.")))))) / 4))

End Sub]

Issues reading image meta data

$
0
0
There are lots of error messages :-(
Would be very kind, if you could help, cause I'm a beginner and thought this is an easy example to learn some things in C# :-)

This is my code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        /* OpenFileDialog:
        https://docs.microsoft.com/de-DE/dotnet/api/system.windows.forms.openfiledialog?view=netframework-4.7.2
        https://docs.microsoft.com/de-de/dotnet/framework/winforms/controls/how-to-open-files-using-the-openfiledialog-component
        */
        OpenFileDialog data = new OpenFileDialog();

        private void Load_Click(object sender, EventArgs e)
        {
            // Setzt den Fenstertitel im Datei öffnen-Dialog
            data.Title = "Öffnen";
            // Setzt das initial durchsuchte Verzeichnis
            data.InitialDirectory = @"D:\tmp";

            // Setzt die möglichen Dateitypen
            data.Filter = "Alle Dateien (*.*)|*.*|Grafik-Dateien (*.bmp;*.gif;*.jpg);*.png;*.tif|*.bmp;*.gif;*.jpg; *.png; *.tif|Textdateien (*.txt)|*.txt";
            // Setzt die initial aktive Filter-Nummer, aus den in der Eigenschaft Filter in Reihenfolge definierten Werten => Hier: Grafik-Dateien
            data.FilterIndex = 2;
            // Stellt das ausgewählte Verzeichnis bei erneutem Öffnen des Datei öffnen-Dialogs wieder her => Funktioniert leider nicht :-(
            data.RestoreDirectory = true;
            // ?
            if (data.ShowDialog() == DialogResult.OK)
            {
                // Öffnet die ausgewählte Grafik-Datei und zeigt Sie im Formular-Element PictureBox an
                pictureBox1.Load(data.FileName);
            }
        }

        // Create method for reading meta data
        public void meta()
            Bitmap image = new Bitmap(data.FileName);
            PropertyItem[] propItems = image.PropertyItems;

        // Loop, that reads meta data from file and saves it in the PropertyItem array
        int count = 0;
        foreach (PropertyItem item in propItems)
        {
            listBox1.Items.Add("Property Item " + count.ToString());
            listBox1.Items.Add("iD: 0x" + item.Id.ToString("x"));
            count++;
        }
    }
}



And this are the error messages (beginning line 48; rest at the start is w/o errors):
Schweregrad Code Beschreibung Projekt Datei Zeile Unterdrückungszustand
Fehler CS8124 Das Tupel muss mindestens zwei Elemente enthalten. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 57 Aktiv
Fehler CS0501 "Form1.meta()" ist nicht als abstrakt, extern oder partiell gekennzeichnet und muss daher einen Text deklarieren. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 49 Aktiv
Fehler CS1026 ) erwartet. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 55 Aktiv
Fehler CS1026 ) erwartet. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 57 Aktiv
Fehler CS1026 ) erwartet. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 58 Aktiv
Fehler CS1026 ) erwartet. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 58 Aktiv
Fehler CS1002 ; erwartet. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 50 Aktiv
Fehler CS8124 Das Tupel muss mindestens zwei Elemente enthalten. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 55 Aktiv
Fehler CS8124 Das Tupel muss mindestens zwei Elemente enthalten. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 57 Aktiv
Fehler CS8124 Das Tupel muss mindestens zwei Elemente enthalten. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 58 Aktiv
Fehler CS8124 Das Tupel muss mindestens zwei Elemente enthalten. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 58 Aktiv
Fehler IDE1007 Der Name "Add" ist im aktuellen Kontext nicht vorhanden. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 57 Aktiv
Fehler IDE1007 Der Name "Add" ist im aktuellen Kontext nicht vorhanden. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 58 Aktiv
Fehler IDE1007 Der Name "count" ist im aktuellen Kontext nicht vorhanden. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 57 Aktiv
Fehler IDE1007 Der Name "count" ist im aktuellen Kontext nicht vorhanden. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 59 Aktiv
Fehler IDE1007 Der Name "count.ToString" ist im aktuellen Kontext nicht vorhanden. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 57 Aktiv
Fehler IDE1007 Der Name "Id" ist im aktuellen Kontext nicht vorhanden. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 58 Aktiv
Fehler IDE1007 Der Name "item" ist im aktuellen Kontext nicht vorhanden. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 58 Aktiv
Fehler IDE1007 Der Name "item.Id" ist im aktuellen Kontext nicht vorhanden. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 58 Aktiv
Fehler IDE1007 Der Name "item.Id.ToString" ist im aktuellen Kontext nicht vorhanden. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 58 Aktiv
Fehler IDE1007 Der Name "Items" ist im aktuellen Kontext nicht vorhanden. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 57 Aktiv
Fehler IDE1007 Der Name "Items" ist im aktuellen Kontext nicht vorhanden. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 58 Aktiv
Fehler IDE1007 Der Name "listBox1" ist im aktuellen Kontext nicht vorhanden. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 57 Aktiv
Fehler IDE1007 Der Name "listBox1" ist im aktuellen Kontext nicht vorhanden. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 58 Aktiv
Fehler IDE1007 Der Name "listBox1.Items" ist im aktuellen Kontext nicht vorhanden. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 57 Aktiv
Fehler IDE1007 Der Name "listBox1.Items" ist im aktuellen Kontext nicht vorhanden. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 58 Aktiv
Fehler IDE1007 Der Name "listBox1.Items.Add" ist im aktuellen Kontext nicht vorhanden. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 57 Aktiv
Fehler IDE1007 Der Name "listBox1.Items.Add" ist im aktuellen Kontext nicht vorhanden. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 58 Aktiv
Fehler IDE1007 Der Name "propItems" ist im aktuellen Kontext nicht vorhanden. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 55 Aktiv
Fehler IDE1007 Der Name "ToString" ist im aktuellen Kontext nicht vorhanden. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 57 Aktiv
Fehler IDE1007 Der Name "ToString" ist im aktuellen Kontext nicht vorhanden. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 58 Aktiv
Fehler CS0236 Ein Feldinitialisierer kann nicht auf das nicht statische Feld bzw. die nicht statische Methode oder Eigenschaft "Form1.data" verweisen. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 50 Aktiv
Fehler CS0236 Ein Feldinitialisierer kann nicht auf das nicht statische Feld bzw. die nicht statische Methode oder Eigenschaft "Form1.image" verweisen. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 51 Aktiv
Fehler CS1031 Typ erwartet. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 57 Aktiv
Fehler CS1031 Typ erwartet. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 58 Aktiv
Fehler CS1031 Typ erwartet. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 58 Aktiv
Fehler CS1022 Typ- oder Namespacedefinition oder Dateiende erwartet. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 62 Aktiv
Fehler CS1519 Ungültiges Token ""iD: 0x"" in Klassen-, Struktur- oder Schnittstellenmemberdeklaration. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 58 Aktiv
Fehler CS1519 Ungültiges Token ""Property Item "" in Klassen-, Struktur- oder Schnittstellenmemberdeklaration. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 57 Aktiv
Fehler CS1519 Ungültiges Token ""x"" in Klassen-, Struktur- oder Schnittstellenmemberdeklaration. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 58 Aktiv
Fehler CS1519 Ungültiges Token "(" in Klassen-, Struktur- oder Schnittstellenmemberdeklaration. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 57 Aktiv
Fehler CS1519 Ungültiges Token "(" in Klassen-, Struktur- oder Schnittstellenmemberdeklaration. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 57 Aktiv
Fehler CS1519 Ungültiges Token "(" in Klassen-, Struktur- oder Schnittstellenmemberdeklaration. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 58 Aktiv
Fehler CS1519 Ungültiges Token "(" in Klassen-, Struktur- oder Schnittstellenmemberdeklaration. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 58 Aktiv
Fehler CS1519 Ungültiges Token ")" in Klassen-, Struktur- oder Schnittstellenmemberdeklaration. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 55 Aktiv
Fehler CS1519 Ungültiges Token ")" in Klassen-, Struktur- oder Schnittstellenmemberdeklaration. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 55 Aktiv
Fehler CS1519 Ungültiges Token ")" in Klassen-, Struktur- oder Schnittstellenmemberdeklaration. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 57 Aktiv
Fehler CS1519 Ungültiges Token "++" in Klassen-, Struktur- oder Schnittstellenmemberdeklaration. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 59 Aktiv
Fehler CS1519 Ungültiges Token "++" in Klassen-, Struktur- oder Schnittstellenmemberdeklaration. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 59 Aktiv
Fehler CS1519 Ungültiges Token "foreach" in Klassen-, Struktur- oder Schnittstellenmemberdeklaration. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 55 Aktiv
Fehler CS1519 Ungültiges Token "in" in Klassen-, Struktur- oder Schnittstellenmemberdeklaration. WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 55 Aktiv
Nachricht IDE1006 Verstoß gegen Benennungsregel: Diese Wörter müssen mit Großbuchstaben beginnen: meta WindowsFormsApp2 D:\Marcus\Programmierung\Visual Studio Community 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs 49 Aktiv

Python Chronometer

$
0
0
Hello,

I'm trying to build a chronometer as my first Python project, and I got it working to the point where when I press STOP, the time that has passed since i pressed the START button is displayed both on terminal and on the main window.

What I'm having trouble to do right now is constantly displaying the time that has passed since i pressed the START button. I'm not even sure if it's possible due to the way my program is designed (I'm not counting the time, I'm getting a start_time when i press the START button and a stop_time when i press the STOP button, and then calculating the delta_time)

Here is my code so far:
from tkinter import *
import datetime

def start_fun():
	global start_time
	start_time = datetime.datetime.now()
	print(start_time)

def stop_fun():
	global stop_time
	stop_time = datetime.datetime.now()
	print(stop_time)
	delta()
	update_label()

def delta():
	global delta_time
	delta_time = stop_time - start_time
	print(delta_time)

def update_label():
	tempo = delta_time
	timer.config(text=str(tempo))

root = Tk()

root.geometry("300x50")
root.title("vChronometer")

timer = Label(root, text="Hello, World!", font=(None, 14))
timer.place(x=100, y=15)

start = Button(root, width=8, text="START", command=start_fun)
start.place(x=0,y=0)

stop = Button(root, width=8, text="STOP", command=stop_fun)
stop.place(x=0,y=25)

root.mainloop()





Is it even possible to display the delta_time every millisecond or so?
Any hints on how to proceed?

Reset Password Script Using PHP & Mysql

$
0
0
I am working on reset password system, first users need to input their email to get a link to reset the password. Here is the link that does that
 <?php
// Connect to MySQL
    $username = "ridtalk_user"; 
    $password = "forwardever1447"; 
    $host = "localhost"; 
    $dbname = "ridtalk_db"; 
try {
$conn = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8", $username, $password);
}
catch(PDOException $ex) 
    { 
        $msg = "Failed to connect to the database"; 
    } 

// Was the form submitted?
if (isset($_POST["ForgotPassword"])) {
	
	// Harvest submitted e-mail address
	if (filter_var($_POST["email"], FILTER_VALIDATE_EMAIL)) {
		$email = $_POST["email"];
		
	}else{
		echo "email is not valid";
		exit;
	}

	// Check to see if a user exists with this e-mail
	$query = $conn->prepare('SELECT email FROM ridtalk_table WHERE email = :email');
	$query->bindParam(':email', $email);
	$query->execute();
	$userExists = $query->fetch(PDO::FETCH_ASSOC);
	$conn = null;
	
	if ($userExists["email"])
	{
		// Create a unique salt. This will never leave PHP unencrypted.
		$salt = "498#2D83B631%3800EBD!801600D*7E3CC13";

		// Create the unique user password reset key
		$password = hash('sha512', $salt.$userExists["email"]);

		// Create a url which we will direct them to reset their password
		$pwrurl = "www.ridtalk.net/prot/script/reset_password.php?q=".$password;
		
		// Mail them their key
		$mailbody = "Dear user,\n\nIf this e-mail does not apply to you please ignore it. It appears that you have requested a password reset at our website www.yoursitehere.com\n\nTo reset your password, please click the link below. If you cannot click it, please paste it into your web browser's address bar.\n\n" . $pwrurl . "\n\nThanks,\nThe Administration";
		mail($userExists["email"], "www.yoursitehere.com - Password Reset", $mailbody);
		echo "Your password recovery key has been sent to your e-mail address.";
		
	}
	else
		echo "No user with that e-mail address exists.";
}
?>[code] 


After getting the link, they need to rest their password with this script

[code]<?php

// Connect to MySQL
    $username = "ridtalk_user"; 
    $password = "forwardever1447"; 
    $host = "localhost"; 
    $dbname = "ridtalk_db"; 
try {
$conn = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8", $username, $password);
//$conn = new PDO('mysql:host=localhost;dbname=test', 'root', '');
}
catch(PDOException $ex) 
    { 
        $msg = "Failed to connect to the database"; 
    } 
    
// Was the form submitted?
if (isset($_POST["ResetPasswordForm"]))
{
	// Gather the post data
	$email = $_POST["email"];
	$password = $_POST["password"];
	$confirmpassword = $_POST["confirmpassword"];
	$hash = $_POST["q"];

	// Use the same salt from the forgot_password.php file
	$salt = "498#2D83B631%3800EBD!801600D*7E3CC13";

	// Generate the reset key
	$resetkey = hash('sha512', $salt.$email);

	// Does the new reset key match the old one?
	if ($resetkey == $hash)
	{
		if ($password == $confirmpassword)
		{
			//has and secure the password
			$password = hash('sha512', $salt.$password);

			// Update the user's password
				$query = $conn->prepare('UPDATE ridtalk_table SET password = :password WHERE email = :email');
				$query->bindParam(':password', $password);
				$query->bindParam(':email', $email);
				$query->execute();
				$conn = null;
			echo "Your password has been successfully reset.";
		}
		else
			echo "Your password's do not match.";
	}
	else
		echo "Your password reset key is invalid.";
}

?>



Am getting error "Your password reset key is invalid"
What am i not doing write?

How to make a key for program selling?

$
0
0
I participate in a small startup. We decided to monetize the game by selling licenses. And so I have a question about creating license keys. How do you create keys? How to avoid handing over keys to others?

import multiple data

$
0
0
Hi Guys,

I have a problem to import bulk data from other applicaiton.

I am using this following code to insert the data from other application to erp application.

 inv = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryGenEntry)
inv.Lines.BaseEntry = doc_entry
inv.Lines.BaseType = 202
inv.Lines.Quantity = qty
inv.Lines.TransactionType = SAPbobsCOM.BoTransactionTypeEnum.botrntComplete
inv.Lines.WarehouseCode = store
inv.Lines.Add()
inv.Lines.BaseEntry = doc_entry
inv.Lines.BaseType = 202
inv.Lines.Quantity = qty1
inv.Lines.TransactionType = SAPbobsCOM.BoTransactionTypeEnum.botrntReject
inv.Lines.WarehouseCode = store
inv.Lines.Add()





The import is failed because my data have difference quantity and some of the reject and complete. in the above code, my data entry no. is filled in the doc_entry.

I have made some changes as follows:
if oRec2.Fields.Item("TransactionType").value = 'C' then
inv.Lines.BaseEntry = doc_entry
inv.Lines.BaseType = 202
inv.Lines.Quantity = qty
inv.Lines.TransactionType = SAPbobsCOM.BoTransactionTypeEnum.botrntComplete
inv.Lines.WarehouseCode = store
inv.Lines.Add()
end if
if oRec2.Fields.Item("TransactionType").value = 'R' then 
then 
inv.Lines.BaseEntry = doc_entry
inv.Lines.BaseType = 202
inv.Lines.Quantity = qty1
inv.Lines.TransactionType = SAPbobsCOM.BoTransactionTypeEnum.botrntReject
inv.Lines.WarehouseCode = store
inv.Lines.Add



but the import proces is failed. I appreciate your help so much. Thank you


Rgds,
Steve

Illegal argument exception in getDeclaredConstructor

$
0
0
I tried accessing the constructor for a class using reflection.

getDeclaredConstructor (String.class,List.class,List.class,List.class,List.class)
And my actual constructor is a constructor with 1 String parameter and 4 two dimensional list. But this throws Illegal argument exception:wrong number of parameters. But if I pass just 1 or 2 parameters it throws no such method exception not illegal argument. Why this happens?

Solr/curl error when trying to set copy-field

$
0
0
I got at this part of solr ref guide exercise:

https://lucene.apache.org/solr/guide/7_6/solr-tutorial.html#create-a-catchall-copy-field

all working fine, normal solr and other curl statements, until I got to doing:

curl.exe -X POST -H 'Content-type:application/json' --data-binary '{"add-copy-field":{"source":"*","dest":"_text_"}}' http://localhost:8983/solr/films/schema


// My windows 10 system seems to need curl.exe for all, which I tried after seeing a stack exchange post for previous error.

which gave me an error:

"msg":"JSON Parse Error: char=*,position=26 AFTER='{add-copy-field : {source:*' BEFORE=',dest:_text_}}'"



Searched for the main part of the error and found nothing. Any one have a idea what could be the problem? Maybe another difference like the exe thing that must go some other way? I tried to find a windows copy field guide but found nothing. I thought maybe the * didn't not need " around it, as I had to change for one thing in the past, but removing that just gave same error.

I also got this huge thing after error part listed above but can make no sense of it

Quote

"trace":"org.noggit.JSONParser$ParseException: JSON Parse Error: char=*,position=26 AFTER='{add-copy-field : {source:*' BEFORE=',dest:_text_}}'\r\n\tat org.noggit.JSONParser.err(JSONParser.java:419)\r\n\tat org.noggit.JSONParser.handleNonDoubleQuoteString(JSONParser.java:775)\r\n\tat org.noggit.JSONParser.next(JSONParser.java:981)\r\n\tat org.noggit.JSONParser.nextEvent(JSONParser.java:1061)\r\n\tat org.noggit.ObjectBuilder.getObject(ObjectBuilder.java:126)\r\n\tat org.noggit.ObjectBuilder.getVal(ObjectBuilder.java:56)\r\n\tat org.apache.solr.common.util.CommandOperation.parse(CommandOperation.java:286)\r\n\tat org.apache.solr.common.util.CommandOperation.readCommands(CommandOperation.java:350)\r\n\tat org.apache.solr.common.util.CommandOperation.readCommands(CommandOperation.java:326)\r\n\tat org.apache.solr.api.ApiBag.getCommandOperations(ApiBag.java:289)\r\n\tat org.apache.solr.servlet.HttpSolrCall.getCommands(HttpSolrCall.java:1073)\r\n\tat org.apache.solr.servlet.SolrRequestParsers$1.getCommands(SolrRequestParsers.java:245)\r\n\tat org.apache.solr.schema.SchemaManager.performOperations(SchemaManager.java:77)\r\n\tat org.apache.solr.handler.SchemaHandler.handleRequestBody(SchemaHandler.java:90)\r\n\tat org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:199)\r\n\tat org.apache.solr.core.SolrCore.execute(SolrCore.java:2541)\r\n\tat org.apache.solr.servlet.HttpSolrCall.execute(HttpSolrCall.java:709)\r\n\tat org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:515)\r\n\tat org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:377)\r\n\tat org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:323)\r\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1634)\r\n\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533)\r\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)\r\n\tat org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)\r\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)\r\n\tat org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)\r\n\tat org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)\r\n\tat org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)\r\n\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1317)\r\n\tat org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)\r\n\tat org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)\r\n\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)\r\n\tat org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)\r\n\tat org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1219)\r\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)\r\n\tat org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:219)\r\n\tat org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)\r\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)\r\n\tat org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(RewriteHandler.java:335)\r\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)\r\n\tat org.eclipse.jetty.server.Server.handle(Server.java:531)\r\n\tat org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:352)\r\n\tat org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)\r\n\tat org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:281)\r\n\tat org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)\r\n\tat org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)\r\n\tat org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)\r\n\tat org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)\r\n\tat org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)\r\n\tat org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)\r\n\tat org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)\r\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:762)\r\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:680)\r\n\tat java.base/java.lang.Thread.run(Thread.java:834)\r\n",
"code":500}}

Column does not belong to table

$
0
0
Hello,

Below is my query which works fine in Management Studio but when I run the code in vb.net it gives me the error below:

 dbconn.AddParams("@d1", txtReceipt.Text)
            dbconn.executequery("SELECT tblFeePayment.ID AS ReceiptNO, tblFeePayment.admission_no, tblSession.ID as sessionid, tblClass.ID as classid,  
                         tblFeePayment.section_id as sectionid,  tblFeePayment.classfee, tblFeePayment.catdiscount, tblFeePayment.studiscount, tblFeePayment.feetype_id, 
                         tblFeePayment.feepart_id, tblFeePayment.payable, tblFeePayment.paidamount, tblFeePayment.paid, tblFeePayment.paiddate, tblSection.SectionName, 
                         tblClass.ClassName, tblSession.session, tblStuCategory.Category, tblStudent.StudentName, tblStudent.FatherName
FROM            tblFeePayment INNER JOIN
                         tblSection ON tblFeePayment.section_id = tblSection.ID INNER JOIN
                         tblClass ON tblSection.class_id = tblClass.ID INNER JOIN
                         tblSession ON tblClass.session_id = tblSession.ID INNER JOIN
                         tblEnrollment ON tblFeePayment.enroll_ID = tblEnrollment.ID AND tblSection.ID = tblEnrollment.Section_ID INNER JOIN
                         tblStudent ON tblFeePayment.admission_no = tblStudent.AdmissionNo AND tblEnrollment.AdmissionNo = tblStudent.AdmissionNo INNER JOIN
                         tblStuCategory ON tblFeePayment.category_id = tblStuCategory.ID AND tblEnrollment.Category_ID = tblStuCategory.ID WHERE tblFeePayment.ID = @d1")



in this line
cmbSession.SelectedValue = dbconn.dt.Rows(0).Item("sessionid")

Error:

Quote

the error is
An unhandled exception of type 'System.ArgumentException' occurred in System.Data.dll

Additional information: Column 'sessionid' does not belong to table .



If I run the below code it show me all the field names correctly and the values as well

For i As Integer = 0 To dbconn.dt.Columns.Count - 1
                    MsgBox(dbconn.dt.Columns(i).ColumnName & " " & dbconn.dt.Rows(0).Item(i))
                Next


pls help.

bound must be positive (IllegalArgumentException)

$
0
0
Hi, I have an integer Queue (as LinkedList<Integer>) and I want to add random integers. However, I always get the error mentioned in the title. Why? My code is a little more complicated but I try to put it simple:

RandomInteger queue = new RandomInteger();

for(int i = 0; i < 10; i++) {
   queue.add(otherClass.getRandomInteger());
}



The method that creates a random integer is in a different class. Any ideas? I thought you can add something even to an empty queue. I read that it has something to do with 0 which is not allowed. But where do I call such a bound?

Hibernate custom type

$
0
0
Hi,
I have such a problem in analyse the following piece of code:
public class BitSetType
        extends AbstractSingleColumnStandardBasicType<BitSet>
        implements DiscriminatorType<BitSet> {

    public static final BitSetType INSTANCE = new BitSetType();

    public BitSetType() {
        super( VarcharTypeDescriptor.INSTANCE, BitSetTypeDescriptor.INSTANCE );
    }

    @Override
    public BitSet stringToObject(String xml) throws Exception {
        return fromString( xml );
    }

    @Override
    public String objectToSQLString(BitSet value, Dialect dialect) throws Exception {
        return toString( value );
    }

    @Override
    public String getName() {
        return "bitset";
    }

}


the source I am using: https://docs.jboss.org/hibernate/orm/5.2/userguide/html_single/Hibernate_User_Guide.html#domain-model

The issue is that I can't find following function declarations stringToObject,objectToSqlString,getName in AbstractSingleColumnStandardBasicType nor DiscriminatorType. Where is this particular overriding come from?

multithreading same object

$
0
0
Hi,

I want two threads of the same class/ instance use the same method. The method gets a lot of input that needs to be worked on and throws several exceptions. I just want my threads to work on different input. I used a LinkedList. While this list contains elements, I want each thread to take the first, do the work, and then remove it. But when the first thread takes the first element, my second thread has to take the next element. The first one is already used. They are not supposed to work on the same element. I tried using synchronized but it just means that they will work on one after another. It would be nice if they could work simultaneously. Here is my code:

	public void run() {
		while (this.queue.size() > 0 && Thread.currentThread().isInterrupted() == false) 
		{
			try 
			{
					postEntry(queue.getFirst());
               //when I print out the first Element here, I get a loop. I keeps printing out everything
					queue.removeFirst();
				}
				this.count++;
			} 
			catch (AccountAlreadyOpenedException e) 
			{
					this.queue.add(this.queue.getFirst());
					this.queue.removeFirst();
			} 
			catch (InputInvalidException e) 
			{
				synchronized (this) 
				{
					this.queue.removeFirst();
				}
			} 
		}
		Thread.currentThread().interrupt();
	}



I used simple prints to see how far my threads come. I don't know why there is an infinite loop. Maybe I didn't understand threads that well. Aren't they supposed to execute each line once? What am I missing here?

Simple machine modification

$
0
0
I'm learning assembly lately, got a simple machine and I'm learning the basics with it.

After a few weeks I've started wanting to optimize and add new instructions apart of the basic, ADD CMP MOV BEQ and wanna add the new optimized functions to the control unit but I'm unsure of how to do it, I've done the tables of what happens with every part of the instructions but not sure how to implement it.

Here is my control unit:



And the instructions table I made:



I did an optimized one and not sure how to implement it correctly in the RAM from the control unit.
Viewing all 51036 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>