dflow Posted September 8, 2009 Share Posted September 8, 2009 im trying to rape dreamweaver into updating more than one table <?php require_once('../Connections/international.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE proposals, contact_form SET contact_form.StatusID = '$StatusID', proposals.StatusID= '$StatusID' WHERE proposals.RequestID = contact_form.RequestID AND proposals.ProposalID = '$ProposalID'", $StatusID = GetSQLValueString($_POST['StatusID'], "int"), $RequestID = GetSQLValueString($_POST['RequestID'], "int")); $ProposalID = $_GET['PropID']; mysql_select_db($database_international, $international); $Result1 = mysql_query($updateSQL, $international) or die(mysql_error()); $updateGoTo = "index.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>"> <label>StatusID <input type="text" name="StatusID" id="StatusID" /></label> </br> <label> <input type="submit" name="Submit" id="Submit" value="Submit" /> </label> <label>RequestID <input type="text" name="RequestID" id="RequestID" /> </label> <input type="hidden" name="MM_update" value="form1" /> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/173547-raping-dreamweaver/ Share on other sites More sharing options...
trq Posted September 9, 2009 Share Posted September 9, 2009 Firstly, Dreamweaver doesn't execute your code, php does. Secondly, you have failed to ask a question. Quote Link to comment https://forums.phpfreaks.com/topic/173547-raping-dreamweaver/#findComment-915147 Share on other sites More sharing options...
Garethp Posted September 9, 2009 Share Posted September 9, 2009 And I have to add this Violence against Dreamweaver Australia says no Quote Link to comment https://forums.phpfreaks.com/topic/173547-raping-dreamweaver/#findComment-915160 Share on other sites More sharing options...
trq Posted September 9, 2009 Share Posted September 9, 2009 And I have to add this Violence against Dreamweaver Australia says no I have to disagree. Dreamweaver should be killed, just look at that god awefull code it produces. Quote Link to comment https://forums.phpfreaks.com/topic/173547-raping-dreamweaver/#findComment-915161 Share on other sites More sharing options...
corbin Posted September 9, 2009 Share Posted September 9, 2009 Ummmm.... Was "raping" google translator gone wrong? Or do you just reallllyyy hate DreamWeaver? Anyway, on a helpful note: You can always add another mysql_query call. Quote Link to comment https://forums.phpfreaks.com/topic/173547-raping-dreamweaver/#findComment-915164 Share on other sites More sharing options...
Garethp Posted September 9, 2009 Share Posted September 9, 2009 And I have to add this Violence against Dreamweaver Australia says no I have to disagree. Dreamweaver should be killed, just look at that god awefull code it produces. You know what I hate about it the most? It teaches people that maybe, just maybe, they don't have to learn how to use Notepad or some other text editor Quote Link to comment https://forums.phpfreaks.com/topic/173547-raping-dreamweaver/#findComment-915165 Share on other sites More sharing options...
saltedm8 Posted September 9, 2009 Share Posted September 9, 2009 my opinion is that it is ok, as long as its used the right way.. dont use the wysiwyg and I see no harm it does produce valid code, as long as you know how to use it.. I don't use many of its 'features' but I do like the fact that some things I can do faster because of some self producing code.. I can code in a text editor if I wanted, and there is nothing wrong with my coding, I tried text editors in the past and dreamweaver gets the job done faster I find.. so, use it in code view, stay away from the wysiwyg and as long as you know how to code, I see no issue. although on the flip side, if you can get the job done faster in a text editor, then its personal choice Quote Link to comment https://forums.phpfreaks.com/topic/173547-raping-dreamweaver/#findComment-915168 Share on other sites More sharing options...
corbin Posted September 9, 2009 Share Posted September 9, 2009 What about IDE's that aren't designed to be a WYSIWYG editor? For example Netbeans? Quote Link to comment https://forums.phpfreaks.com/topic/173547-raping-dreamweaver/#findComment-915180 Share on other sites More sharing options...
dflow Posted September 9, 2009 Author Share Posted September 9, 2009 Firstly, Dreamweaver doesn't execute your code, php does. Secondly, you have failed to ask a question. as a "weekend coder", i started off with DW and discovered the beauty of PHP. so actually i am using notepad and even learning cakephp. actually i was frustrated with a simple piece of code i wrote and it drove me crazy and I didnt get any help with it(ADHD doesn't really help ) so i went back to DW to look at their logic and updated the query in their update form server behavior : if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE proposals, contact_form SET contact_form.StatusID = '$StatusID', proposals.StatusID= '$StatusID' WHERE proposals.RequestID = contact_form.RequestID AND proposals.ProposalID = '$ProposalID'", $StatusID = GetSQLValueString($_POST['StatusID'], "int"), $RequestID = GetSQLValueString($_POST['RequestID'], "int")); $ProposalID = $_GET['PropID']; i would like to update 2 tables from 1 form and control the redirection( avoiding the "resend" on refresh) , thus including a header before any output of course. i know it is a logical layout problem. i have done it with the following piece of code, the update query works fine but refeshing it by pressing "enter" in the address bar submits empty values so in fact the if (isset($_POST['submit']) isn't working. and where should i place the redirection header() ? here is the code <?php require_once('../Connections/international.php'); ?> <head> </head> <body> <form action="<?php echo $update_tables_action; ?>" method="post" enctype="multipart/form-data" name="form2"> <label>StatusID <input name="StatusID" type="text" id="StatusID" value=""> </label> <p> <label>RequestID <input name="RequestID" type="text" id="RequestID" value=""> </label> </p> <p> <label> <input type="submit" name="submit" id="button" value="Submit"> </label> </p> </form> </body> <?php $StatusID = $_POST['StatusID']; $ProposalID = $_GET['PropID']; $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("international", $con); $query="UPDATE proposals, contact_form SET contact_form.StatusID = '$StatusID', proposals.StatusID= '$StatusID' WHERE proposals.RequestID = contact_form.RequestID AND proposals.ProposalID = '$ProposalID'"; print($query); $update_tables_action = mysql_query($query) or trigger_error(mysql_error(),E_USER_ERROR); if (isset($_POST['submit'])) { echo "POST: <BR>"; print_r($_POST); } else { print ("no value entered"); }; mysql_close($con); ?> Quote Link to comment https://forums.phpfreaks.com/topic/173547-raping-dreamweaver/#findComment-915301 Share on other sites More sharing options...
Garethp Posted September 9, 2009 Share Posted September 9, 2009 Place it after the code you want to execute has been run, but before you output anything. The if(isset($_POST['submit'])) was put after your query is run, so it's only checking if the POST['submit'] is set AFTER you do your SQL. You want it to check that it exists BEFORE you do anything with $_POST Quote Link to comment https://forums.phpfreaks.com/topic/173547-raping-dreamweaver/#findComment-915304 Share on other sites More sharing options...
Adam Posted September 9, 2009 Share Posted September 9, 2009 Maaan, things I'd do to that dreamweaver b*tch! Quote Link to comment https://forums.phpfreaks.com/topic/173547-raping-dreamweaver/#findComment-915306 Share on other sites More sharing options...
Zane Posted September 9, 2009 Share Posted September 9, 2009 Not another one of these threads.... There's nothing wrong with using an IDE/WYSIWIG editor (such as Dreamweaver or Netbeans, etc, etc) and there's nothing wrong with using just Notepad either..(although you do seem kinda of retarded doing everything the hard way) Using notepad to do all your coding is like a primo award winning chef saying... "I don't have any use for a kitchen...I just cook outside over a bonfire...and widdle my knives out of wood too...using food I catch with my bare hands...non of that fancy grocery store stuff" If your coding needs are that of a person that needs drop and drag everything...which would lead up to an IDE (any IDE albeit) creating shitty code...then you shouldn't be coding in the first place. Write you code from scratch to begin with. No...not with notepad either..(get that out of your head. Notepad is like a caveman's dreamweaver or whatever your choice is). Most IDEs come with libraries anyway to help you along with your code writing to let you know what to type next anyway. Quote Link to comment https://forums.phpfreaks.com/topic/173547-raping-dreamweaver/#findComment-915308 Share on other sites More sharing options...
dflow Posted September 9, 2009 Author Share Posted September 9, 2009 Place it after the code you want to execute has been run, but before you output anything. The if(isset($_POST['submit'])) was put after your query is run, so it's only checking if the POST['submit'] is set AFTER you do your SQL. You want it to check that it exists BEFORE you do anything with $_POST cool the isset is working now! where should i place the redirection header()? <?php require_once('../Connections/international.php'); ?> <head> </head> <body> <form action="<?php echo $update_tables_action; ?>" method="post" enctype="multipart/form-data" name="form2"> <label>StatusID <input name="StatusID" type="text" id="StatusID" value=""> </label> <p> <label>RequestID <input name="RequestID" type="text" id="RequestID" value=""> </label> </p> <p> <label> <input type="submit" name="submit" id="button" value="Submit"> </label> </p> </form> </body> <?php $StatusID = $_POST['StatusID']; $ProposalID = $_GET['PropID']; $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } if (isset($_POST['submit'])) { mysql_select_db("international", $con); $query="UPDATE proposals, contact_form SET contact_form.StatusID = '$StatusID', proposals.StatusID= '$StatusID' WHERE proposals.RequestID = contact_form.RequestID AND proposals.ProposalID = '$ProposalID'"; print($query); $update_tables_action = mysql_query($query) or trigger_error(mysql_error(),E_USER_ERROR); echo "POST: <BR>"; print_r($_POST); } else { print ("no value entered"); }; mysql_close($con); ?> Quote Link to comment https://forums.phpfreaks.com/topic/173547-raping-dreamweaver/#findComment-915316 Share on other sites More sharing options...
MasterACE14 Posted September 9, 2009 Share Posted September 9, 2009 before any HTML output sounds good. Quote Link to comment https://forums.phpfreaks.com/topic/173547-raping-dreamweaver/#findComment-915318 Share on other sites More sharing options...
dflow Posted September 10, 2009 Author Share Posted September 10, 2009 so the redirection will go before the <form> but what about the POST vars? and my db is set to utf8_unicode_ci and the php and html set to: <?php mysql_query("SET NAMES utf8");?> and <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> non latin letters come out as ×××× in the value insert/update although in the print($query) they look fine Quote Link to comment https://forums.phpfreaks.com/topic/173547-raping-dreamweaver/#findComment-915772 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.