Jump to content

MySQL Query Problem


jonoc33

Recommended Posts

Hey guys,

This script is a code that adds a tactic into the database from a form on the previous page (that has fckeditor). It all works fine, but when you add images to the FCKeditor and submit them to the database, the img src="HTTP:// stuffs up the query. How would I go about fixing this?

 

And yes, I have tried mysql_real_escape_string, that does not work.

<?php
include("../include/constants.php");
$db_host = DB_SERVER;
$db_pass = DB_PASS;
$db_user = DB_USER;
$db_table = DB_NAME;
include("../include/header.php");
if(mysql_connect($db_host,$db_user,$db_pass)) {
	if(mysql_select_db($db_table)) {
		$tactic_name = mysql_real_escape_string($_POST['tacticname']);
		$tactic_map = mysql_real_escape_string($_POST["map"]);
		$tactic = mysql_real_escape_string($_POST['tactics']);
		if(mysql_query("INSERT INTO ".TBL_TACTICS." (tacticname, map, tactics) VALUES ('".$tactic_name."','".$tactic_map."','".$tactic."')")) {
			print '<center>Record added. <br /><a href=admin.php>Back</a> </center>';
		}
		else {
			print mysql_error();
		}
	}
	else {
		print mysql_error();
	}
}
else {
	print mysql_error();
}

?> 

Link to comment
Share on other sites

		if(mysql_query("INSERT INTO ".TBL_TACTICS." (tacticname, map, tactics) VALUES ('".$tactic_name."','".$tactic_map."','".$tactics."')")) {
			print '<center>Record added. <br /><a href=admin.php>Back</a> </center>';

It actually doesn't stuff up the query, the query works fine. But the thing that doesn't work is this:

 

I have a hidden textbox right that has all of the tactics from the database, when you hit an Edit button, it takes the POST data and you're able to edit it in a FCKeditor, although the image does not show up, and if you go into the source code, the image link disappears but the img src="" stays there.

Link to comment
Share on other sites

Replace....

 

if(mysql_query("INSERT INTO ".TBL_TACTICS." (tacticname, map, tactics) VALUES ('".$tactic_name."','".$tactic_map."','".$tactic."')")) {

 

with

 

$sql = "INSERT INTO ".TBL_TACTICS." (tacticname, map, tactics) VALUES ('".$tactic_name."','".$tactic_map."','".$tactic."')";
die($sql);
if (mysql_query($sql)) {

 

and show us the output.

Link to comment
Share on other sites

Edited.

Heres a bit more info for you guys:

 print "<td nowrap><form name=\"form2\" method=\"post\" action=\"action.php?do=tacticedit1\">";
 print "<input type=\"submit\" name=\"button\" id=\"button\" value=\"Edit\">";
     print "<input name=\"tacticname\" type=\"hidden\" id=\"tacticname\" value=\"".$values['tacticname']."\">";
 print "<input name=\"map\" type=\"hidden\" id=\"map\" value=\"".$values['map']."\">";
 print "<input name=\"tactics\" type=\"hidden\" id=\"tactics\" value=\"".mysql_real_escape_string($values['tactics'])."\">";
     print "</form></td></tr></table>";

There is what displays the edit button for the tactic. Notice the last input how it is a hidden tactics text box.

The output is the Edit button, then next to it it, strangely enough, it has ">. I believe this is to do with the last bit of img html, being />. This interferes with the PHP

"\">";

at the end of the print.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.