PDA

View Full Version : What is wrong?


SDP2006
07-18-2003, 05:49 PM
Could someone tell me what is wrong with what I have written below? I have blocked my password for my protection.


<?php
$location = "localhost";
$username = "peelesd";
$password = "*******";
$database = "db1";

$conn = @mysql_connect("$location","$username","$password")
or die("Could not connect: " . mysql_error());
if($conn){
@mysql_select_db($database,$conn) or die ("Could not open database");
}

CREATE TABLE Reminder
(
apptime int(10),
title varchar(25),
message varchar(25),
sendingtime int(10)
)
print ("SUCCESSFUL");
?>


Thanks

Spookster
07-18-2003, 07:16 PM
Originally posted by SDP2006
Could someone tell me what is wrong with what I have written below? I have blocked my password for my protection.


<?php
$location = "localhost";
$username = "peelesd";
$password = "*******";
$database = "db1";

$conn = @mysql_connect("$location","$username","$password")
or die("Could not connect: " . mysql_error());
if($conn){
@mysql_select_db($database,$conn) or die ("Could not open database");
}

CREATE TABLE Reminder
(
apptime int(10),
title varchar(25),
message varchar(25),
sendingtime int(10)
)
print ("SUCCESSFUL");
?>


Thanks

The title of your thread is inappropriate. You have been given warnings about this before. Please read our posting guidelines specifically part 2:

http://www.codingforums.com/postguide.htm

raf
07-18-2003, 07:41 PM
+ it's a PHP problem.

The problem is that you simply don't execute the query. Look into mysql_query()

http://www.php.net/mysql_query

SDP2006
07-18-2003, 09:32 PM
Sorry Spookster

How can it be a PHP question? It's mysql script!:p

raf
07-19-2003, 10:40 AM
How can it be a PHP question? It's mysql script! :confused: :confused:
Everything between "<?php" and "?>" is PHP script. mysql_query() is a PHP function. So is mysql_connect()

You use embedded sql there, thats right, but to PHP, it's just a variabel value.

And the reason why it's not working, is because you need to use the PHP function mysql_query() and you then need to check the returned value etc

SDP2006
07-19-2003, 03:41 PM
So, where do I need to put that ''mysql_query()''?

raf
07-19-2003, 05:38 PM
Your code should be something like

$sql_create = "CREATE TABLE Reminder(apptime int(10),title varchar(25),message varchar(25),sendingtime int(10))";
$result = mysql_query($sql_create, $conn);
if ($result){
print ("TABLE SUCCESSFULLY CREATED");
}
else {
print ("Table not created");
}

SDP2006
07-19-2003, 09:49 PM
Thanks raf

SDP2006
07-20-2003, 02:51 AM
How do I make my form (i know how to make the form, just not the action) action send it to the table in the database?

SDP2006
07-20-2003, 03:00 PM
How do I make my form (i know how to make the form, just not the action) action send it to the table in the database?

SDP2006
07-20-2003, 07:43 PM
Will someone answer my posts (above)?

raf
07-21-2003, 06:04 PM
Well, best start a new thread for this new question + start it in the approrpriate forum.

The action, in the form tag, needs to be the php-page with your script in. Like
<form action="myphppage.php" method="post" ...>

If you're not familiar with all this kinda stuff, best check a turorial like
http://www.mysql.com/articles/ddws/index.html
or run a search on google or so to find some tutorials.