can some one help please, i am running my code connecting the client to the server that connects to a database and when i am sending the info from the client to the server with the ID as an int, an error would appear saying: TypeError: must be string or buffer, not int.
And when changing the ID into a string at the server side, an error would appear saying: TypeError: an integer is required
Please help me because i got confused...
#!/usr/bin/python
import os import sys import socket import sqlite3 as lite
global s s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
class client:
#functions on the client side only send the data to the server side (their only job)
def login(ID, password):
try:
s.send(self, ID)
s.send(password)
except IOError:
print "Error! Cannot execute statement."
def signup(self, ID, Name, Email, Password):
try:
s.send(ID, Name)
s.send(Email, Password)
except IOError:
print "Error! Cannot execute statement."
def addContact(self, ID, name, email):
try:
s.send(ID, name)
s.send(email)
except IOError:
print "Error! Cannot execute statement."
class main: # create a socket object c = client() Register = "Register" Login = "Login"
# get local machine name
host = socket.gethostname()
port = 9999
# connection to hostname on the port.
s.connect((host, port))
Message = input("Login if you are a user. If you are new, register here so you could play checkers! \t")
if Message == Login:
ID = input("ID \t")
password = input("Password \t")
c.login(ID, password)
elif Message == Register:
ID = input("ID \t")
Name = input("Name \t")
Email = input("Email \t")
Password = input("Password \t")
c.signup(ID, Name, Email, Password)
elif Message == add:
ID = input("ID \t")
Name = input("Name \t")
Email = input("Email \t")
c.addContact(ID, name, email)
else:
exit()
# Receive no more than 1024 bytes
data = s.recv(1024)
s.close()
print("The time got from the server is %s" % data.decode('ascii'))
TypeError
message appears. Above that message, you'll see some text that starts withTraceback (most recent call last):
and then has several lines of the formFile <something>, line <some number>, in <something else>
. I need all of that information. – Kevin