ID:107250
 
I have a PHP PRoblem, and it's probably so simple I'm going to feel stupid.

if(isset($_POST["button"]))
{
$title = $_POST["title"];
$color = $_POST["color"];
$message = $_POST["message"];
$date = date("m/d/Y");
$by = $_SESSION["admin"];
mysql_query("INSERT INTO Blog (title, date, by, content, color)
VALUES ('$title', '$date', '$by', '$message', '$color')") or mysql_error();
$content = 'Thank you for posting this message.<br><br><a href="index.php">[Go Back]</a>';
}


The part that isn't working is the mysql_query().
You've spanned lines without telling PHP, maybe. Can't remember if PHP allows that, with something like \ on the end of the line.
That's not it, just checked to make sure.
Duelmaster409 wrote:
http://www.byond.com/members/Teka123

I made the CSS, I was using my page to test/preview it, now unless you can help me with my PHP problem, don't post here anymore.

kthx.
Why don't you output the query to yourself. Then you can try manually querying with it. My guess would be that you might have some character in one of those variables that is messing up the MYSQL syntax.
You need to make sure that you create a mysql connection, and use a database before you can call mysql_query().

http://php.net/manual/en/function.mysql-connect.php
http://www.php.net/manual/en/function.mysql-select-db.php

In any case, I recommend using mysqli over the old mysql driver.
Galactic Soldier wrote:
Stop ripping CSS's, learn how to make one yourself.

You're an idiot.

Unknown Person wrote:
You need to make sure that you create a mysql connection, and use a database before you can call mysql_query().

http://php.net/manual/en/function.mysql-connect.php
http://www.php.net/manual/en/function.mysql-select-db.php

In any case, I recommend using mysqli over the old mysql driver.

I have done this already.
mysql_connect(localhost,"root","not showing my password!:O"); 
mysql_select_db("Final Resurrection") or die("Could not connect to the database");
Neblim wrote:
Just pointing out a simple syntax error:

VALUES ('$title', '$date', '$by', '$message', '$color')") or mysql_error();

@Stephen: PHP doesn't need spanned lines. You're thinking of something like Python.

You sure that's a syntax error? As that was just the closing of the mysql_query from what I can see.