-
Posts
9,409 -
Joined
-
Last visited
-
Days Won
1
Everything posted by MadTechie
-
was reading and all was find until this still doesn't make sense! explain with more words!
-
Thats hardly php scripting.. echo "<a href=\"http://www.adworld-online.com/submit.php?user=$username\"><img src=\"http://www.adworld-online.com/images/banners/". $username ."_banner.jpg\" width=\"600\" height=\"110\"><br />"; some effort would be nice try something like <?php $types = array("jpg","gif","png"); $dir = "path/to/image/"; foreach($types as $type) { if(file_exists($dir.$username ."_banner.".$type)) { echo "<a href=\"http://www.adworld-online.com/submit.php?user=$username\"><img src=\"http://www.adworld-online.com/images/banners/". $username ."_banner.".$type.\" width=\"600\" height=\"110\"><br />"; } } ?> Ok thats written on the fly.. just a basic idea
-
Question regarding Unix timestamps, php, and mysql
MadTechie replied to Kevin3374's topic in PHP Coding Help
please click topic solved without the "as" you would of needed to do this echo "the start date is {$row_data['UNIX_TIMESTAMP(start_date)']}"; -
Question regarding Unix timestamps, php, and mysql
MadTechie replied to Kevin3374's topic in PHP Coding Help
try <?php $query_str = "SELECT UNIX_TIMESTAMP(start_date) as start_date, UNIX_TIMESTAMP(end_date) as end_date, title, location FROM Events"; ?> -
[SOLVED] Need help. Slightly complicated, I'm stuck beyond reason!!
MadTechie replied to atravotum's topic in PHP Coding Help
without some debug data its hard to say what he problem is but on this line f_mod_table($db_name, $db_user, $db_pword, $db_table, "ADD", $col); shouldn't $col be a array ? ie f_mod_table($db_name, $db_user, $db_pword, $db_table, "ADD", array($col)); -
i agree with corbin, $foo = str_replace(PHP_EOL, '\\n', $foo); should do it.. you may even preg_replace to clean out everything that will mess it up..
-
Huh.. ??? Okay your need to re-explain what your attemping to do.. start from the end.. whats the goal ?
-
try this <?php //this script outputs the data in table format. mysql_connect("localhost",$user,$password); mysql_select_db($database) or die( "Unable to select database"); $vars = Array(); // Append to the array, the variable 'where' query, if the variable exists. if(isset($_POST['sfirst']) && !empty($_POST['sfirst'])){ $vars[] = "`sfirst`='".mysql_escape_string($_POST['sfirst'])."'"; } if(isset($_POST['slast']) && !empty($_POST['slast'])){ $vars[] = "`slast`='".mysql_escape_string($_POST['slast'])."'"; } if(isset($_POST['sphone']) && !empty($_POST['sphone'])){ $vars[] = "`sphone`='".mysql_escape_string($_POST['sphone'])."'"; } if(isset($_POST['smobile']) && !empty($_POST['smobile'])){ $vars[] = "`smobile`='".mysql_escape_string($_POST['smobile'])."'"; } if(isset($_POST['sfax']) && !empty($_POST['sfax'])){ $vars[] = "`sfax`='".mysql_escape_string($_POST['sfax'])."'"; } if(isset($_POST['semail']) && !empty($_POST['semail'])){ $vars[] = "`semail`='".mysql_escape_string($_POST['semail'])."'"; } if(isset($_POST['sweb']) && !empty($_POST['sweb'])){ $vars[] = "`sweb`='".mysql_escape_string($_POST['sweb'])."'"; } // echo "value of sfirst is $sfirst<br>\n" ; // echo "value of slast is $slast<br>\n" ; // echo "value of sphone is $sphone<br>\n" ; // echo "value of smobile is $smobile<br>\n" ; // echo "value of sfax is $sfax<br>\n" ; // echo "value of semail is $semail<br>\n" ; // echo "value of sweb is $sweb<br>\n" ; // echo "value of vars is $vars<br>\n" ; // If user did not submit any queries... if(!isset($vars[0])){ exit("Please Choose At Least One Filter"); } // Count how many where queries is requested if(count($vars) > 1){ // If there is more than 1 where query then 'implode' the array with " and ", (convert to str and insert " and " between each item) //echo "vars was greater than 1<br>\n" ; $where = "WHERE ".implode(" and ",$vars); }else{ // Otherwise assume there is only 1 where query //echo "vars was less than 1<br>\n" ; $where = "WHERE ".$vars[0]; } //echo "the value of where is $where<br>\n" ; // Make the Query $query="SELECT * FROM `contacts` $where LIMIT 30"; $result = mysql_query($query); echo("result is: "); print_r($result);echo("<br />\n"); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Database Output</center></b><br><br>"; ?> <table border="0" cellspacing="2" cellpadding="2"> <tr> <th><font face="Arial, Helvetica, sans-serif">Name</font></th> <th><font face="Arial, Helvetica, sans-serif">Phone</font></th> <th><font face="Arial, Helvetica, sans-serif">Mobile</font></th> <th><font face="Arial, Helvetica, sans-serif">Fax</font></th> <th><font face="Arial, Helvetica, sans-serif">E-mail</font></th> <th><font face="Arial, Helvetica, sans-serif">Website</font></th> </tr> <?php while ($row = mysql_fetch_assoc($result)) { $first = $row["first"]; $last = $row["last"]; $phone = $row["phone"]; $mobile = $row["mobile"]; $fax = $row["fax"]; $email = $row["email"]; $web = $row["web"]; /*personal dislike of this style of code $i=0; while ($i < $num) { $first =mysql_result($result,$i,"first"); $last = mysql_result($result,$i,"last"); $phone = mysql_result($result,$i,"phone"); $mobile = mysql_result($result,$i,"mobile"); $fax = mysql_result($result,$i,"fax"); $email = mysql_result($result,$i,"email"); $web = mysql_result($result,$i,"web");*/ //echo "<b>$first $last</b><br>Phone: $phone<br>Mobile: $mobile<br>Fax: $fax<br>E-mail: $email<br>Web: $web<br><hr><br>"; ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><? echo $first." ".$last; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $phone; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $mobile; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $fax; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $email; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $web; ?></font></td> </tr> <?php //$i++; //noted needed } // close while mysql_free_result($result); echo "</table>"; ?>
-
you must have a field in the database called type and part of the sql select statement (or use * for all)
-
ahh i should of read all the code!! try this if(isset($_POST['sfirst']) && !empty($_POST['sfirst'])){ $vars[] = "`sfirst`='".mysql_escape_string($_POST['sfirst'])."'" }
-
i'll take that as a solved!
-
print_r — Prints human-readable information about a variable echo — Output one or more strings try this <?php $myArray = array("test", "123"); echo "echo=".$myArray; echo "print_r="; print_r($myArray); ?>
-
you have a url we can look at?
-
oops updated <?php $handle = fopen("test.csv", "r"); echo "<?xml version=\"1.0\" ? >\n"; //remove space after ? (added for make it format in here) echo "<rss version=\"2.0\">\n"; echo " <channel>\n"; echo " <title>test</title>\n"; echo " <link>http://www.test.com/</link>\n"; echo " <description>test</description>\n"; $row = 1; while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $title = $data[0]; $link = $data[1]; $description= $data[2]; echo " <item>\n"; echo " <title>$title</title>\n"; echo " <link>$link</link>\n"; echo " <description>$description</description>\n"; echo " </item>\n"; } fclose($handle); echo " </channel>\n"; echo "</rss>\n"; ?> REMEMBER the space on line 3 my csv file
-
so <?php echo $row['descr'].$row['type'];?> ??? or am i still missing it ?
-
PHP and MySQL - Not pulling correct filename
MadTechie replied to rwachowiak's topic in PHP Coding Help
that code has nothing to do with the download from what i can see.. your probably need to urlencode the filename or your not quoting it in the header! -
form not submitting/sql query not working
MadTechie replied to trilbyfish's topic in PHP Coding Help
is "08:00 - 09:00" a value field!!! surely your need some back tick! ie `08:00 - 09:00` also you have <?php if (isset($_GET['id'])) { //snip }else{ echo '<p>'. mysql_error() . '<br/> <br/>Query: ' . $query . '</p>'; } ?> which i assume is not what you expected! -
try changing if(isset($_POST['sfirst'])){ $vars[] = "`sfirst`='".mysql_escape_string($_POST['sfirst'])."'"; } to if(isset($_POST['sfirst'])){ $vars[] = (!empty($_POST['sfirst']))?"`sfirst`='".mysql_escape_string($_POST['sfirst'])."'":""; } apply same logic to all (note the (!empty($_POST['sfirst']))? at the start and :"" at the end) also a debug tip change echo "value of vars is $vars<br>" ; to echo "value of vars is "; print_r($vars); echo "<br>" ;
-
if this topic is solved, please click solved bottom left (i think)
-
well it would but most of the feature of the from relie on index.php so it will not function correct. humm.. phpbb has a permission for members only see here
-
you still lost me <?php echo $row['descr'.'type']; ?> <?php $avar = "descrtype"; echo $row[$avar]; ?>
-
well if its a typical forum 99% of the data is accesed via i file called index.php if you add the code above excluding }else{ $_SESSION['access'] = false; //clear so they need to use the welcome.php again , that should suite quite well, it really depends on the forum and the exact requirments.. of course you could change the boolean (true/false) for a timestamp, this will allow access (including direct access) for a time period (start from when they went to welcome.php) .. if that make sense! so to sum up.. welcome.php sets the time and other_section.php checks the time ie <?php session_start(); $_SESSION['access'] = time(); ?> <?php session_start(); if (time() > $_SESSION['access']+(60*60)) //1 hour { die("No access"); } ?>
-
<?php <?php $data = "John Brown"; $data = "Cat in a hat"; if (preg_match('/(\w+)/i', $data, $regs)) { $firstword= $regs[1]; } echo $firstword; ?> ?>
-
So let me check.. you have a main page ie mydomain.com/welcome.php and mydomain.com/other_section.php and you want people to access other_section.php VIA welcome.php but NOT directly.. if so... you could use sessions/cookies ie <?php session_start(); $_SESSION['access'] = true; ?> <?php session_start(); if ($_SESSION['access'] !== true) { die("No access"); }else{ $_SESSION['access'] = false; //clear so they need to use the welcome.php again } echo "Hello world"; ?>
-
gmail recieves mails sent from php's mail() function, but not yahoo mail
MadTechie replied to obay's topic in PHP Coding Help
try this function <?php function send_mail($to, $body, $subject, $fromaddress, $fromname, $attachments=false) { $eol="\r\n"; $mime_boundary=md5(time()); # Common Headers $headers .= "From: ".$fromname."<".$fromaddress.">".$eol; $headers .= "Reply-To: ".$fromname."<".$fromaddress.">".$eol; $headers .= "Return-Path: ".$fromname."<".$fromaddress.">".$eol; // these two to set reply address $headers .= "Message-ID: <".time()."-".$fromaddress.">".$eol; $headers .= "X-Mailer: PHP v".phpversion().$eol; // These two to help avoid spam-filters # Boundry for marking the split & Multitype Headers $headers .= 'MIME-Version: 1.0'.$eol.$eol; $headers .= "Content-Type: multipart/mixed; boundary=\"".$mime_boundary."\"".$eol.$eol; # Open the first part of the mail $msg = "--".$mime_boundary.$eol; $htmlalt_mime_boundary = $mime_boundary."_htmlalt"; //we must define a different MIME boundary for this section # Setup for text OR html - $msg .= "Content-Type: multipart/alternative; boundary=\"".$htmlalt_mime_boundary."\"".$eol.$eol; # Text Version $msg .= "--".$htmlalt_mime_boundary.$eol; $msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol; $msg .= "Content-Transfer-Encoding: 8bit".$eol.$eol; $msg .= strip_tags(str_replace("<br>", "\n", substr($body, (strpos($body, "<body>")+6)))).$eol.$eol; # HTML Version $msg .= "--".$htmlalt_mime_boundary.$eol; $msg .= "Content-Type: text/html; charset=iso-8859-1".$eol; $msg .= "Content-Transfer-Encoding: 8bit".$eol.$eol; $msg .= $body.$eol.$eol; //close the html/plain text alternate portion $msg .= "--".$htmlalt_mime_boundary."--".$eol.$eol; if ($attachments !== false) { for($i=0; $i < count($attachments); $i++) { if (is_file($attachments[$i]["file"])) { # File for Attachment $file_name = substr($attachments[$i]["file"], (strrpos($attachments[$i]["file"], "/")+1)); $handle=fopen($attachments[$i]["file"], 'rb'); $f_contents=fread($handle, filesize($attachments[$i]["file"])); $f_contents=chunk_split(base64_encode($f_contents)); //Encode The Data For Transition using base64_encode(); $f_type=filetype($attachments[$i]["file"]); fclose($handle); # Attachment $msg .= "--".$mime_boundary.$eol; $msg .= "Content-Type: ".$attachments[$i]["content_type"]."; name=\"".$file_name."\"".$eol; // sometimes i have to send MS Word, use 'msword' instead of 'pdf' $msg .= "Content-Transfer-Encoding: base64".$eol; $msg .= "Content-Description: ".$file_name.$eol; $msg .= "Content-Disposition: attachment; filename=\"".$file_name."\"".$eol.$eol; // !! This line needs TWO end of lines !! IMPORTANT !! $msg .= $f_contents.$eol.$eol; } } } # Finished $msg .= "--".$mime_boundary."--".$eol.$eol; // finish with two eol's for better security. see Injection. # SEND THE EMAIL ini_set(sendmail_from,$fromaddress); // the INI lines are to force the From Address to be used ! $mail_sent = mail($to, $subject, $msg, $headers); ini_restore(sendmail_from); return $mail_sent; } ?>