Ok, before I contact my server host, I figured I should make sure I'm
not just making a Python mistake. I get an Internal Server Error with
this script:
!#/usr/bin/python
import MySQLdb
db = MySQLdb.connect(host='xxx',
user='xxx',
passwd='xxx',
db='xxx') # changed this stuff
cursor = db.cursor()
cursor.execute("CREATE TABLE test (first varchar(10), second number(2))")
cursor.execute("INSERT INTO test (first, second) VALUES ('Hello', 33)")
cursor.execute("SELECT first, second FROM test")
cursor.fetchall()
cursor.close()
db.close()
All I do is run it directly with my URL, not sure if there's more to it. 7 1146
Are you able to connect to the DB using MySQL administrator?
Please learn to provide needed information when asking questions.
1. What does "run it directly with my URL" mean??
2. Show the traceback that you got.
This is probably causing a problem:
!#/usr/bin/python
It should be "#!", not "!#".
If that doesnt' work, add this line at the top of your script, to check
that the script is begin executed:
print "Content-Type: text/html\n\n"
print "Hello, World!"
If you still get an Internal Server Error put the following before you
import MySQLdb:
import cgitb; cgitb.enable()
Hope this helps,
- Alex Ross tr*******@gmail.com wrote: This is probably causing a problem: !#/usr/bin/python
It should be "#!", not "!#".
Ugh! So stupid! Thanks for correcting that, but it wasn't the only problem.
If that doesnt' work, add this line at the top of your script, to check that the script is begin executed:
print "Content-Type: text/html\n\n" print "Hello, World!"
Yes, this part gets executed.
If you still get an Internal Server Error put the following before you import MySQLdb:
import cgitb; cgitb.enable()
This produces a page with a ProgrammingError
( http://www.johnjsalerno.com/server_db_test.py), but the main part I
guess is this:
ProgrammingError: (1064, "You have an error in your SQL syntax. Check
the manual that corresponds to your MySQL server version for the right
syntax to use near 'number(2))' at line 1")
I'm not sure what I'm doing wrong with the syntax though. I don't think
I need semicolons (a sample I saw didn't use them).
BartlebyScrivener wrote: Are you able to connect to the DB using MySQL administrator?
Yes, through my hosting control panel. That's how I created the DB, but
I want to try to do everything else with mysqldb.
John Salerno wrote: Ok, before I contact my server host, I figured I should make sure I'm not just making a Python mistake. I get an Internal Server Error with this script:
Ok, got some help from Dennis Bieber and he solved it. I was using
number(), which is a SQL but not a MySQL command. I needed to use
something else, like int().
Thanks!
Dennis Lee Bieber wrote: Out of curiosity, which SQL reference listed "number" as a data type?
I was taking the sqlcourse.com tutorial yesterday, and it shows it here: http://sqlcourse.com/create.html
All the interactive examples in the tutorial seem to work with number().
But after work today I think I will go pick up a copy of the MySQL
Pocket Reference, just to have something to easily consult from now on. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Lodewijk van Haringhal |
last post by:
I'am new with javascritping not with programming. Is there nobody who can
help me with ths simple promblem? :) Please, please give me a hint.
Please help me with this script. I have two lists in...
|
by: francisco lopez |
last post by:
ok , first of all sorry if my english is not so good, I do my best.
here is my problem:
I don´t know much javascript so I wrote a very simple one to validate
a form I have on my webpage.
...
|
by: Lisa Pearlson |
last post by:
Hi,
My php application (on Apache/Linux) needs to do the following:
The PHP script receives a request from a client (binary), asking for certain
records of data.
My PHP script loops through...
|
by: hel |
last post by:
Hi
I have just adopted a PHP project and need some help understanding
DB_DataObject. I've looked around on the web and can't find a simple
explanation.
Basically, my MySQL database has no...
|
by: Me |
last post by:
Hello,
I have read all the reason why DOM purists don't like document.write
and innerHTML. I would like to be a good programmer and do the right
thing and not use them. But I need your help to...
|
by: gunimpi |
last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431
********************************************************
VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help
wanted...
|
by: eBob.com |
last post by:
I am trying to understand a bit of JavaScript from
http://developer.yahoo.com/maps/simple/jspost.html (appended below). I'd
appreciate help understanding two things it. The first is the...
|
by: astrogirl77 |
last post by:
Hi,
I'm new to Python and am hoping to find help with coding a Python script, applet.
I code in an old version of Visual Basic 4.0, I have a simple app that is about 3 and a half pages of code...
|
by: shawnwperkins |
last post by:
Hi Folks,
I'm new to Javascript and just need a little help. I downloaded a
script from Dynamic Drive's Web site and I'm trying to make a simple
modification and could use some help. :)
The...
|
by: souporpower |
last post by:
Hello All
I am trying to activate a link using Jquery. Here is my code;
<html>
<head>
<script type="text/javascript" src="../../resources/js/
jquery-1.2.6.js"</script>
<script...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |