PC Nerd Posted March 5, 2007 Share Posted March 5, 2007 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 Link to comment https://forums.phpfreaks.com/topic/41229-solved-update-querys-mot-working-but-select-querys-work/ Share on other sites More sharing options...
tauchai83 Posted March 5, 2007 Share Posted March 5, 2007 what i see here the query is correct. Maybe u try to change '".$to_ID."' to '$to_ID' only and see what happen. the spelling of the field and variable correct? double check first. Link to comment https://forums.phpfreaks.com/topic/41229-solved-update-querys-mot-working-but-select-querys-work/#findComment-199703 Share on other sites More sharing options...
PC Nerd Posted March 5, 2007 Author Share Posted March 5, 2007 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??? Link to comment https://forums.phpfreaks.com/topic/41229-solved-update-querys-mot-working-but-select-querys-work/#findComment-199705 Share on other sites More sharing options...
mmarif4u Posted March 5, 2007 Share Posted March 5, 2007 Can u post ur whole sql code. Link to comment https://forums.phpfreaks.com/topic/41229-solved-update-querys-mot-working-but-select-querys-work/#findComment-199711 Share on other sites More sharing options...
PC Nerd Posted March 5, 2007 Author Share Posted March 5, 2007 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); Link to comment https://forums.phpfreaks.com/topic/41229-solved-update-querys-mot-working-but-select-querys-work/#findComment-199715 Share on other sites More sharing options...
Greaser9780 Posted March 5, 2007 Share Posted March 5, 2007 Why do you have mysqli_query instead of mysql_query? Link to comment https://forums.phpfreaks.com/topic/41229-solved-update-querys-mot-working-but-select-querys-work/#findComment-199719 Share on other sites More sharing options...
PC Nerd Posted March 5, 2007 Author Share Posted March 5, 2007 im running mysql v 5.1 or something liek that. i know its right cos its the same for every other query on the site. all the SELECT queries use it and they work Link to comment https://forums.phpfreaks.com/topic/41229-solved-update-querys-mot-working-but-select-querys-work/#findComment-199730 Share on other sites More sharing options...
Greaser9780 Posted March 5, 2007 Share Posted March 5, 2007 try adding the old or die(mysql_error()); to the end of the query. Then it will tell you an error if there is one Link to comment https://forums.phpfreaks.com/topic/41229-solved-update-querys-mot-working-but-select-querys-work/#findComment-199734 Share on other sites More sharing options...
PC Nerd Posted March 5, 2007 Author Share Posted March 5, 2007 no error Link to comment https://forums.phpfreaks.com/topic/41229-solved-update-querys-mot-working-but-select-querys-work/#findComment-199736 Share on other sites More sharing options...
Greaser9780 Posted March 5, 2007 Share Posted March 5, 2007 Can you post some more of that page? Link to comment https://forums.phpfreaks.com/topic/41229-solved-update-querys-mot-working-but-select-querys-work/#findComment-199738 Share on other sites More sharing options...
PC Nerd Posted March 5, 2007 Author Share Posted March 5, 2007 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 Link to comment https://forums.phpfreaks.com/topic/41229-solved-update-querys-mot-working-but-select-querys-work/#findComment-199754 Share on other sites More sharing options...
redarrow Posted March 5, 2007 Share Posted March 5, 2007 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; } Link to comment https://forums.phpfreaks.com/topic/41229-solved-update-querys-mot-working-but-select-querys-work/#findComment-199757 Share on other sites More sharing options...
redarrow Posted March 5, 2007 Share Posted March 5, 2007 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()); ?> Link to comment https://forums.phpfreaks.com/topic/41229-solved-update-querys-mot-working-but-select-querys-work/#findComment-199761 Share on other sites More sharing options...
PC Nerd Posted March 5, 2007 Author Share Posted March 5, 2007 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 Link to comment https://forums.phpfreaks.com/topic/41229-solved-update-querys-mot-working-but-select-querys-work/#findComment-199768 Share on other sites More sharing options...
redarrow Posted March 5, 2007 Share Posted March 5, 2007 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()); } ?> Link to comment https://forums.phpfreaks.com/topic/41229-solved-update-querys-mot-working-but-select-querys-work/#findComment-199769 Share on other sites More sharing options...
PC Nerd Posted March 5, 2007 Author Share Posted March 5, 2007 for some reason thats not working??? anything else Link to comment https://forums.phpfreaks.com/topic/41229-solved-update-querys-mot-working-but-select-querys-work/#findComment-199773 Share on other sites More sharing options...
redarrow Posted March 5, 2007 Share Posted March 5, 2007 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()); } ?> Link to comment https://forums.phpfreaks.com/topic/41229-solved-update-querys-mot-working-but-select-querys-work/#findComment-199776 Share on other sites More sharing options...
PC Nerd Posted March 5, 2007 Author Share Posted March 5, 2007 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 Link to comment https://forums.phpfreaks.com/topic/41229-solved-update-querys-mot-working-but-select-querys-work/#findComment-199785 Share on other sites More sharing options...
Greaser9780 Posted March 5, 2007 Share Posted March 5, 2007 If the form isn't too long could you post it? Link to comment https://forums.phpfreaks.com/topic/41229-solved-update-querys-mot-working-but-select-querys-work/#findComment-199788 Share on other sites More sharing options...
redarrow Posted March 5, 2007 Share Posted March 5, 2007 <?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()); } ?> Link to comment https://forums.phpfreaks.com/topic/41229-solved-update-querys-mot-working-but-select-querys-work/#findComment-199789 Share on other sites More sharing options...
PC Nerd Posted March 5, 2007 Author Share Posted March 5, 2007 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>"; Link to comment https://forums.phpfreaks.com/topic/41229-solved-update-querys-mot-working-but-select-querys-work/#findComment-199792 Share on other sites More sharing options...
redarrow Posted March 5, 2007 Share Posted March 5, 2007 echo "<p><input name='submit' type = 'submit' value = 'Send'></p>\n"; Link to comment https://forums.phpfreaks.com/topic/41229-solved-update-querys-mot-working-but-select-querys-work/#findComment-199794 Share on other sites More sharing options...
PC Nerd Posted March 5, 2007 Author Share Posted March 5, 2007 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 Link to comment https://forums.phpfreaks.com/topic/41229-solved-update-querys-mot-working-but-select-querys-work/#findComment-199801 Share on other sites More sharing options...
PC Nerd Posted March 5, 2007 Author Share Posted March 5, 2007 what do you mean by the form stuff you posted??? Link to comment https://forums.phpfreaks.com/topic/41229-solved-update-querys-mot-working-but-select-querys-work/#findComment-199802 Share on other sites More sharing options...
redarrow Posted March 5, 2007 Share Posted March 5, 2007 post your current code ok. Link to comment https://forums.phpfreaks.com/topic/41229-solved-update-querys-mot-working-but-select-querys-work/#findComment-199812 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.