Jump to content

Mysql Error

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
Whitey

Whitey

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 255 posts
My Submit form
<?php
include("header.inc");
?>
<form action="process.php" method="POST">
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><div align="center"><Font face="arial" size="1">
      
      <textarea name="txt_index" cols="60" rows="10" id="txt_index" style="width: 100%">
<?php
	$query = "SELECT * FROM home_info";
	$result = mysql_query($query, @mysql_connect(DB_SERVER, DB_USER, DB_PASS)) or die(mysql_error());
	$text = mysql_result($result, 0, "home_text");
	echo($text);
?>
      </textarea>
    </font></div></td>
  </tr>
  <tr>
    <td><div align="center"><Font face="arial" size="1">
      <input type="hidden" name="subindexpost" value="1">
	  <input type="submit" value="Submit">
	  <input type="reset" value="Reset">
    </font></div></td>
  </tr>
</table>
</form>
<?php
include("footer.inc");
?>

here is my process.php when its submitted
function procSubmitIndex(){
   	global $session, $form;
		$text = $_POST['txt_index'];
		$query = "UPDATE home_info SET home_text = $text";
		mysql_query($query, @mysql_connect(DB_SERVER, DB_USER, DB_PASS)) or die(mysql_error());
		include("header2.inc");
		echo("<center><font size='4'><font color='red'>Post has been submitted! Will redirect in 2 seconds</center></font>");
		echo("<META HTTP-EQUIV='refresh' CONTENT='2;main.php'>");
		//header("location:news.php");
		include("footer.inc");
		}
	
};

My Error
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 'Punky Jones Website!!! yay!!' at line 1

Now when i got to just the mysql cmd i type
UPDATE home_info SET home_text = "Hey whats up";

It will update.. So its a syntax problem for sure.. Any Help?

#2
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
 
$link = mysql_connect(DB_SERVER, DB_USER, DB_PASS);
if (!$link) {
    die('Could not connect: ' . mysql_error());
}

$query = "UPDATE `home_info` SET `home_text` = '" . $text . "'";
mysql_query($query, $link) or die('Could not update: ' . mysql_error());


#3
Whitey

Whitey

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 255 posts
error
Fatal error: Cannot redeclare username() (previously declared in C:\wamp\www\template2\functions.php:2) in C:\wamp\www\template2\functions.php on line 10

php code on that line
function username($username){

	$sql_username = 'select username

				  from users

				  where username = \'' . $username . '\';';

	$result = mysql_query($sql_username);

	$array = mysql_fetch_array($result);

	$username = $array['username'];

	return $username;

	}


#4
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
The function username() is already declared somewhere else. Possibly in another file you are including - thats not a mysql error.

#5
Guest_Jordan_*

Guest_Jordan_*
  • Guests
I can't help but comment on this line:

 $sql_username = 'select username
                  from users
                  where username = \'' . $username . '\';'; 

Why are you selecting the username and using the username as a condition? If you already know the username why in the world would you run a SQL query to find the same information you already have?

#6
Whitey

Whitey

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 255 posts
Well i first had 2 names.. 1 as a login name and 1 as a display name.. i decided to scatch that idea and i just replaced all of my mname to username.. haha