Jump to content

[SOLVED] UPDATE querys mot working, but SELECT querys work


PC Nerd

Recommended Posts

hi guys

 

 

ive got the following query, it doesnt submit to the database, but it doesnt return an error??? ive got no idea whats happenig.

 

 

$Message_SQL = "INSERT INTO individual_messages ( `User_ID` , `To` , `From` , `From_ID` , `Subject` , `Message_Body` ) VALUES ('".$to_ID."', '".$to_Name."', '".$from_Name."', '".$from_ID."', '".$Subject."' , '".$New_Message."')";

 

can anyone spot an error???, thankx

ok

 

thanks but that didnt help.

 

 

i know that all my SELECT queryes work, becauase theyre displayed on the page, without error.

 

does anyone else have any ideas whats happening.  the query (mysqli_query()) works becauase its not returning an error. I dont know whether its relevent, but when i echo the variable that contains the result of the query, its empty. 

 

 

thanks..

 

 

anything else???

this is the code

 

 

its checked the variables and eched them so theyre fine.

 

$Message_SQL = "INSERT INTO individual_messages ( `User_ID` , `To` , `From` , `From_ID` , `Subject` , `Message_Body` ) VALUES ('".$to_ID."', '".$to_Name."', '".$from_Name."', '".$from_ID."', '".$Subject."' , '".$New_Message."')";

$Message_Query = mysqli_query($Message_SQL, $DB_Server);

ok, this page sensors words, but i will sensor the sensor list .

 

 







<?php

require("inc_files/Database_link.inc");
require("inc_files/Page_Data.inc");


function sensor_words() {


$New_Message = $_POST['Message_Body'];
$Sensor_list = array("#######");
$Sensor_Char_list = array("!", "@", "#", "$", "%", "^", "&", "*");


$loop = 1;

while($loop<=4) {

$Sensor_Char_Index = rand(0, ;

$Sensor_Char_Replace = $Sensor_Char_Replace . $Sensor_Char_list[$Sensor_Char_Index];
$loop ++;

}

#$New_Message = str_replace();

#$Sensor_Char_Replace = rand($Sensor_Char_list, 1).rand($Sensor_Char_list, 1).rand($Sensor_Char_list, 1).rand($Sensor_Char_list, 1);
foreach($Sensor_list as $Sensor_Word) {

	$New_Message = str_replace($Sensor_Word, $Sensor_Char_Replace, $New_Message);
return $New_Message;
}

$New_Message = sensor_words();

$to_Name = $_POST['To_Name'];
$to_ID = $_POST['To_ID'];
$from_Name = $_POST['From_Name'];
$from_ID = $_POST['From_ID'];
$Subject = $_POST['Subject'];



#$Message_SQL = "INSERT INTO individual_messages ( `User_ID` , `To` , `From` , `From_ID` , `Message_Body` ) VALUES($to_ID, $to_Name, $from_Name, $from_ID, $New_Message)";

$Message_SQL = "INSERT INTO individual_messages ( `User_ID` , `To` , `From` , `From_ID` , `Subject` , `Message_Body` ) VALUES ('".$to_ID."', '".$to_Name."', '".$from_Name."', '".$from_ID."', '".$Subject."' , '".$New_Message."')";

$Message_Query = mysqli_query($Message_SQL, $DB_Server) or die(mysql_error());
#	or die("ERROR 14  Your Message could not be sent");




}

 

 

 

hopefully this helps

 

 

thankx

what all this rubbish for

 

function sensor_words() {


$New_Message = $_POST['Message_Body'];
$Sensor_list = array("#######");
$Sensor_Char_list = array("!", "@", "#", "$", "%", "^", "&", "*");


$loop = 1;

while($loop<=4) {

$Sensor_Char_Index = rand(0, ;

$Sensor_Char_Replace = $Sensor_Char_Replace . $Sensor_Char_list[$Sensor_Char_Index];
$loop ++;

}

#$New_Message = str_replace();

#$Sensor_Char_Replace = rand($Sensor_Char_list, 1).rand($Sensor_Char_list, 1).rand($Sensor_Char_list, 1).rand($Sensor_Char_list, 1);
foreach($Sensor_list as $Sensor_Word) {

	$New_Message = str_replace($Sensor_Word, $Sensor_Char_Replace, $New_Message);
return $New_Message;
}

Try this please ok.

 

<?php
$SQL14 = "INSERT INTO individual_messages  (`User_ID` , `To` , `From`
, `From_ID` , `Subject` , `Message_Body` ) VALUES ('$to_ID', '$to_Name', '$from_Name', 
'$from_ID, '$Subject' , '$New_Message' )";
$result14 = mysql_query($result14, $DB_Server) or die(mysql_error());
?>

 

ok, a) that code sensors words from the array, but ive sensored it out fso it appears to be nothing.

 

b) that new sql doesnt work.  even though it displays no error on screen, even though the SQL reference in the query actually points to the query itself..... does this mean an error with errors???.  if so how do i fix it ... (xampp installation)  i tried changing the variable to the sql and it didnt do anything

 

thankx

try this as a test ok.

 

edited

use addslashes at least to protect database ok.

 

if works add the function above if it dosent work post the echoed query back ok.

 


<?php

require("inc_files/Database_link.inc");
require("inc_files/Page_Data.inc");


$to_Name =addslashes($_POST['To_Name']);
$to_ID =addslashes($_POST['To_ID']);
$from_Name =addslashes($_POST['From_Name']);
$from_ID =addslashes($_POST['From_ID']);
$Subject =addslashes($_POST['Subject']);

if($_POST['submit']){

$SQL14 = "INSERT INTO individual_messages  (`User_ID` , `To` , `From`
, `From_ID` , `Subject` , `Message_Body` ) VALUES ('$to_ID', '$to_Name', '$from_Name', 
'$from_ID, '$Subject' , '$New_Message' )";

echo $SQL14;

$result14 = mysql_query($SQL14, $DB_Server) or die(mysql_error());

}
?>

try this ok will work fingers crossed.

 

<?php

require("inc_files/Database_link.inc");
require("inc_files/Page_Data.inc");


$To_Name =addslashes($_POST['To_Name']);
$To_ID =addslashes($_POST['To_ID']);
$From_Name =addslashes($_POST['From_Name']);
$From_ID =addslashes($_POST['From_ID']);
$Subject =addslashes($_POST['Subject']);

if($_POST['submit']){

$SQL14 = "INSERT INTO individual_messages  (`User_ID` , `To` , `From`
, `From_ID` , `Subject` , `Message_Body` ) VALUES ('$To_ID', '$To_Name', '$From_Name', 
'$From_ID, '$Subject' , '$New_Message' )";

echo $SQL14;

$result14 = mysql_query($SQL14, $DB_Server) or die(mysql_error());

}
?>

sorry but still nothing.  bo echo no nothing.  im getin goutput elsewhere, but no output from this script

 

 

is there anything else i need to do, posibly within php config.  i just reinstalled xampp today, so there shouldnt be any errors from me changing anything in the config file....

 

 

 

thankx for your help

<?php
error_reporting(E_ALL);

require("inc_files/Database_link.inc");
require("inc_files/Page_Data.inc");


$To_Name =addslashes($_POST['To_Name']);
$To_ID =addslashes($_POST['To_ID']);
$From_Name =addslashes($_POST['From_Name']);
$From_ID =addslashes($_POST['From_ID']);
$Subject =addslashes($_POST['Subject']);

if($_POST['submit']){

$SQL14 = "INSERT INTO individual_messages  (`User_ID` , `To` , `From`
, `From_ID` , `Subject` , `Message_Body` ) VALUES ('$To_ID', '$To_Name', '$From_Name', 
'$From_ID, '$Subject' , '$New_Message' )";

echo $SQL14;

$result14 = mysql_query($SQL14, $DB_Server) or die(mysql_error());

}
?>

echo "<p>Quick Mesage.  Send a quick message to ".$Player_Info['User_Name'].":</p>\n";

echo "<p><form action = 'B_A-Message_Handler.php' method = 'POST' name = 'Quick_Message'>\n";

echo "<input type = 'hidden' name = 'To_Name' value = '".$Player_Info['Name']."'></input>\n";

echo "<input type = 'hidden' name = 'To_ID' value = '".$Player_Info['User_ID']."'></input>\n";

echo "<input type = 'hidden' name = 'From_ID' value = '".$Page_Data['User_ID']."'></input>\n";

echo "<input type = 'hidden' name = 'From_Name' value = '".$Page_Data['User_Name']."'></input>\n";

echo "<input type = 'text' name = 'subject' value = 'Quick Message'></input>";

echo "<p><textarea rows ='8' cols =  '40' name='Message_Body' maxlength='500'></textarea></p>\n";

echo "<p><input type = 'submit' value = 'Send'></p>\n";

echo "</form>";

INSERT INTO individual_messages (`User_ID` , `To` , `From` , `From_ID` , `Subject` , `Message_Body` ) VALUES ('1', '', 'Administration', '1, 'Quick Message' , 'thshadflusi gfolbay g' )

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in FILE on line 142

 

 

i fixed the mysql query error by switching the variables around and changing to mysqli instead as it should be

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.