1 (edited by Different55 2011-11-21 00:09)

Topic: MySQL Queries

So I have this CSS editor thing right here:

<?php

$db_host = 'dis my host';
$db_name = 'dis my db';
$db_username = 'dis my other stuff';
$db_password = 'dis my other stuff';

//Connect to the db
$db = mysql_connect($db_host,$db_username,$db_password);
if (!$con)
   {
   die('Could not connect: ' . mysql_error());
   }

//Grab any custom css that's already been entered...
$css = mysql_query("SELECT css FROM css");
mysql_select_db($db_name, $db);

//Insert any css entered into the form
if (isset($_POST['css'])) {
$css=$_POST['css'];
mysql_query("INSERT INTO pun_css (css) VALUES("$css")") or error("Unable to insert CSS into database.");
echo "CSS has been inserted into database successfully. Now you better pray it works right, nub.<br />";
echo "Now to see if it worked. If you can see something here:<br /> <blockquote>" . $_POST['css'] . "</blockquote><br />Then it worked.... maybe.";
};

//Display the css form if there's existing css
elseif (isset($css)) {
echo "<form action=csseditor.php method=post><textarea name=css rows=600 cols=800>" . $css . "</textarea><br /><input type=submit value=Submit /></form>";
};

//If there's no css in the db
else {
echo "<form action=csseditor.php method=post><textarea name=css rows=600 cols=800>Insert your custom css here.</textarea><br /><input type=submit value=Submit /></form>";
};
?>

and it doesn't work. I'm getting
Parse error: syntax error, unexpected T_VARIABLE in /home/a9376970/public_html/punstuff/csseditor/csseditor.php on line 24
if someone could walk me through the long list of things I'm doing wrong I would appreciate it.

Re: MySQL Queries

Hi.

It seems that your code stops at the $css variable on line 24.

I would have tried to seach in this line:

$css = mysql_query("SELECT css FROM css");

It may contain errors.

Re: MySQL Queries

I guess this topic can be closed. I finished the CSS Editor and a whole SuperEdit page for my admins a few days ago.