Topic awaiting preservation: PHP and MySQL (Page 1 of 1) |
|
---|---|
Bipolar (III) Inmate From: Calgary Alberta Canada |
posted 07-17-2003 21:07
Maybe I'm just thick, but I can't figure out how to write to my database. Followinf tutorials, I can connect to my database propperly, but I cannot figure out how to write to it. I am not sure if I can read from it because there's nothing in the database to read. |
Maniac (V) Mad Scientist with Finglongers From: Cell 53, East Wing |
posted 07-17-2003 22:12
FlagMan: If I understand right use something like: code: $sql = "INSERT INTO my_table (field1, field2)
|
Bipolar (III) Inmate From: Calgary Alberta Canada |
posted 07-17-2003 23:41
No, the table was already created for me by the admin (just using some crappy free account to test stuff and learn php), and I can load it good, I just didn't know how to write to it. |
Bipolar (III) Inmate From: Calgary Alberta Canada |
posted 07-18-2003 00:08
I'm not really sure on this stuff, I can't find any solid doccumentation on it. This is what I have so far, it should create my table, but it just shows up like there's a syntax error (<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> ect...). I know the login works, becuase I have done that before with no errors, so it must be something wrong with "CREATE TABLE". I have no clue on the syntax of "CREATE TABLE", I pretty much just copied that off a tutorial, so I'm 99% certain that's where the error is. code: <?php
|
Maniac (V) Mad Scientist with Finglongers From: Cell 53, East Wing |
posted 07-18-2003 01:20
FlagMan: Well if the table has already been created then you will fail when you try to create the table again. |
Bipolar (III) Inmate From: Calgary Alberta Canada |
posted 07-18-2003 03:38
Now that I think about it, I don't think there is a table... Maybe I don't understand how this is setup, does this work like a spreadsheet with column and row names? or is there only one column with lots of rows? or neither? |
Paranoid (IV) Mad Scientist with Finglongers From: Germany |
posted 07-18-2003 10:50
http://www.mysql.com/doc . |
Maniac (V) Inmate From: under the bed |
posted 07-18-2003 14:37
quote:
|
Paranoid (IV) Inmate From: Minneapolis, MN, USA |
posted 07-18-2003 22:52
Well, if you copied and pasted, I see a problem right off the bat. You forgot to close out your query with a " right before the last parenthesis. That would definitely give you a syntax error (although I don't know what you mean by a doctype showing up on syntax error, usually it's a line # and an error type). |
Maniac (V) Mad Scientist with Finglongers From: Cell 53, East Wing |
posted 07-18-2003 23:17
I have noticed errors like that if there is an error (esp. with XHTML) - it seems to be a IE problem and if you view it in another browser you can see the actual error. Its a pain. |
Bipolar (III) Inmate From: Calgary Alberta Canada |
posted 07-24-2003 01:08
yes, when there is a syntax error (eg. a missing semi-colon) it just shows a blank page, which always has the same source. |
Bipolar (III) Inmate From: Calgary Alberta Canada |
posted 07-24-2003 01:38
Tyberius: I looked at that before, but it doesn't tell any PHP-mySQL related commands. |
Maniac (V) Inmate From: under the bed |
posted 07-24-2003 02:39
Well, TP's link, my previous link, the PHP Manual, and this tutorial at the Gurus Network - http://www.gurusnetwork.com/tutorials/php/dynamic_php_mysql_1.html should give you everything you need to get going.... |
Paranoid (IV) Mad Scientist with Finglongers From: Germany |
posted 07-24-2003 16:39
and there are not 'php-mysql-related' commands. |
Bipolar (III) Inmate From: Calgary Alberta Canada |
posted 07-25-2003 00:39
Ya, well the problem is, I don't know the PHP-SQL commands. |
Bipolar (III) Inmate From: Calgary Alberta Canada |
posted 07-25-2003 01:32
Well, I can't get PHPmyAdmin to work, and I don't know what kind of shit I have done to my database (I think I have created a table?). Is there a PHP script that shows what's in your database (if that's even possible)? code: mysql_query(" CREATE TABLE counter(
|
Paranoid (IV) Inmate From: Den Haag, Netherlands |
posted 07-25-2003 09:57
The query is a STRING ... so ... mysql_select('SELECT number FROM counter', $connection); ... might have a better chance of working ... |
Bipolar (III) Inmate From: Calgary Alberta Canada |
posted 07-28-2003 01:32
As I said, I copied that code from a tutorial, so they must have missed the quotation... code: mysql_query("CREATE TABLE counter( counter INT NOT NULL AUTO_INCREMENT, number INT NOT NULL, PRIMARY KEY (counter), UNIQUE UC_id (counter))");
|