Jump to content

mpsn

Members
  • Posts

    264
  • Joined

  • Last visited

Everything posted by mpsn

  1. That was simple! Just a question, so basically I am using an associative array where input tag's attribute is the name attribute with key/value being value attribute, is that right? Thanks.
  2. Hi, please can someone just help out! The installation is simple (download XAMPP, download SimpleTest, make a simple webpage, make a simple SimpleTest script and put the SimpleTest script, your webpage to test, SimpleTest dir inside htdocs!) Any help much appreciated!
  3. Hi, I want to be able to allow user to enter in <input type="text" >... the total XML files to upload on the first page so: my first page has form that asks user how many uploads form they want so (firstpage.html): <form method='post' action='outputTotalUploads.php' >... Then in second form (outputTotalUploads.php) is where it outputs the desired number of upload forms based on the first page: for loop to post each <form method='post' action='addToDb.php' >... Finally in third page (addToDb.php): for each uploaded file, do: //BUT HOW DO I GET THIS TOTAL?? add to database *My problem is HOW do I refer to the total number of uploads the user chose way back in the first page b/c I know you cannot have multiple action attribute in the form tag. Any help much appreciated!
  4. Hi, MasterAce, yes, it was the parenthesis that mysql was nitpicky about so now my register page works, and it ouputs the link Click here to login (login.php), BUT now on the login.php, I type in username userA, and password userA (I checked db and password was encrypted), it says" Please register!" Hi, thorpe, what do you mean output message comes first! Again, I hope any experts can help a fellow out and take a look at my other post (it is fairly three line script; I don't like to have to repost it otherwise I get warning...) Edit by thorpe: Don't spam one thread with another either or the same will apply Any help much appreciated!
  5. Hi, I don't know why it outputs" You are now registered BUT the user name and password don't show up in the database! I want to encrypt the passwords so maybe that is problem, I don't know, please read scripts below. here is register.php: ============== <html> <head></head> <body> <form method="post" action="" > <p>Create a username <input type="text" name="newUsername"/> </p> <p>Create a password <input type="password" name= "newPassword" /> </p> <p> <input type="submit" value="Make account now" name="makeAccountSubmit" /> </p> </form> <?php if(array_key_exists("makeAccountSubmit",$_POST) && !empty($_POST["newUsername"]) && !empty($_POST["newPassword"]) ) { //IF username doesn't exist, then store new user login info to db dummydpevx mysql_connect("localhost","root"); mysql_select_db("someDB"); $newUserName=$_POST["newUsername"]; $newPassword=crypt($_POST["newPassword"]); $usernameQuery=mysql_query("SELECT userName FROM users WHERE userName='$newUserName'"); if(mysql_num_rows($usernameQuery)==0) { $makeNewAccountQuery=mysql_query("INSERT INTO users userName,userPassword VALUES('$newUserName','$newPassword')"); print "You are now registered, <a href='login.php'>proceed to login</a>"; } if(mysql_num_rows($usernameQuery)==1) print "Username taken. Please make another one. <br />"; } here is login.php: ============ <html> <head></head> <body> <form method="post" action=""> <label>Username:</label> <input type="text" name="username" /> <br /> <label>Password:</label> <input type="password" name="password" /> <p> <input type="submit" value="Login" name="Login" /> <input type="reset" value="Reset" name="Reset" /> </p> </form> <?php if(array_key_exists("Login",$_POST) && !empty($_POST["username"]) && !empty($_POST["password"])) { $attemptedUsername=$_POST["username"]; $attemptedPassword=$_POST["password"]; mysql_connect("localhost","root"); mysql_select_db("someDB"); $getLoginInfoQuery=mysql_query("SELECT userName,userPassword FROM users WHERE userName=$attemptedUsername AND userPassword=$attemptedPassword"); $getLoginInfo=mysql_fetch_assoc($getLoginInfoQuery); $getUsername=$getLoginInfo["userName"]; $getPassword=crypt($getLoginInfo["userPassword"]); if(crypt($attemptedPassword,$getPassword)==$getPassword) { session_start();//NB: Start session BEFORE doing any session stuff! $_SESSION["isAuthenticated"]="userAuthenticated"; header("Location: xmlShredderIndex.php"); exit; } else print "Please register!"; } Also, if any has time, please see my other post, it is straightforward instructions to see if you get same error as me, thanks. http://www.phpfreaks.com/forums/index.php?topic=347639.msg1640652#msg1640652 Any help much appreciated!
  6. My website, I know it is not the localhost issue (as I said, XAMPP has Apache,MySQL and PHP all prebundled), and it is not SimpleTest b/c I have tried the same test on internet-based webpages like cnn.com etc, so that's why I figure it must be php.ini, if possible (it only takes 5 minutes or so), just install XAMPP or whatever used for localhost make a simple webpage that you store to C:\xampp\htdocs and install SimpleTest (put in C:\xampp\htdocs) and make make a new script (just copy my code but change info according to your webpage and directory) and put SimpleTest, your webpage, SimpleTest script for your webpage in htdocs and just run it. Sorry to be longwinded. Any help much appreciated!
  7. I use XAMPP (so I have Apache installed), but when I run this script from cmd, I get this message: Equal expectation fails at character 0 with [My Page:Home] and [bad requrest!] at [C:\xampp\htdocs\path\way\to\this\script for line 9] line 9 is my assertion: $this->assertTitle b/c I am pretty sure assertTitle checks the <title> tag If not too much trouble, if anyone just install simpletest and then copy my code but make up a simple webpage to run off your localhost (make sure put the simpletest dir in C:\xampp\htdocs along with your webpage of course) and test quickly for me what you get, that be great. Here is link on Web SimpleTest lesson: http://simpletest.org/en/web_tester_documentation.html Any help much appreciated.
  8. Hi, I want to use SimpleTest framework (unit test library) to test if a web page has the text set in the title tag, but I am using localhost, so I think that's why it doesn't run, does anyone know how to configure php.ini (I think it's security issue) here is script: ========= <?php require_once('simpletest/autorun.php'); require_once('simpletest/web_tester.php'); class TestOfMyWebPage extends WebTestCase { //test home page is up and running function testMyPageIndex() {//THIS function just goes to the page then asserts if title tag has "My Page:Home" text set $this->get("C:/xampp/htdocs/projectMyWebsite/MyPageIndex.html"); $this->assertTitle("My Page:Home");//test if the page contains this page content } } ?> Any help much appreciated!
  9. I just want to clarify: so let's say I use this: while($curEdgeRow=mysql_fetch_assoc($edgeQuery)) { if cur row in table edge has text node child { $query=mysql_query("SELECT edge_id FROM edge LIMIT 1");//READ ME: will this always refer to current row as while loop does its traversing??? $getEdgeId=mysql_fetch_assoc($query); $getEdgeIdToUse=$getEdgeId["edge_id"]; $getValQuery=mysql_query(//USE JOIN table edge , value where value.edge_id=$getEdgeIdToUse"); $getVal=mysql_fetch_assoc($getValQuery); if($getVal["val"]==NULL) print "null </br >"; else "nay <br />"; } } Please read the comment READ ME, b/c I still need to refer to the current row edge.edge_id, so that's the problem I am having, b/c if I know that, can't I just use: "SELECT value from value,edge WHERE value.edge_id=$getEdgeIdToUse" where $getEdgeIdToUse refers to the current row edge.edge_id? I hope this makes sense. Any help much appreciated!
  10. Thanks for checking it out: (edge) (value) edge_id source target value_id edge_id value ---------- -------- -------- ----------- ---------- -------- 1 email to 1 1 null 2 to toFirstName 2 2 Bob 3 from fromFirstName 3 3 Frank 4 closing closingText 4 4 Yours Sincerely I want to parse and insert an XML file to this db table and specifically I for a node with text (so tag nodes <toFirstName>Bob</toFirstName> or <closingText>Yours Sincerly</closingText>, I would like to traverse this whole table and if it is a parent node with text node child, then go to the corresponding table value to get the value (via FK) but I don't know how to always refer to the current table edge's edge_id in order to get the matching FK table value.value, I hope I am clear as to what I would like to make happen. Any help much appreciated!
  11. I was hoping there was a less redundant/hard coded way, b/c I want to change it so that user can type in how many images to upload, so then there would no way to use the method you showed me, but I guess I'll stick with 10 uploads and figure it out later, thanks though. Hey, if you are good with mysql, can you also take a look at my other post: http://www.phpfreaks.com/forums/index.php?topic=347404.0 Any help is much appreciated!
  12. Please, can someone help a fellow PHP programmer out???
  13. Sorry, what text box?
  14. I have 10 upload forms, so how do I count which one's have files uploaded to them b/c don't they all have different names as in: <input type='file' name='uploadA' > etc There is user logging in so only each user can upload to their online album. Any help much appreciated!
  15. I'm not sure what you mean, please elaborate, thanks.
  16. Hi, I want to let users upload multiple images to my online picture book, so after they press submit, HOW do I count the total $_FILES[someName]['name'] uploaded. I want to allow users to type in html form the total uploads they want and this will then display that many desired upload forms. I'm going to try count($_FILES[][]) and go from there first... Any help much appreciated!
  17. Hi, I want to maintain users who log in a webpage and each time they leave, I want to record the current time, so this sounds silly but do I just set in my db table in a field that tracks a user's last log in with DEFAULT: CURRENT_TIMESTAMP? db structure: user_id lastActivity lastSession (stores TIMESTAMP of last time user logged in) Any help much appreciated
  18. Hi, I get errors when trying to validate this schema. here is xml: ======== <?xml version="1.0" encoding="ISO-8859-1"?> <email> <message> <to> <toFirstName>Tove</toFirstName> <toLastName toType="common" style="swag">Smith</toLastName> </to> <from> <fromFirstName>Jani</fromFirstName> <fromLastName fromType="unique">Dravison</fromLastName> </from> <heading>Reminder</heading> <body> <prologue>Tis the night before Xmas...</prologue> </body> </message> </email> here is schema: =========== <?xml version="1.0" encoding="ISO-8859-1" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="email"> <xs:complexType> <xs:element name="message"> <xs:complexType> <xs:sequence> <xs:element name="to"> <xs:complexType> <xs:sequence> <xs:element name="toFirstName" type="xs:string"/> <xs:element name="toLastName"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="from"> <xs:complexType> <xs:sequence> <xs:element name="fromFirstName" type="xs:string"/> <xs:element name="fromLastName"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="heading" type="xs:string"/> <xs:element name="body"> <xs:complexType> <xs:prologue name="prologue" type="xs:string"/> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:attribute name="toType" type="xs:string" use="required"/> <xs:attribute name="style" type="xs:string" use="required"/> <xs:attribute name="fromType" type="xs:string" use="required"/> </xs:complexType> </xs:element> </xs:schema> here is script that has validateXML function to check email.xml: ============================================ ?php //FCN SOURCE: IBM //helper FCN: that switches b/t libxml error types function showLibXMLErrors($error) { $return = "<br/>\n"; switch ($error->level) { case LIBXML_ERR_WARNING: $return .= "<b>Warning $error->code</b>: "; break; case LIBXML_ERR_ERROR: $return .= "<b>Error $error->code</b>: "; break; case LIBXML_ERR_FATAL: $return .= "<b>Fatal Error $error->code</b>: "; break; } $return .= trim($error->message); if($error->file) { $return .= " in <b>$error->file</b>"; } $return .= " on line <b>$error->line</b>\n"; return $return; } //calls showLibXMLErrors to show appropriate libxml error for line in cur XML file function validateXML() { $errors = libxml_get_errors(); foreach ($errors as $error) { print showLibXMLErrors($error); } libxml_clear_errors(); } // Enable user error handling libxml_use_internal_errors(true); $xml = new DOMDocument(); $xml->load("email.xml"); if (!$xml->schemaValidate("email.xsd")) { print '<b>Errors Found!</b>'; validateXML(); } else { print "Validated <br />"; } Please just try to run the script, just copy the info from this post and you will see errors! Any help much appreciated!
  19. No, it doesn't work, here is exact db tables I use (I should have posted this first!) (edge) (value) edge_id source target flag value_id edge_id(FK) val --------- --------- -------- ----- ----------- ---------- ---- 1 letter to Ref 1 1 null 2 to ... Ref 2 2 null 3 ... ... Val 3 3 Bob 4 ... ... Val 4 4 Smith 5 ... ... Ref 5 5 null 6 ... ... Val 6 6 John 7 ... ... Val 7 7 normal 8 ... ... Val 8 8 Doe So when I run this script: while($curEdgeRow=mysql_fetch_assoc($edgeQuery)) { if($curEdgeRow["flag"]=="Val") { $query=mysql_query("SELECT edge_id FROM edge LIMIT 1");//does this refer to next row in while loop? $getEdgeId=mysql_fetch_assoc($query); $getEdgeIdToUse=$getEdgeId["edge_id"]; $getValQuery=mysql_query("SELECT val from value,edge WHERE value.edge_id<'$getEdgeIdToUse' LIMIT 1") or die("ERROR!"); $getVal=mysql_fetch_assoc($getValQuery); if($getVal["val"]==NULL) print "null </br >"; else "nay <br />"; } } It outputs to browser: null null null null null Any help much appreciated!
  20. Actually I think I got it. I will try first...
  21. Ok, let's say I have these db tables: (edge) (value) edge_id source target value_id edge_id value ---------- -------- -------- ----------- ---------- -------- 1 email to 1 1 null 2 to toFirstName 2 2 Bob while($curEdgeRow=mysql_fetch_assoc() ) { if some condition true from some field in cur row in table edge, then: $query=mysql_query("SELECT edge_id FROM edge LIMIT 1"); $getEdgeId=mysql_fetch_assoc($query); $getValQuery=mysql_query("SELECT val from value,edge WHERE value.edge_id='edge.$getEdgeId[edge_id]'"); $getVal=mysql_fetch_assoc($getValQuery); print $getVal["val"]; } I tried to do it like this but it doesn't work. So I want to always be able to retrieve the current row's edge_id and then get the value from the corresponding (via FK of course) table value.value, which I just print. So I just want that query "SELECT edge_id from edge LIMIT 1" to automatically refer to the current row in the while loop, if that is possible. Sorry for confusion, I hope this clarifies what I want. Any help much appreciated!
  22. but even if I join the tables, how do I still refer to the CURRENT ROW in table1 to get the edge_id from table1 to get the table2.edge_id(FK), that is the problem I am having. Can I just use: SELECT edge_id FROM edge LIMIT 1 to get edge_id from the current row I am at? Any help much appreciated!
  23. yes that is what I want.
  24. On a related issue, each time I traverse a db table1, I want it to look at the corresponding table2 (where table2 linked to table1 via FK of course) so what would be the SELECT query? let's say these table1, table2: (for table1 ) (for table2) tbl_1_ID fieldT1A tbl_2_ID tbl_1_ID(FK) fiedlT2A ----------- --------- ------------ ---------- ----------- 1 yes 1 1 hello 2 no 2 2 world 3 yes 3 3 bye so then in loop: while still rows in table1, do: if table1.fieldT1A is this, then: get corresponding table2.fieldT2A WHERE table1.tbl_1_ID=table2.tbl_1_ID? BUT how do I get the CURRENT table1's tbl_1_ID PK? Any help much appreciated!
  25. Appreciate the help!
×
×
  • 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.