-
Posts
9,409 -
Joined
-
Last visited
-
Days Won
1
Everything posted by MadTechie
-
Hummm is_numeric('0.123') // = true Try this $data = "111"; if (preg_match('/^[0-9]$/', $data)) { //its a number only } <?php function isnumeric($data) { return preg_match('/^[0-9]$/', $data); } ?>
-
Erm.. echo "$rS2 = $db_conn->execute(\"INSERT INTO TempData(Col1) VALUES('total')\");\n"; i assume you mean $rS2 = $db_conn->execute("INSERT INTO TempData(Col1) VALUES('total')"); but i don't see where your setting $db_conn
-
how to go to make auto go back to previous page after login?
MadTechie replied to lukelee's topic in PHP Coding Help
If $_SESSION['gPage'] is empty goto index.php instead.. type in the URL of the login page directly into the address bar and then login.. what happens! Oh what didn't work ? and i should of said don't add <?php session_start(); $_SESSION['gPage'] = $_SERVER['REQUEST_URI']; ?> to the login page! -
[SOLVED] characters screwed up with file_get_contents
MadTechie replied to frankiej's topic in PHP Coding Help
Erm okay use <?php header('Content-Type: text/html; charset=iso-8859-1'); ?> -
change charset=windows-1251 to charset=utf-8 or remove that whole line and try <?php header('Content-Type: text/html; charset=utf-8'); include("file.html"); ?>
-
[SOLVED] characters screwed up with file_get_contents
MadTechie replied to frankiej's topic in PHP Coding Help
define "messed up" are you encoding it correctly ? ie UTF-8 ? try adding <?php header('Content-Type: text/html; charset=utf-8'); ?> to the start of the page -
how to go to make auto go back to previous page after login?
MadTechie replied to lukelee's topic in PHP Coding Help
Okay update the code to the below $result=mysql_query("select * from member where username='$username' and password='$password'"); if(mysql_num_rows($result)!='0'){ session_register("username"); $page = (!empty($_SESSION['gPage']))?$_SESSION['gPage']:"index.php";//add header($page); //update exit; }else{ echo "Wrong username and password, back in 3 sec!"; } (you could use $_COOKIE instead of $_SESSION and add <?php session_start(); $_SESSION['gPage'] = $_SERVER['REQUEST_URI']; ?> at the top of your pages ( you could use <?php setcookie("gPage", $_SERVER['REQUEST_URI']); ?> instead ) -
how to go to make auto go back to previous page after login?
MadTechie replied to lukelee's topic in PHP Coding Help
Its hard to say without knowing the code behind it but the basic concept is as follows On the page that redirects you to the login page save the URL in a session ie 'ePage'.. then on login if 'ePage' is set redirect to it -
Here is an untested example I hope it make sense or at least gives you an idea on how it works <?php //FROM TO CODE = http://www.webservicex.net/CurrencyConvertor.asmx?op=ConversionRate //GET XML = http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=USD&ToCurrency=GBP $From="USD"; $To="GBP"; $URL = "http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=$From&ToCurrency=$To"; //XML $xml = new SimpleXMLElement($URL); $Rate = $xml->double; //OR use /* $Rate = file_get_contents($URL); if (preg_match('/<.*?>([^<]*)/', $Rate, $regs)) { $Rate= $regs[1]; } */ echo $Rate; ?> Now using XML you could get all the details for conversion from the remote site (http://www.webservicex.net/CurrencyConvertor.asmx?WSDL)
-
if your using utf-8 correctly you should be able to just echo it
-
<?php echo $haku;?> UserProfile XXS, do you want to use BBcode, allowing the user to manually enter genres good idea.. could cause problem with finds later ! we could go on but thats why we get a full brief! as for HTML yeah easy to code but you need to know what you what it to look like...!!! PHP code easy if you have a design! Javascript easy if you know what your using it for then.. Oh the one we all start to hate.. browser compatability!
-
WOW redarrow 2 hours.. I would spend most of that time on the Proof Of Concept... its strange how a good programmer can take the same amount of time as a bad programmer but but you can always tell form the results... rush the job and your end up re-doing the same job.. rush it again.. yeah you know what i'm saying.. In truth most of my client, i get from an existing client recommendating me, most of which i have had very badly designed system built (and i'm not taking about the interface). and from the info spikypunker has supplied you can't build a full system.. a POC yes but even then your need to make it look good! Link please!
-
to Sort an array and maintain index association use asort() EDIT: if you want to sort by first item try this <?php aksort($array); print_r($array); function aksort(&$array) { asort($array); $vals = array_count_values($array); $i = 0; foreach ($vals AS $val=>$num) { $first = array_splice($array,0,$i); $tmp = array_splice($array,0,$num); ksort($tmp); $array = array_merge($first,$tmp,$array); unset($tmp); $i = $i+$num; } } ?>
-
Magic quote are being removed in php6 and are diabled by default in php5 if they are on then they addslashes automatically thus using addslashes does it again.. your last code will check if they are on and strip the slashes function guard_sql($value) { // Stripslashes if (get_magic_quotes_gpc()) { $value = stripslashes($value); } $value = mysql_real_escape_string($value); return $value; } EDIT: premiso beat me
-
you could but why have a function calling one function that does the same as function you are calling ? just do $queryUsername = "SELECT username FROM user WHERE username = '".mysql_real_escape_string($username)."'"; or $queryUsername = sprintf("SELECT username FROM user WHERE username = '%s'",mysql_real_escape_string($username)); EDIT: yes that guard_sql is better
-
[SOLVED] Increment number in while loop question
MadTechie replied to realjumper's topic in PHP Coding Help
Okay i think i know what you are trying to do.. and yes you could add a counter but i would suggest you use the Unique User ID (AutoNumber) so echo "<td>$first_name <a name=\"User{$row2['ID']}\"></a></td>" also you should quote the field names ie $row2[first_name] should be $row2['first_name'] -
IMA store the date as a DATE field then when i want to view it i format it on the output.. you can store it pre-formatted but your kick yourself when you start to have problems.. output is just as easy $today = date("l F j, Y",$row['workdate']);
-
Send to your server.. okay are you talking about POST, GET, FTP, HTTP, EMAIL, TCP SOCKET, Carrier Pigeon?
-
Oh don't get me wrong i agree, My 2nd Choice would be phpmailer (due to ease of use) but it is still limited, i have added to it but still limited hence my "workaround", I only said that because you said Pear Mail in 3 out of 4 paragraphs.
-
stripslashes() isn't needed unless you have magic quotes on.. if(get_magic_quotes_gpc()) { $password1 = stripslashes($password1); } ALSO remember no matter how secure the door is, its no good if you leave the window open!
-
Hummm i have the stragest feeling that premiso likes Pear::Mail, if you can't use it then a trick i used was a loop that send 100 mails, then auto-refreshed and send the next 100 mails etc etc.. it was a lazy trick but worked for a one off project..
-
Why not just put the file in a folder lower that the html_public folder ? ie root +-----Public_html +-----------+index.php +-----------+Blar.php +-----hidden +-------+hidden.php
-
ORDER BY BAND_UPDATE DESC $sql_events = mysql_query("SELECT * FROM jamroom_band_info WHERE band_zipcode='$key' ORDER BY BAND_UPDATE DESC ") or die (mysql_error());
-
i think you want this $find = implode("=1 AND ",$_POST['criteria'])."=1"; $query = "select * from drinking WHERE $find order by venue asc"; //RESULT = $query= "select * from drinking WHERE realale=1 AND fruitwine=1 AND champagne=1 order by venue asc";
-
Okay this is very untested.. as not tested at all.. <?php //EG $FTP = new FTPUpload(); $FTP->UploadFolder("Old_html/","New_html/"); class FTPUpload { protected $conn_id; private $FTP_HOST ="ftp.NewServer.com"; private $FTP_USER ="NewServerUser"; private $FTP_PW ="NewServerPass"; private $FTP_ROOT_DIR="/"; private $FTP_DIR = "public_html/"; private $LOCAL_SERVER_DIR = "public_html/"; private $mode = FTP_BINARY; // or FTP_ASCII function __construct() { $this->conn_id = ftp_connect($this->FTP_HOST); } function UploadFolder($FromFolder, $ToFolder) { $this->LOCAL_SERVER_DIR = $FromFolder; $this->FTP_DIR = $ToFolder; if(ftp_login($this->conn_id, $this->FTP_USER, $this->FTP_PW)) { $this->GetFiles($FromFolder); ftp_quit($this->conn_id); } } //Connect to New Server function UploadFile($f) { ftp_pwd($this->conn_id); ftp_mkdir($this->conn_id,$this->FTP_DIR); ftp_chdir($this->conn_id,$this->FTP_DIR); $from = fopen($this->LOCAL_SERVER_DIR.$files,"r"); foreach($f as $files) { $from = fopen($this->LOCAL_SERVER_DIR.$files,"r"); if(ftp_fput($this->conn_id, $files, $from, $this->mode)) { print $files."<br>"; } } if(ftp_fput($this->conn_id, $files, $from, $this->mode)) { print "Uploaded: $files<br>"; } } function GetFiles($dir) { if(!$dh = @opendir($dir)) return; while (false !== ($obj = readdir($dh))) { if($obj=='.' || $obj=='..') continue; if(is_dir($obj)) { $this->GetFiles($dir.'/'.$obj); }else{ $f[]="$file"; } } $this->UploadFile($f); } } ?>