-
Posts
9,409 -
Joined
-
Last visited
-
Days Won
1
Everything posted by MadTechie
-
Same code, the only thing that would change is the $delimiter which is picked up from the form .
-
Okay you win.. its a tab Not sure why explode isn't working!! try $arr = explode("$delimiter", $line); if that fails use preg_split, that should work! $arr = preg_split("/$delimiter/", $line);
-
Can you attach one of the files so i can check, this form say they are 3 spaces but it could be be the parse to attach (click Additional Options...) bottom left than browse etc
-
Okay they are not tabs.. but 3 spaces add an extra option to the form <option value=" " selected>Triple Space
-
Yeah one item.. not creating 3 as expected can you post a sample of the text file.. attach it or paste into a code tag
-
okay well it seams $arr = explode($delimiter, $line); isn't working so i'll assume its a $delimiter problem to test try $arr = explode($delimiter, $line); //existing code var_dump($arr); die("Wait");
-
One thing i should point out is that if the data being imported has a single quote (') this is messing up the insert.. Try this $arr = array_map("mysql_real_escape_string",$arr); //<--Add $sql = "insert into Application values ('".implode("','", $arr) ."')"; //tidy mysql_query($sql) or die("$sql<br>".mysql_error()); //updated
-
[SOLVED] Table (form) not showing after while loop
MadTechie replied to hwcasey12's topic in PHP Coding Help
Your very welcome Happy PHPing as a tip when you use mysql_fetch_array($result, MYSQL_ASSOC) instead of using or die('No records retrieved') use or die(mysql_error()) as it give more info of course don't try this in a while loop -
Ahhhhhh Magic Quote are on.. if you can turn them off in the PHP.INI file.. if not try this change $delimiter = $_POST['delimiter']; to if(get_magic_quotes_gpc()) { $delimiter = stripslashes($_POST['delimiter']); } else { $delimiter = $_POST['delimiter']; }
-
[SOLVED] Table (form) not showing after while loop
MadTechie replied to hwcasey12's topic in PHP Coding Help
Okay Let break up this line while($row = mysql_fetch_array($result, MYSQL_ASSOC)) while loops until while the condition is true, and ends the loop when its false now $row = mysql_fetch_array($result, MYSQL_ASSOC) $row gets an array from the mysql database unless theirs no more records then it gets a false.. that ends the loop Now with this line $row = mysql_fetch_array($result, MYSQL_ASSOC) or die('No records retrieved') if mysql_fetch_array= false it calls die('No records retrieved') (remember row is getting its value from mysql_fetch_array so it works both ways) this is the same as exit.. thus ends the whole script not just the loop make sense ? -
Great. Next problem (if any) ?
-
[SOLVED] Table (form) not showing after while loop
MadTechie replied to hwcasey12's topic in PHP Coding Help
change while($row = mysql_fetch_array($result, MYSQL_ASSOC) or die('No records retrieved')) to while($row = mysql_fetch_array($result, MYSQL_ASSOC) ) -
[SOLVED] wont let me change header...again
MadTechie replied to mike12255's topic in PHP Coding Help
you can't use header like that, if you want this line echo "Upload sucess,redirecting..."; your better off using a HTML metatag to redirect ie echo "<meta http-equiv=\"REFRESH\" content=\"3;url=images.php\">"; -
you could just add, the following code (from the upload.php) to the forms.php <?php if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { move_uploaded_file($_FILES['userfile']['tmp_name'], "DUMMY.txt"); print "The file " . $_FILES['userfile']['name'] . " has been uploaded.<br>"; } else { print "Possible file upload attack. Filename: " . $_FILES['userfile']['tmp_name']; } ?> basically if you need to have 2 forms they will post their OWN data to wherever you point them but you can't point 1 form to 2 places Hows the reading the text file comming along ?
-
Okay where is the text file in relation to the php file ? ie index.php <--file to open text file +---Data +---TextFiles +---Applications.txt <---File to open code $fcontents = file("Data/TextFiles/Applications.txt"); Next.. the forms your closing the first form after the 2nd form this is a no no also they are going to different php files.. with only 1 submit. also a no no.. so let join these first you can include the upload.php in the forms.php if you wish (it may work) depends on the coding.. <form enctype="multipart/form-data" action="http://xxxxxx/forms.php" method="post"> <hr> <p> Select the file delimiter<br> <select name=delimiter> <option value="," selected>Comma <option value="\t" selected>Tab <option value=";" selected>Semi-Colon </select><br><br> <input type="hidden" name="MAX_FILE_SIZE" value="1000"> Send this file: <input name="userfile" type="file"> <input type="submit" value="Send File"> </form> php code you posted looks okay (your need to test) Next Sounds okay.. you seam to have a good idea what your plaing to do (tests required) Any problems please post back
-
If you want to use HTML in an email your need to tell the email client your data contains HTML data, you can use phpmailer (google it) or try this <?php function send_email($from, $to, $subject, $message){ $headers = "From: ".$from."\r\n"; $headers .= "Reply-To: ".$from."\r\n"; $headers .= "Return-Path: ".$from."\r\n"; $headers .= "Content-type: text/html\r\n"; if (mail($to,$subject,$message,$headers) ) { echo "email sent"; } else { echo "email couldn't be sent"; } } $subject = "Helloooo!"; $message .= "<html><body>"; $message .= "<b>Hey! How are you today?</b>"; $message .= "<br>Regards"; $message .= "</body></html>"; send_email("youraddress@domain.com", "recpeient@domain.com", $subject , $message); ?>
-
Your Options are 1. Form + POST|GET 2. Javascript (See AJAX) Try this.. (not really planned it out but will atleast give you an idea bout AJAX) <?php if(!empty($_GET['Total'])) { $Total = (float)$_GET['Total']; $db_conn = new COM("ADODB.Connection"); $connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". realpath("./Database1.mdb").";"; $db_conn->open($connstr); $rS2 = $db_conn->execute("INSERT INTO TempData(Col1) VALUES('$Total')"); exit(); } ?> function ajaxFunction(ID, Total) { var xmlHttp; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); }catch(e){ // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){ try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){ alert("Your browser does not support AJAX!"); return false; } } } xmlHttp.onreadystatechange=function() { if(xmlHttp.readyState==4) { document.getElementById(ID).innerHTML = xmlHttp.responseText; } } xmlHttp.open("GET", "?Total="+Total,true); xmlHttp.send(null); } <?php if ($a == 1) { echo "<script type='text/javascript'> \n"; echo "var temp1; \n"; echo "total; \n"; echo "var total = 0; \n"; echo "var x = 0; \n"; echo "for (counter=0;counter<3;counter++){ \n"; echo "x = x + 1; \n"; echo "var temp3 = 'colid' + x; \n"; echo "var content=document.getElementsByTagName(temp3) \n"; echo "temp1 = content[0]; \n"; echo "for(c=0;c<content.length;c++) { \n"; echo "var temp4 = 1; \n"; echo "for(d=0;d<content.length;d++){ \n"; echo "if (c == d) {} \n"; echo "else{ \n"; echo "if (content[d].innerHTML == content[c].innerHTML) { \n"; echo "total = total + 1; \n"; echo "} \n"; echo "} \n"; echo "} \n"; echo "} \n"; echo "} \n"; echo "ajaxFunction('result', Total);\n"; echo "</script>\n"; } ?>
-
[SOLVED] what's wrong with my mysql_query syntax?
MadTechie replied to ShoeLace1291's topic in PHP Coding Help
in other word $query = mysql_query("SELECT * FROM fc_matches ORDER BY matchID DESC LIMIT 5") or die(mysql_error()); I tried it and got -
PHP & Javascript to create a rollover image from multiple links
MadTechie replied to jonw118's topic in Javascript Help
Okay this really is more of a HTML/CSS question from the code you have posted you could be able to get this to work, with a little help on the html side.. so here and an example <A HREF="pages.html" ONMOUSEOVER='rollover.src="overtop.gif"' ONMOUSEOUT='rollover.src="thumb.gif" '> <IMG SRC="thumb.gif" NAME="rollover" border="0"> </A> -
[SOLVED] characters screwed up with file_get_contents
MadTechie replied to frankiej's topic in PHP Coding Help
I just tried this code <?xml version="1.0" encoding="iso-8859-1" ?> <users> <user> <name>Göran Karlsson</name> <position>PR</position> </user> ...next user and so on </users> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>test</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <meta http-equiv="content-language" content="se"> </head> <body> <?php $xmlStr = file_get_contents('sysfile.xml'); $xml = new SimpleXMLElement($xmlStr); $nodes = $xml->xpath('/users/user/name'); echo $nodes[0]; ?> </body> </html> and yes it failed.. BUT.. change <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> to <meta http-equiv="content-type" content="text/html; charset=UTF-8"> And Guess what.. it works! BUT as you want iso-8859-1 Your going to have to decode it from UTF-8 to iso-8859-1 So Final Script <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>test</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <meta http-equiv="content-language" content="se"> </head> <body> <?php $xmlStr = file_get_contents('sysfile.xml'); $xml = new SimpleXMLElement($xmlStr); $nodes = $xml->xpath('/users/user/name'); echo utf8_decode($nodes[0]); ?> </body> </html> -
Cool Can you click solved please
-
Add displayLogin(); at the end
-
Have you got a "Zend PHP Certification Study Guide"?
-
On the new table have a field Called UserID (this will have the same value as the Prime field in the usres table) and IMO i would probably keep a table for logins and another for game status info EDIT: oh and link them via a JOIN but if you have the UserID stored in session during login you can just pass that to the other table directly to get Game Info) but if you want to get the Users name etc your need to either use a JOIN or do 2 queries
-
Ahh forgot about the No zero!