Jump to content

Search the Community

Showing results for tags 'php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Here is my code which i use to recieve uploaded files. $filepath = $_SERVER['DOCUMENT_ROOT'] . "file/"; $fileunzippath = $filepath."unzipped/"; $exclude_list = array(".", "..", "...", "index.php", ".php", ".htaccess"); if($_FILES["zip_file"]["name"]) { $filename = $_FILES["zip_file"]["name"]; $source = $_FILES["zip_file"]["tmp_name"]; $type = $_FILES["zip_file"]["type"]; $name = explode(".", $filename); $accepted_types = array('application/zip', 'application/x-zip-compressed', 'multipart/x-zip', 'application/x-compressed'); foreach($accepted_types as $mime_type) { if($mime_type == $type) { $okay = true; break; } } $continue = strtolower($name[1]) == 'zip' ? true : false; if(!$continue) { $message = "The file you are trying to upload is not a .zip file. Please try again."; } $string = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $filename); $clean_name = strtr($string, array('Š' => 'S','Ž' => 'Z','š' => 's','ž' => 'z','Ÿ' => 'Y','À' => 'A','Á' => 'A','Â' => 'A','Ã' => 'A','Ä' => 'A','Å' => 'A','Ç' => 'C','È' => 'E','É' => 'E','Ê' => 'E','Ë' => 'E','Ì' => 'I','Í' => 'I','Î' => 'I','Ï' => 'I','Ñ' => 'N','Ò' => 'O','Ó' => 'O','Ô' => 'O','Õ' => 'O','Ö' => 'O','Ø' => 'O','Ù' => 'U','Ú' => 'U','Û' => 'U','Ü' => 'U','Ý' => 'Y','à' => 'a','á' => 'a','â' => 'a','ã' => 'a','ä' => 'a','å' => 'a','ç' => 'c','è' => 'e','é' => 'e','ê' => 'e','ë' => 'e','ì' => 'i','í' => 'i','î' => 'i','ï' => 'i','ñ' => 'n','ò' => 'o','ó' => 'o','ô' => 'o','õ' => 'o','ö' => 'o','ø' => 'o','ù' => 'u','ú' => 'u','û' => 'u','ü' => 'u','ý' => 'y','ÿ' => 'y')); $clean_name = strtr($clean_name, array('Þ' => 'TH', 'þ' => 'th', 'Ð' => 'DH', 'ð' => 'dh', 'ß' => 'ss', 'Œ' => 'OE', 'œ' => 'oe', 'Æ' => 'AE', 'æ' => 'ae', 'µ' => 'u')); $clean_name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $clean_name); $target_path = $filepath.$clean_name; // change this to the correct site path if(move_uploaded_file($source, $target_path)) { echo "Source: ".$source."<br/>"; echo "Type: ".$type."<br/>"; echo "Filename: ".$filename."<br/>"; $zip = new ZipArchive(); $x = $zip->open($target_path); if ($x === true) { $zip->extractTo($fileunzippath.$clean_name); // change this to the correct site path $zip->close(); $exclude_list; $dir_path = $_SERVER['DOCUMENT_ROOT']; $dir_path .= "/file/unzipped/"; $directories = array_diff(scandir($fileunzippath.$clean_name), $exclude_list); foreach($directories as $entry) { if(is_dir($dir_path.$entry)) { if($entry != 'part0' || $entry !='part1') { rmdir($entry); } } } } $message = "Your .zip file was uploaded and unpacked."; } else { $message = "There was a problem with the upload. Please try again."; } } Specifically i want to highlight this part: $exclude_list; $dir_path = $_SERVER['DOCUMENT_ROOT']; $dir_path .= "/file/unzipped/"; $directories = array_diff(scandir($fileunzippath.$clean_name), $exclude_list); foreach($directories as $entry) { if(is_dir($dir_path.$entry)) { if($entry != 'part0' || $entry !='part1') { rmdir($entry); } } } When I upload a zip file containing 2 directories(one called 'part0', and one called 'bad'), they get unzipped correctly and it gives no errors, however the fake directories(not called part0 or part1) I put in there are still there. Any Help?
  2. Hello: I am having a brain fart on how to get this done and any ideas would greatly be appreciated. I am working on a in-house mailbox project and have my first problem. I am going to try and explain this a simple as possible as putting the words from my head to screen harder than I thought. I have a page with 1 div called msgs_main. Inside of that div are 2 more, top one called msgs_msgs and the bottom called msgs_content. The msgs_msgs div contains a simple mysqli query displaying the records that correspond to the user. What I want/need is that when the user clicks one of the rows, the contents of the message are displayed in the msgs_content div. I could provide the code, if it helps, but I am not really looking for answered code, but a process to learn from, like. "First, get a join and have all the records display in the msg_msgs div. Display them all to see that all the data is there. Later in production, remove the un-necessary fields from top div". Then research .... etc
  3. Hi there, I want to make script which will execute via crontab every Sunday at 0:01h and will stop at 23:59h. My goal is to put(show) some tekst on the site. The problem is how to put this tekst in the site? I mean I know how to configure Cron Jobs but how to include the tekst in index.php for example? crontab will be. 1 0 * * 0 /usr/bin/php Start.php 59 23 * * 0 /usr/bin/php Stop.php
  4. Hi everyone, I would like to know if: I have three different forms to create three different mysql codes. Now my code will generate the three mysql codes correctly but each time I tried to generate the second mysql code using another form, the previous will get wiped and therefore I can only have one mysql code working at the moment. (I apologize in advanced if my issue is not clearly stated.) Attached is the code that I have right now. I am trying to get all three mysql codes (Searchsql, Filtersql, Panelsql) correct so I can pass all three mysql queries to a function where it can combine all three queries into one array using the array_intersect function. Please kindly let me know your opinion on the problem and I would really appreciate the help. $object = new Three; class Three { public $Panel, $Search, $Filter; function save_Three() { while($Prow = sqli_fetch_array($Panel, MYSQLI_BOTH)) { $PanelName = $Prow ['name']; } while($Srow = sqli_fetch_array($Search, MYSQLI_BOTH)) { $SearchName = $Srow ['name']; } while($Frow = sqli_fetch_array($Filter, MYSQLI_BOTH)) { $FilterName = $Frow ['name']; } $Combined = array_intersect($Panel, $Search, $Filter); foreach ($Combined as $item) print $item; } } $Panelsql = "SELECT DISTINCT aID, name from test.article"; if (isset($_GET['pid'])) { $pID= $_GET['pid']; echo "$pID"; $Panelsql = "SELECT DISTINCT aID, name from test.a_m, test.platform, test.message, test.article where aid in (SELECT DISTINCT assocAID from test.a_m, test.platform, test.message where assocMID in (SELECT mID from test.message, test.platform where pID=$pID and pID = assocPID))"; } else if (isset($_GET['mid'])) { $mID= $_GET['mid']; $Panelsql = "SELECT DISTINCT aID, name from a_m, message, article where aid in (SELECT DISTINCT assocAID from a_m, message where mID=$mID and mID = assocMID)"; } else { $Panelsql = "SELECT DISTINCT aID, name from article"; } $object->Panel = $Panelsql; $aRegions = $_POST['RegionSelected']; $Filtersql = 'SELECT * FROM test.article'; if(isset($aRegions)) { $Filtersql .= ' WHERE 1 AND ('; foreach ($aRegions as $word) if($word==$aRegions[count($aRegions)-1]) { $Filtersql .= " Region = '". $word ."')"; } else { $Filtersql .= " Region = '". $word ."' OR"; } } //Population filtering function $aPopulations = $_POST['PopulationSelected']; if(isset($aPopulations)) { if(!isset($aRegions)){$Filtersql .= ' WHERE 1 AND ('; } else { $Filtersql .= ' AND ('; } foreach ($aPopulations as $word) if($word==$aPopulations[count($aPopulations)-1]) { $Filtersql .= " Population = '". $word ."')"; } else { $Filtersql .= " Population = '". $word ."' OR"; } } $object->Filter = $Filtersql; $Searchsql="SELECT * FROM test.article"; if (isset($_POST['search'])){ $st= ($_POST['search_box']); $Searchsql .= " WHERE name LIKE '%{$st}%' OR abstract LIKE '%{$st}%' OR Summary LIKE '%{$st}%' OR Keyword LIKE '%{$st}%' OR population LIKE '%{$st}%'OR region LIKE '%{$st}%'"; } $object->Search = $Searchsql;
  5. Are either of these OK depending on circumstance or stupid things I should never do? Is one or the other sensible/idiotic? Is there an obvious 'better' way? I think all the php tags opening and closing within the DIVs is untidy but it's static HTML therefore if there's a LOT of it it's easier on the server right/wrong? On the other hand, maybe all the open/close of php tags defeats the object. I'm applying for a web design apprenticeship (I know, I need one) so I'm trying to appear less stupid as much as make nice php. Many thanks in advance, I know I'll end up better off by asking here <?php // php in here ?> <div class='content header'> <?php include("includes/header.php"); ?> </div> <div class='content content1'> <?php include("includes/intro.php"); ?> </div> <div class='content content2'> <?php include("includes/quals.php"); ?> </div> <div class='content content3'> <?php include("includes/experience.php"); ?> </div> <div class='content content4'> <?php include("includes/hobbies-and-interests.php"); ?> </div> <?php // More php here ?> Or this one: <?php print("<div class='content header'>"); include("includes/header.php"); print("</div> \r\n <div class='content content1'>"); include("includes/intro.php"); print("</div> \r\n <div class='content content2'>"); include("includes/quals.php"); print("</div> \r\n <div class='content content3'>"); include("includes/experience.php"); print("</div> \r\n <div class='content content4'>"); include("includes/hobbies-and-interests.php"); print("</div> \r\n"); ?> test.zip
  6. Hi, could I have some help with this code please? Getting: "Fatal error: Call to undefined function chn() in ......" Thanks <?php $mysqli = chn("localhost", "root", "") or die("Connect failed : " . mysql_error()); mysql_select_db("jm_db"); $result = mysql_query("SELECT COUNT(*) FROM asterisk_cdr WHERE calldate LIKE '%2014-10-11%' AND channel LIKE '%SIP/4546975289%'"); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo ($row["channel"]); } mysql_free_result($result); ?>
  7. Hi guys, Here's my code: <?php $servername="127.0.0.1"; $username="root"; $password=""; $dbname="testdb"; $connection = new mysqli($servername,$username,$password,$dbname); $sql = "SELECT Wages FROM w WHERE \"Country\"=\"".$_POST["blah"]."\""; $r = $connection->query($sql); $result = $r->fetch_all(MYSQLI_ASSOC); echo $result; ?> When I go to the page I get the following message: Notice: Undefined index: w in C:\xampp\htdocs\test\processing.php on line 13 Does anyone know what problem I'm having here? /stuck Cheers, B
  8. Hi I require a PHP code to get output table. My Table Item Qty Date aa-1 2 2014-10-01 aa-2 5 2014-10-01 aa-3 1 2014-10-01 ab-1 2 2014-10-01 ab-2 1 2014-10-01 bb-1 4 2014-10-01 bb-2 3 2014-10-01 bb-3 2 2014-10-01 aa-1 1 2014-10-02 aa-2 2 2014-10-02 aa-3 5 2014-10-02 ab-1 6 2014-10-02 ab-2 1 2014-10-02 bb-1 9 2014-10-02 bb-2 0 2014-10-02 bb-3 4 2014-10-02 aa-1 1 2014-10-03 aa-2 2 2014-10-03 aa-3 5 2014-10-03 ab-1 4 2014-10-03 ab-2 3 2014-10-03 bb-1 1 2014-10-03 bb-2 8 2014-10-03 bb-3 2 2014-10-03 I wrote code as mentioned below. <?php $accounts=mysql_connect("localhost", "root", "") or die("could not connect"); mysql_select_db("shops",$accounts) or die("could not find db!"); if(isset($_POST['search']) && ($_POST['from']) && ($_POST['to'])){ $searchq=$_POST['search']; $searchq=preg_replace("#[^0-9a-z]#i", "" , $searchq); $from=$_POST['from']; $to=$_POST['to']; $dateInput = explode('-',$from); $fdate = $dateInput[2].'-'.$dateInput[1].'-'.$dateInput[0]; $dateInput = explode('-',$to); $tdate = $dateInput[2].'-'.$dateInput[1].'-'.$dateInput[0]; for ($date=$fdate; $date<=$tdate; $date++) { $sql = "SELECT item, SUM(CASE WHEN `date` = '$date' THEN Qty ELSE 0 END) FROM shop WHERE item LIKE '%$searchq%' GROUP BY item"; $query = mysql_query($sql) or die("could not search!"); echo "<table border='1'>"; echo "<tr> <td>Item </td> <td>$date</td> </tr>" ; while ($row=mysql_fetch_array($query)) { echo "<tr> <td>". $row[0] ." </td> <td>" . $row[1] . "</td> </tr>"; } echo "</table>"; } } ?> I am getting result like this as I asked for three days. Item 2014-10-01 aa-1 2 aa-2 5 aa-3 1 Item 2014-10-02 aa-1 1 aa-2 2 aa-3 5 Item 2014-10-03 aa-1 1 aa-2 2 aa-3 5 But I need result like below Item 2014-10-01 2014-10-02 2014-10-03 aa-1 2 1 1 aa-2 5 2 2 aa-3 1 5 5 Can anybody help me to write PHP code to display result as needed. Please help. Thanks in advance.
  9. Hi I'm currently investigating how much it will cost me approximately for someone to code me a basic chat script. The script should be very basic (old school) PHP without any javascript or fancy options. must use Mysql as database. Must use automatic login if the user match to certain HTTP header otherwise they must specify a username to register Should not use css stylesheets must be inline styles No cookies Moderating time ban(kick) for 1h, 12h, 24h, 7days, 1 month and 1 year and Permanent Option to unkick/ban Option to edit messages and delete messages. The moderator should be able to type under hes real username and by using a prefix like a ? infront of hes message it must be able to post a message under the name Moderator in a different color. Each time a person has been banned a message should appear saying something like user1 has been kicked for 7 days. Display the amount of times being kicked within the last 30 days... Admin Panel time ban(kick) for 1h, 12h, 24h, 7days, 1 month and 1 year and Permanent Option to unkick/ban Option to edit messages and delete messages. The Admin should be able to type under hes real username and by using a prefix like a ! infront of hes message it must be able to post a message under the name Admin in a different color. Each time a person has been banned a message should appear saying something like user1 has been kicked for 7 days. Display the amount of times being kicked within the last 30 days... Option to rename Users usernames Word filter with an option to specify the replacement word Auto mute for specific time frame if a user used a word on the word filter Option to make users moderators and remove them and option to specify text colors of the moderator and Admin and normal user using span and div styles Option to remove messages older then a specified time. Should be able to select how many messages must be displayed per page Chat window Should show the time posted in brackets in grey, name: and message Should make use of pagination should have a text link to page to show users currently active and chatting Refresh option and highlight the font of the usernames in another color for new messages appearing after each refresh. If a user is a moderator/admin he should get [x] option next to each message he can select to be able to do all the moderation / admin options of regarding the specific message/user. The Admin should have another admin page regarding the setup of the chat like user/ moderation/admin text colors etc... witch he can access via a link to the specific page. Note: This is just for interest sake no real job offering yet. I want this script to be able to be implemented via a .mobi portal on a IM application for mobiles named Mxit. It has many limitations...
  10. Hi guys, Does anyone know why my code isn't working?: $servername="127.0.0.1"; $username="root"; $password=""; $dbname="testdb"; $connection = new mysqli($servername,$username,$password); $result = "SELECT 'Country' from 'w'"; echo '<select>'; foreach($result as $res) { echo '<option value="'.$res['Country'].'">' . $res['Country'] . '</option>'; } echo '</select>'; } There's not a credential issue, the table is called 'w' and the collumn I'm trying to get the values from is 'Country' Any help is appreciated. Cheers, Broken
  11. Hi there, I've built a form that should generate an e-mail, but it's not working properly. At first the page wouldn't display at all due to a problem with the EOD tags, that's fixed and I can now see a page, but when I type something in and hit submit, it's just not doing what it's supposed to do. Like I said it's supposed to e-mail me the data and leave the form filled with the data just submitted; it's doing neither. It is however posting the info into the address bar, so something is happening at least. here's a link to the page: http://www.remembertheprojector.com/php/testform.php here's the code: <?php if ($_POST['parse_var'] == "testform"){ $emailtitle = 'New E-mail'; $youremail = 'junk@remembertheprojector.com'; $namefield = $_POST['name']; $emailfield = $_POST['email']; $messagefield = $_POST['message']; $body = <<<EOD <br><hr><br> Name: $namefield <br /> Email: $emailfield <br /> Message: $messagefield <br /> EOD; $headers = "From: $emailfield\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail("$youremail", "$emailtitle", "$body", "$headers"); $sent = "Thank you!"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/xml; charset=utf-8" /> <title>Contact Form</title> </head> <body> <table width="400" border="1" cellpadding="0" align="center"> <tr> <td align="center">Contact me? <br /> <br /> <form id="contactform" name="contactform" methord="post" action="testform.php"> <table width="100%" border="0" cellpadding="3"> <tr> <td width="25%" align="right">Name:</td> <td width="75%"> <label for="name"></lable> <input type="text" name="name" id="name" maxlength="30" size="30" value="<?php print "$namefield"; ?>" /> </td> </tr> <tr> <td width="25%" align="right">Email:</td> <td width="75%"> <label for="email"></lable> <input type="text" name="email" id="email" maxlength="50" size="50" value="<?php print "$emailfield"; ?>" /> </td> </tr> <tr> <td width="25%" align="right">Message:</td> <td width="75%"> <label for="message"></lable> <textarea name="message" id="message" cols="40" rows="5"><?php print "$messagefield"; ?></textarea> </td> </tr> <tr> <td width="25%"></td> <td width="75%" align="right"> <input type="reset" name="reset" id="reset" value="reset" /> <input type="hidden" name="parse_var" id="parse_var" value="testform" /> <input type="submit" name="submit" id="submit" value="submit" /> </td> </tr> <tr> <td width="100%"><?php print "$sent"; ?></td> </tr> </table> </form> </td> </tr> </table> </body> </html> Also attached is a screen shot of the php so you can see how it's tabbed. Thanks for any help.
  12. Hi all, I have quite a big issue regarding an e-commerce site I'm in the process of redeveloping. The company whom I work for sell hundreds of event tickets to clients worldwide. I've been tasked with rebuilding the entire shop as its very basic at the moment, and only accepts PP express. The shop itself only has a few categories so the design / layout isn't a problem for me. The main issue is with the dev site of things. They want me to integrate a so-called 'white label' or 'affiliate' type system so that other 'agencies' can register with ourselves. From there they would have access to our product list and be able to add them on their own shop. In turn they would receive a commission for every sale. I was thinking about going with Prestashop or Drupal but this kind ingratiation has me thinking if its even possible. I'm not even sure if there are any off-the-self solutions that would do exactly what we need, without hiring a developer.. anyone here have any experience building a similar system? Any guidance of any of this would be greatly appreciated. Thanks 4T7
  13. Hi again PHP Freaks. So I would like to code something similar to the buy menu of Counter-strike: Global offensive in-game module, just in a browser and for a project of mine. I've made the design in photoshop to illustrate better. I just don't know what I should look into to make this kind of menu, I would love if someone could explain me what languages that this would require. (I'm guessing HTML, CSS and jQuery but I am not sure) more specific help like which particular codes would be much appreciated. Here is a picture of what I would like to create. (Also attached) http://i1227.photobucket.com/albums/ee433/rec0ill/CSGOKeyz_zps4195288a.png
  14. I'm trying to figure out how to combine these queries, to decrease server load and load time, but I'm not so good with MySQL queries. Does anyone have any ideas, any help is greatly appreciated, I've been tinkering with this for days now. $Actv = 0; $ActvCount = -1; $ActvUpgrade = 0; $ActvRenewal = 0; $ActvVehicleAdds = 0; $result2 = mysql_query("SELECT * FROM tblOperators WHERE OperatorLocale = 'USA' and OperatorStatus = 'ACTIVE' and Team = 'RENEWALS'"); while($row2 = mysql_fetch_array($result2)) { $operID = $row2['OperatorID']; $result = mysql_query("SELECT * FROM tblUserPayments WHERE OperatorID = '$operID' AND PaymentStatus='OK' AND PaymentDate LIKE '$currentDate%'"); while($row = mysql_fetch_array($result)) { if($row['PaymentReason'] == 'ACTIVATION'){ ++$ActvCount; //if($row['PaymentMethod'] == 'CREDITCARD'){ $ActvUpgrade += $row['ChargeAmount']; //} } elseif($row['PaymentReason'] == 'UPGRADE'){ $userid = $row['UserID']; $paymentdate = $row['PaymentDate']; $result1 = mysql_query("SELECT * FROM tblRenewalInvoices WHERE UserID='$userid' AND ('$paymentdate' >= DATE_SUB(DueDate, INTERVAL 90 DAY) AND '$paymentdate' < DATE_ADD(DueDate, INTERVAL 15 DAY)) AND ParentInvoiceID IS NULL ORDER BY InvoiceNum DESC LIMIT 1"); if( $row1 = mysql_fetch_array($result1)) { $packageid = $row['PackageID']; $pack = mysql_query("SELECT * FROM tblUserPackages WHERE PackageID='$packageid';"); if($pack1 = mysql_fetch_array($pack)){ $expDate = $pack1['ExpirationDate']; $dueDate = $row1['DueDate']; $days = mysql_fetch_row(mysql_query("SELECT TO_DAYS('$expDate')-TO_DAYS('$dueDate');")); $months = (int)( ((int)$days + 14) / 30.4); $years = (int) ( ((int)$days + 182) / 365); $Intervals = 0; if($years > 0){ $Intervals = $years; } if(($pack1['Package'] or 'GPS-SVL') or ($pack1['Package'] == 'GPS-1') or ($pack1['Package'] == 'GPS-1PLUS')){ if($Intervals > 1){ //if($row['PaymentMethod'] == 'CREDITCARD'){ $Actv += $row['ChargeAmount']; //} } else{ //if($row['PaymentMethod'] == 'CREDITCARD'){ $ActvRenewal += $row['ChargeAmount']; //} } } else{ $Actv += $row['ChargeAmount']; } } else{ } } else{ //if($row['PaymentMethod'] == 'CREDITCARD') $ActvUpgrade += $row['ChargeAmount']; } } elseif($row['PaymentReason'] == 'ADDVEHICLE'){ //if($row['PaymentMethod'] == 'CREDITCARD') $ActvVehicleAdds += $row['ChargeAmount']; } } $result = mysql_query("SELECT * FROM tblRenewalCalls WHERE OperatorID = '$operID' AND PayStatus='OK' AND DateSubmitted LIKE '$currentDate%'"); while( $row = mysql_fetch_array($result) ) { if($row['Charged']){ if ((int)$row['RenewYears'] > 1) { $Actv += $row['RenewTotal']; } else{ $ActvRenewal += $row['RenewTotal']; } } } } $total = $Actv+$ActvRenewal+$ActvUpgrade+$ActvVehicleAdds; $ActvRenewal = $total - ($ActvVehicleAdds + $ActvUpgrade); $upgradeEarned = $ActvUpgrade; $renewalEarned = $ActvRenewal;
  15. Just curious how other people feel about this. I am working on an application where a lot of info is pulled from MySQL and needed on multiple pages. Would it make more sense to... 1. Pull all data ONCE and store it in SESSION variables to use on other pages 2. Pull the data from the database on each new page that needs it I assume the preferred method is #1, but maybe there is some downside to using SESSION variables "too much"? Side question that's kind of related: As far as URLs, is it preferable to have data stored in them (i.e. domain.com/somepage.php?somedata=something&otherdata=thisdata) or use SESSION variables to store that data so the URLs can stay general/clean (i.e. domain.com/somepage.php)? Both are probably loaded questions but any possible insight would be appreciated. Thanks! Greg
  16. I’m trying to write a post-panel where the user can see the preview of his post to the right of the text area he’s writing into. I tried the following into a file called writepost.php : <?php $text=(isset($_GET['message']))?$_GET['message']:''; $formatted_text=nl2br(stripslashes(htmlspecialchars($text))); echo '<form method="post" action="proceedtopost.php?>'. '<table>'. '<td style width="50%"><tr>'. '<fieldset> Write your post here : <br> <textarea cols="50" rows="12" '. 'id="message" name="message">'.$text.'</textarea>'. '</fieldset> <p> '. '<input type="submit" name="submit" formaction="writepost.php" value="Preview" /> '. '<input type="submit" name="submit" value="Sent" /> '. '</p>'. '</td>'. '<td>'. '<fieldset> Your post will appear as follows :<br><p> '. $formatted_text. '</fieldset>'. '</td></tr>'. '</table>'. '</form>'; There are several things wrong with this code : 1) When the user hits the "Preview" button, I expect writepost.php to be reloaded (this is what happens), and the current content of the textarea to be stored in $_GET['message'] (this is not what happens). 2) Why does my browser output the preview part under the text area (or in other words outputs the HTML table as a single column of two cells), when I insist in my HTML code for the table to be displayed as a single row ?
  17. Hi I'm trying to set up my first contact form, but I keep getting this error message: Parse error: syntax error, unexpected end of file in /home/remem539/public_html/php/testform.php on line 85 here's my code, what am I doing wrong? <?php if ($_POST['parse_var'] == "testform"){ $emailtitle = 'New E-mail'; $youremail = 'junk@remembertheprojector.com'; $namefield = $_POST['name']; $emailfield = $_POST['email']; $messagefield = $_POST['message']; $body = <<<EOD <br><hr><br> Name: $namefield <br /> Email: $emailfield <br /> Message: $messagefield <br /> EOD; $headers = "From: $emailfield\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail("$youremail", "$emailtitle", "$body", "$headers"); $sent = "Thank you!"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/xml; charset=utf-8" /> <title>Contact Form</title> </head> <body> <table width="400" border="1" cellpadding="0" align="center"> <tr> <td align="center">Contact me? <br /> <br /> <form id="contactform" name="contactform" methord="post" action="testform.php"> <table width="100%" border="0" cellpadding="3"> <tr> <td width="25%" align="right">Name:</td> <td width="75%"> <label for="name"></lable> <input type="text" name="name" id="name" maxlength="30" size="30" value="<?php print "$namefield"; ?>" /> </td> </tr> <tr> <td width="25%" align="right">Email:</td> <td width="75%"> <label for="email"></lable> <input type="text" name="email" id="email" maxlength="50" size="50" value="<?php print "$emailfield"; ?>" /> </td> </tr> <tr> <td width="25%" align="right">Message:</td> <td width="75%"> <label for="message"></lable> <textarea name="message" id="message" cols="40" rows="5"><?php print "$messagefield"; ?></textarea> </td> </tr> <tr> <td width="25%"></td> <td width="75%" align="right"> <input type="reset" name="reset" id="reset" value="reset" /> <input type="hidden" name="parse_var" id="parse_var" value="testform" /> <input type="submit" name="submit" id="submit" value="submit" /> </td> </tr> <tr> <td width="100%"><?php print "$sent"; ?></td> </tr> </table> </form> </td> </tr> </table> </body> </html>
  18. Hi everybody I am one stressed person right now. I had been away for a while only to return recently and find out that none of my websites (with Hostpapa) had been working. I sent the technical support team an email and they told me that my websites were not PHP 5.4 compatible. They also said: "As register_globals is deprecated in PHP 5.4 and because of this you are receiving errors on your website. You will have to update your website code and remove register global references. If this can not be done then in that case the last option would be to upgrade to VPS hosting." Why have things just suddenly changed? How can I fix this problem? It's affected many of the sites on my host - and in some cases - the submission forms are not working in connection with my Aweber account. Please help as this has shocked me quite badly - and needs resolving asap. Thank you in advance
  19. i've use php-event-calender for showing event from table.when i click on event date, it's dispay table details for relevent date correctly in localhost.but it's didn't show details in live server. index.php <div id="Calendar"> </div> <div id="Events"> </div> <script language="javascript" src="calendar.js"></script> calender.php <?php error_reporting(0); include("config.php"); /// get current month and year and store them in $cMonth and $cYear variables (intval($_REQUEST["month"])>0) ? $cMonth = intval($_REQUEST["month"]) : $cMonth = date("m"); (intval($_REQUEST["year"])>0) ? $cYear = intval($_REQUEST["year"]) : $cYear = date("Y"); // generate an array with all dates with events $sql = "SELECT * FROM reservation WHERE arrival LIKE '".$cYear."-".$cMonth."-%'"; $result = db::getInstance()->query($sql); while ($row = $result->fetch()) { $events[$row["arrival"]]["f_name"] = $row["f_name"]; $events[$row["arrival"]]["l_name"] = $row["l_name"]; } // calculate next and prev month and year used for next / prev month navigation links and store them in respective variables $prev_year = $cYear; $next_year = $cYear; $prev_month = intval($cMonth)-1; $next_month = intval($cMonth)+1; // if current month is December or January month navigation links have to be updated to point to next / prev years if ($cMonth == 12 ) { $next_month = 1; $next_year = $cYear + 1; } elseif ($cMonth == 1 ) { $prev_month = 12; $prev_year = $cYear - 1; } if ($prev_month<10) $prev_month = '0'.$prev_month; if ($next_month<10) $next_month = '0'.$next_month; ?> <table width="100%" style="width:800px;height:600px;background-color:#FFFFFF;"> <tr> <td class="mNav"><a href="javascript:LoadMonth('<?php echo $prev_month; ?>', '<?php echo $prev_year; ?>')"><<</a></td> <td colspan="5" class="cMonth"><?php echo date("F, Y",strtotime($cYear."-".$cMonth."-01")); ?></td> <td class="mNav"><a href="javascript:LoadMonth('<?php echo $next_month; ?>', '<?php echo $next_year; ?>')">>></a></td> </tr> <tr> <td class="wDays">M</td> <td class="wDays">T</td> <td class="wDays">W</td> <td class="wDays">T</td> <td class="wDays">F</td> <td class="wDays">S</td> <td class="wDays">S</td> </tr> <?php $first_day_timestamp = mktime(0,0,0,$cMonth,1,$cYear); // time stamp for first day of the month used to calculate $maxday = date("t",$first_day_timestamp); // number of days in current month $thismonth = getdate($first_day_timestamp); // find out which day of the week the first date of the month is $startday = $thismonth['wday'] - 1; // 0 is for Sunday and as we want week to start on Mon we subtract 1 for ($i=0; $i<($maxday+$startday); $i++) { if (($i % 7) == 0 ) echo "<tr>"; if ($i < $startday) { echo "<td> </td>"; continue; }; $current_day = $i - $startday + 1; if ($current_day<10) $current_day = '0'.$current_day; // set css class name based on number of events for that day if ($events[$cYear."-".$cMonth."-".$current_day]<>'') { $css='withevent'; $click = "onclick=\"LoadEvents('".$cYear."-".$cMonth."-".$current_day."')\""; } else { $css='noevent'; $click = ''; } echo "<td class='".$css."'".$click.">". $current_day . "</td>"; if (($i % 7) == 6 ) echo "</tr>"; } ?> </table> events.php <?php error_reporting(0); include("config.php"); $sql = "SELECT * FROM reservation WHERE arrival = '".mysql_real_escape_string($_REQUEST["date"])."' AND status='pending'"; $result = db::getInstance()->query($sql); while ($row = $result->fetch()) { echo "<h2>"."Reservation ID :"." ".$row["res_id"]."</h2>"; echo "<b>"."Client Name :"."</b>"."<span>".$row["f_name"]." ".$row["l_name"]."</span>"."</br>"; echo "<b>"."Address :"."</b>"."<span>".$row["address"]."</span>"."</br>"; echo "<b>"."City :"."</b>"."<span>".$row["city"]."</span>"."</br>"; echo "<b>"."Zip :"."</b>"."<span>".$row["zip"]."</span>"."</br>"; echo "<b>"."Country :"."</b>"."<span>".$row["country"]."</span>"."</br>"; echo "<b>"."E-mail :"."</b>"."<span>".$row["email"]."</span>"."</br>"; echo "<b>"."Contact No :"."</b>"."<span>".$row["contact"]."</span>"."</br>"; echo "<b>"."In Date :"."</b>"."<span>".$row["arrival"]."</span>"."</br>"; echo "<b>"."Out Date :"."</b>"."<span>".$row["departure"]."</span>"."</br>"; echo "<b>"."Total Price :"."</b>"."<span>".$row["tot_price"]."</span>"."</br>"; echo "<b>"."Room Id :"."</b>"."<span>".$row["room_id"]."</span>"."</br>"; echo "<b>"."No Of Beds :"."</b>"."<span>".$row["no_beds"]."</span>"."</br>"; } ?> live server show calender and event date fine.but didn't show event details for that date.it's show correctly in localserver.
  20. I have a page that functions like this: The user begins by loading ajaxtest.php, then using a drop-down menu, selects a user, after which a DIV on ajaxtest.php is populated with the user's selction to getuser.php?q=John%Doe Here's a visual representation of what is currently happening, along with the part I don't understand. getuser.php consists largely of a a large HTML table which interacts through PHP with my SQL database. Several of the fields in this table are editable, and after the user changes one of these fields, he can press an "update" button, which calls an AJAX script in update.js and runs update.php, which contains all my SQL queries to update the database, without the user being redirected to this update.php page. All of this is processing perfectly - the user makes some sort of edit, hits "update", and the database gets updated without any redirection or refresh. Here's what I can't figure out though. Once the user makes a change, and hits "update," the database updates, but the end user doesn't see those changes that he made. I can't just do a simple page refresh, because the action is taking place on getuser.php, but getuser.php is loaded inside of a #DIV on ajaxtest.php. If I use something like window.location.reload(), this just refreshes ajaxtest.php and puts the user back to the starting point of having to select a user. This is not what I want. I don't want to refresh ajaxtest.php, I want to "refresh" ajaxtest.php with getuser.php?q=John%Doe insidethe DIV on ajaxtest.php. It seems like this is very common - several forums have this capability, where a user has a page loaded, adds a comment, and sees that comment immediately without a full page refresh. I just don't know how to do it, and I've tried at lengths to search the web for an answer with no luck. Can someone walk me through how to do this?
  21. Hi, I hope this belongs to the right sub-forum. I'm gonna be on the move for quite some time, and I was wondering if there was an [almost] ideal portable PHP development environment, which I can treat just like the non-portable counterpart, which will include using Composer, Laravel, etc. With a little research I found http://zwamp.sourceforge.net/ and http://www.codelobster.com, but I'm not sure how efficient they are. Any of you guys use this approach? Thanks.
  22. I have a 'subscribe' form on a website that uses Ajax to validate the input fields, the form is then processed via php. The actual html code resides on a Wordpress page. I had actually just got the form to work again. The website was static, and I transferred everything over to Wordpress, and the form didnt work. I was able to get it working by specifying the url: in ajax, as an absolute path to my php form. Overnight, something, I'm not sure what, stopped the form from processing. No data is posted to myql, and no email is sent or received. The status message just hangs at "Please wait while we process your information..." This message is in part of my Ajax code, so I am thinking something is wrong with my php script. I have a 'contact' page that uses nearly identical code that the 'subscribe' pages uses to validate the input fields, and it works. I was able to recover both the ajax and php script from an earlier time when they did work, I uploaded back to my server and nothing, the form still does not process. I also made sure my database credentials were correct with my host, and even tested my connection to mysql which I was able to connect. Next, I made sure I was able to send mail with my host. I don't know what is causing the form to hang, and I would love to get this solved; any help would be appreciated! PHP code: <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { define('DB_NAME', '######'); define('DB_USER', '######'); define('DB_PASSWORD', '######'); define('DB_HOST', '######'); $first = Trim(stripslashes($_POST['First'])); $last = Trim(stripslashes($_POST['Last'])); $city = Trim(stripslashes($_POST['City'])); $state = Trim(stripslashes($_POST['State'])); $country = Trim(stripslashes($_POST['Country'])); $email = Trim(stripslashes($_POST['Email'])); $tempt = $_POST['tempt']; $tempt2 = $_POST['tempt2']; if ($tempt == 'http://' && empty($tempt2)) { $error_message = ''; $reg_exp = "/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9­-]+\.[a-zA-Z.]{2,5}$/"; if(!preg_match($reg_exp, $email)) { $error_message .= "<p>A valid email address is required.</p>"; } if (empty($first)) { $error_message .= "<p>Please provide your first name.</p>"; } if (empty($last)) { $error_message .= "<p>Please provide your last name.</p>"; } if (!empty($error_message)) { $return['error'] = true; $return['msg'] = "<p>The request was successful, but the form was not filled out correctly.</p>".$error_message; echo json_encode($return); exit(); $dbc = mysql_connect('######', '######', '######'); $check_email_for_duplicates = mysql_query($dbc, "select * from 'members' where 'Email' = '".mysql_real_escape_string($email)."'"); if(mysql_num_rows($check_email_for_duplicates) > 0) //Email address is unique within this system and must not be more than one { echo 'Sorry, <b>'.$email.'</b> has already subscribed.'; } } else { $return['error'] = false; $return['msg'] = "<p style='top:12px; color:#ff6000; left:15px; text-align:left; font-size:1.50em;'>".$first .", <p style='top:0px; width:100%; left:15px; text-align:left; line-height:1.1em;'>your subscription request has been processed.</p>"; echo json_encode($return); } } else { $return['error'] = true; $return['msg'] = "<p>There was a problem while sending this form. Try it again.</p>"; echo json_encode($return); } $to = "######, ######"; $subject = "New Email Address for Mailing List"; $headers = "From: $email\n"; $headers .= "Content-type: text/html\r\n"; $message = "<span style='color:#252525; font-size:1.2em;'>A visitor to 3Elements Review has entered the following information so they can be added to your mailing list.</span><br>\n <br> <span style='color:#252525; font-weight:bold; font-size:1.35em;'>$first $last</span><br> <span style='color:#252525; font-weight:bold; font-size:1.35em;'>$city, $state</span><br> <span style='color:#252525; font-weight:bold; font-size:1.35em;'>$country</span><br> <span style='color:#252525; font-weight:bold; font-size:1.35em;'>$email</span>"; mail($to,$subject,$message,$headers); $user = "$email"; $usersubject = "Thank you for subscribing to 3Elements Review"; $userheaders = "From: ######\n"; $userheaders .= "Content-type: text/html\r\n"; $usermessage = "<body style='background-color:#dbf7ff; width:100%; height:105%;'> <span style='color:#353535; font-size:2em; font-weight:bold; font-family:pt sans;'>Welcome</span> <span style='color:#ff6000; font-size:2em; font-weight:bold; font-family:pt sans;'>$first</span><span style='color:#353535; font-size:2em; font-weight:bold; font-family:pt sans;'>,</span><br> <br> <span style='color:#353535; font-size:1.30em; font-family:noto serif;'>We're glad that you've decided to subscribe to our email list. We adore the people of $city!</span><br> <br> <span style='color:#353535; font-size:1.30em; font-family:noto serif;'>We have a lot of great things in the works that we're excited about at <em>3Elements Review,</em> and we can't wait to show <em>you</em> and all of the other writers, artists, and photographers immersed in the $city literary scene, all that <strong><em>3Elements Review</em></strong> has in store!</span><br> <br> <span style='color:#353535; font-size:1.30em; font-family:noto serif;'>Stay tuned for information regarding our issue release dates, contests, and other news!<br> <br> If you find us interesting enough, like us on Facebook and follow us on Twitter!</span><br> <br> <br> <span style='color:#353535; font-size:1.30em; font-family:noto serif;'>Sincerely,</span><br> <br> <span style='color:#ff6000; font-size:1.50em; font-family:pt sans;'>The 3Elements Team</span><br> <br> <br> <p> <span style='color:#353535; font-size:1.25em; font-family:pt sans; font-weight:bold;'>######</span><br> <span style='color:#353535; font-size:1.25em; font-family:pt sans; font-weight:bold;'>######</span><br> <span style='color:#ff6000; font-size:1.25em; font-family:pt sans; font-weight:bold;'>######</span><br> <img src='http://www.3elementsreview.com/images/logo-2.svg' width='122px' height='95px'> <br> <p> <span style='color:#353535; font-size:.9em; font-family:noto serif;'>You're receiving this email because you or someone you know subscribed you to our email list.</p> <span style='color:#353535; font-size:.9em; font-family:noto serif;'>If you would rather not receive email from 3Elements Review, you can unsubscribe by clicking <a href='mailto:######?Subject=Unsubscribe%20Request'>here</a>.</p> <br> <p> </body>"; mail($user,$usersubject,$usermessage,$userheaders); $link = mysql_connect('######', '######', '######'); if (!$link) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db('######', $link); if (!$db_selected) { die('Can\'t use ' . '######' . ': ' . mysql_error()); } $value = mysql_real_escape_string($_POST['First']); $value2 = mysql_real_escape_string($_POST['Last']); $value3 = mysql_real_escape_string($_POST['City']); $value4 = mysql_real_escape_string($_POST['State']); $value5 = mysql_real_escape_string($_POST['Country']); $value6 = mysql_real_escape_string($_POST['Email']); $sql = "INSERT INTO members (First, Last, City, State, Country, Email, Date) VALUES('$value','$value2','$value3','$value4','$value5','$value6',NOW() + interval 2 hour)"; if (!mysql_query($sql)){ die('Error: ' . mysql_error()); } mysql_close(); }else{} ?> Ajax code: //*************************************************************REQUIRED FIELD SCRIPT FOR SUBSCRIBE PAGE*************************************************// $(document).ready(function() { $('form #response2').hide(); $('.button2').click(function(e) { e.preventDefault(); var valid = ''; var required = ' is required'; var first = $('form #first').val(); var last = $('form #last').val(); var email = $('form #email').val(); var tempt = $('form #tempt').val(); var tempt2 = $('form #tempt2').val(); if (first = '' || first.length <= 1) { valid += '<p>Your first name' + required + '</p>'; } if (last = '' || last.length <= 1) { valid += '<p>Your last name' + required + '</p>'; } if (!email.match(/^([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$)/i)) { valid += '<p>Your e-mail address' + required + '</p>'; } if (tempt != 'http://') { valid += '<p>We can\'t allow spam bots.</p>'; } if (tempt2 != '') { valid += '<p>A human user' + required + '</p>'; } if (valid != '') { $('form #response2').removeClass().addClass('error2') .html('' +valid).fadeIn('fast'); } else { $('form #response2').removeClass().addClass('processing2').html('<p style="top:0px; left:0px; text-align:center; line-height:1.5em;">Please wait while we process your information...</p>').fadeIn('fast'); var formData = $('form').serialize(); submitForm(formData); } }); }); function submitForm(formData) { $.ajax({ type: 'POST', url: 'http://3elementsreview.com/blog/wp-content/themes/3elements/php-signup/sign-up-complete.php', data: formData, dataType: 'json', cache: false, timeout: 4000, success: function(data) { $('form #response2').removeClass().addClass((data.error === true) ? 'error2' : 'success2') .html(data.msg).fadeIn('fast'); if ($('form #response2').hasClass('success2')) { setTimeout("$('form #response2').fadeOut('fast')", 6000); } }, error: function(XMLHttpRequest, textStatus, errorThrown) { $('form #response2').removeClass().addClass('error2') .html('<p>There was an <strong>' + errorThrown + '</strong> error due to an <strong>' + textStatus + '</strong> condition.</p>').fadeIn('fast'); }, complete: function(XMLHttpRequest, status) { $('form')[0].reset(); } }); };
  23. This is my code it always returns null i know that there is info in the table but it never works $sql = 'SELECT * FROM $user WHERE ticker = "$ticker"'; $resultsql = mysqli_query($conp,$sql); $row = mysqli_fetch_array($resultsql); echo $row[ticker]; var_dump($row); echo '<br>';
  24. Hello all, I am working on my own PHP project where I can build myself my own forum just like how this site functions. I would like to have user accounts and when you log in have a list of bulletin topics that you can choose from and then post your own question or topic and then other users can go to your post and write answers to it. I know there are many forums out there that you can make and set up to use but I would like to have my own so I can customize it any way I want. Could I get some ideas on where I should start with this. I have been working on a website with a login functionality and I almost have that set up, then my next steps will be making it so users will be able to post topics. I been doing google research trying to get some tutorials on this but I haven’t found one that is much help. I will be using phpmyadmin database and I plan on writing my sql as mysqli. Thank you.
  25. Hello - hope you are all well. I am creating a website for a family friend who has a shop. See preview of the site in this picture .... Currently the results are showing in one column. I want to show them in three columns in the format of: 1 2 3 4 5 6 7 8 9 etc But formatted with the picture and then the title and the border. The current code i have is.... HEAD <?php $sql = "SELECT * FROM abs_productcat WHERE catid = $catid ORDER BY catid ASC"; $can = mysql_query($sql); $catname = mysql_fetch_assoc($can); ?> BODY <?php while ($row_pro = mysql_fetch_assoc($rs_proddetails)) { ?><tr> <td><table width="243" border="0" align="left" cellpadding="15" cellspacing="0" class="sectionborders"> <tr> <td height="120" align="center"><p><strong><a href="indproducts.php?ProductID=<?php echo $row_pro['ProductID']; ?>"><img src="products/product_<?php echo $row_pro['ProductID']; ?>" alt="<?php echo $row_pro['ProductName']; ?>" height="120" class="sectionborders" border="0" /></a></strong></p> <p><strong><a href="indproducts.php?ProductID=<?php echo $row_pro['ProductID']; ?>" class="products"><?php echo $row_pro['ProductName']; ?></a></strong></p></td> </tr> </table></td> </tr> <tr> <td> </td> </tr> <?php } ?> THANK YOU FOR YOUR 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.