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. Hello, I am trying to import a CSV file into an existing mysql table but it doesn't seem to work well. Here is how my mysql is looking like: 1 a_id int(11) AUTO_INCREMENT 2 a_lobecoid int(7) 3 a_code varchar(30) utf8_general_ci 4 a_omschint varchar(60) utf8_general_ci 5 a_beveiligingniv int(5) 6 a_type varchar(5) utf8_general_ci 7 a_assortiment int(5) 8 a_discipline varchar(30) utf8_general_ci 9 a_brutoprijs varchar(50) utf8_general_ci 10 a_status varchar(5) utf8_general_ci 11 a_levcode varchar(10) utf8_general_ci 12 a_omschr_nl varchar(60) utf8_general_ci 13 a_omschr_fr varchar(60) utf8_general_ci these are some lines from my CSV file 16158|-H|Factory installed heater|10|S|400|CCTV|45.0|E| 1829|Factory installed heater|Factory installed heater 16159|-IR|Factory installed IR LED ring|10|S|400|CCTV|50.0|E| 1829|Factory installed IR LED ring|Factory installed IR LED ring 9001|00-SBN2|Smoke box niet geaspireerd,230VAC|10|S|267|BRAND|1587.03|D| 642|Smoke box niet geaspireerd,230VAC|Smoke box pas aspiré,230VCA 9003|00-TP1|Telescopische verlengstok voor Smoke box,2,4-4,6m|10|S|267|BRAND|644.09000000000003|D| 642|Telescopische verlengstok voor Smoke box,2,4-4,6m|Rallonge téléscopique pour Smoke box,2,4-4,6m 9004|00-TP2|Telescopische verlengstok voor Smoke box,2,4-9,2m|10|S|267|BRAND|944.64999999999998|D| 642|Telescopische verlengstok voor Smoke box,2,4-9,2m|Rallonge téléscopique pour Smoke box,2,4-9,2m 12161|001-0081|Thermistor probe,rood, high temp. 0-+150°C|10|S|52|INBRAAK|136.91|D| 1731|Thermistor probe,rood, high temp. 0-+150°C|Sonde température,rouge,high temp. 0-+150°C Here you have the code for the import: $upload_article_query = "LOAD DATA INFILE 'ARTIKELS.CSV' INTO TABLE artikelen FIELDS TERMINATED BY '|' LINES TERMINATED BY '\\r\\n' (a_lobecoid, a_code, a_omschint, a_beveiligingniv, a_type, a_assortiment, a_discipline, a_brutoprijs, a_status, a_levcode, a_omschr_nl, a_omschr_fr)"; $upload_article_stmt = $dbh->prepare($upload_article_query); $upload_article_stmt->execute(); If i use the code then in the MYSQL table the first line is filled in but where the second line has to start it just writes it into the last column and doesn't start a new line. Also if i edit that first line it shows a lot of "?" (questionmarks) into a window symbol. Anyone has an idea what i am doing wrong? In attachment some printscreens of my table after the insert. Apologies for the Dutch language. Thanks in advance
  2. Good day, I have problem on subtracting time. Can anyone give me a hint how will I going to do that. I already manage to get the SUM on time addition using this method. $data = array('1:52:37','9:56:39','08:04:22','05:32:20'); echo convertTime($data); - ANSWER 25:25:58 function convertTime($data){ $seconds = null; $minutes = null; $hours = null; foreach($data as $key => $value){ $time1 = explode(':',$value); list($h[$key],$m[$key],$s[$key]) = $time1; $seconds += $s[$key]; $minutes += $m[$key]; $hours += $h[$key]; } $total_sec_min = intval($seconds / 60); $total_seconds = $seconds % 60; #$total_seconds; $total_minutes = $minutes % 60; if($total_sec_min > 0){ $total_minutes = $total_minutes + $total_sec_min; } $total_min_hr = intval($minutes / 60); $total_hours = $hours; if($total_min_hr > 0){ $total_hours = $total_hours + $total_min_hr; } return $total_hours.':'.sprintf("%02s",$total_minutes).':'.sprintf("%02s",$total_seconds); } But I really got hard time when it comes to subtraction.
  3. <?PHP require("../fpdf/fpdf.php"); include("db.classes.php"); $g = new DB(); $g->connection(); class PDF extends FPDF { .....codes..... } $pdf = new PDF(); .....codes..... $pdf->SetFont('Arial','',14); $pdf->AddPage('L', 'Legal'); $pdf->SetXY(20,20); $pdf->image('../images/DCWD Watermark.png'); $pdf->SetY(35); // call the table creation method $pdf->SetFont('Arial','B',16); $pdf->Cell(0,10,$plateNo); $pdf->SetY(45); $pdf->SetFont('Arial','B',16); $pdf->Cell(0,10,$model); $pdf->SetXY(310, 45); $pdf->SetFont('Arial','B',16); $pdf->Cell(0,10,date("m/d/Y")); $pdf->SetY(55); $pdf->BuildTable($header,$data); $pdf->Output(); ?> Why is FPDF's Output not working? or is something wrong with my browser? I already tried putting paramaters on it but still no go I tried Output('foo.pdf','I') not working but if i itegrate my chrome withIDM it just downloads but when i disable integrationnothing happens.
  4. Hello! I was assigned to create a simple php game as a part of my grade. I'm not really a php expert and this isnt really working. I copied some of the code from this website, but this isn't really working for me. I don't really know how to solve the problem and connect that two files. Part 1: <html> <head> <title>PHP based example Game - Earth & Wind & Fire (aka Paper-Scissors-Rock)</title> </head> <body> <center> <div id="game"> <a href="?item=earth">Earth<br /><img src="images/sand.png" width="135" height="135" alt="Earth"></a><br /><a href="?item=wind">Wind<br /><img src="images/wind.png" width="135" height="135" alt="Wind"></a><br /><a href="?item=fire">Fire<br /><img src="images/fire.png" width="135" height="135" alt="Fire"></a><br /></div> </center> </body> </html> Part 2: <?php function showComponents($items = null) { $pictures = array( "earth" => '<a href="?item=earth">Earth<br /><img src="images/sand.png" width="135" height="135" alt="Earth"></a><br />', "wind" => '<a href="?item=wind">Wind<br /><img src="images/wind.png" width="135" height="135" alt="Wind"></a><br />', "fire" => '<a href="?item=fire">Fire<br /><img src="images/fire.png" width="135" height="135" alt="Fire"></a><br />', ); if ($items == null) : foreach( $pictures as $items => $value ): echo $value; endforeach; else: echo str_replace("?item={$items}", "#", $pictures[$items]); endif; } function game() { if ( isset($_GET['item']) == TRUE ) : $pictures = array('earth','wind','fire'); $playerPic = strtolower($_GET['item']); $computerPic = $pictures[rand(0, 2)]; echo '<div><a href="http://mapswidgets.com/game.php">New game</a></div>'; if (in_array($playerPic, $pictures) == FALSE): echo "Play as either Earth, Wind or Fire."; die; endif; if ( $playerPic == 'fire' && $computerPic == 'wind' OR $playerPic == 'earth' && $computerPic == 'fire' OR $playerPic == 'wind' && $computerPic == 'earth' ): echo '<h2>You Win!</h2>'; endif; if ( $computerPic == 'fire' && $playePic == 'wind' OR $computerPic == 'earth' && $playerPic == 'fire' OR $computerPic == 'wind' && $playerPic == 'earth' ): echo '<h2>Computer wins!</h2>'; endif; if ($playerPic == $computerPic) : echo '<h2>House wins! =)</h2>'; endif; showComponents($playerPic); showComponents($computerPic); else : showComponents(); endif; } ?> Thanks for your time and help!
  5. Hi! I was assigned to create a simple php game as a part of my grade, but i got stuck. I'm not really a php expert and this isnt really working. I managed to get some of the code/game working, but it's pointless imo. I'm looking for someone who would take 3 mins and fix this code for me. The game is called "Random number guessing game." From the title you can see that the game is not really complicated. Code: <html> <head> <title></title> </head> <body> <h1> Ugani Random!</h1> <? php if(isset($_POST['submit'])) $x = $_POST['x']; $num = $_POST['num']; $x = rand(1, 10) if($num<$x) { echo " Your number is higher! "<br /> } if($num==$x) { echo " Correct! Press Reset to try again! "<br /> } if($num>$x) { echo " Your number is lower! "<br /> } ?> <p> <form> <input type="number" name="quantity"> <br /> <button type="submit" value="<? echo $x?>">Submit</button> <button type="reset" value="<? echo $num?>">Reset</button> </form> </p> </body> </html> Computer basically generates a random number and compares it to the input part of <p> but it's not working as intended.
  6. Hello, I created a web page that executes request from mysql and prints it on web page. I also created a export submit button to export mysql query in csv format file. When I select values and then click on export buttons, I get nothing and page gets refreshed. Here is the link of my site: rahil.me/index.php Here is the code: These are the buttons: <input type="submit" name="search" value="Search"> <input type="submit" name="export" value="Export" /> PHP code: if (isset($_POST['export'])) { if (empty($_POST['service'])) { echo "Please select service in dropdown" . "</br>"; } else { $service = $_POST['service']; } if (empty($_POST['environment'])) { echo "Please select Environment in dropdown" . "</br>"; } else { $env = $_POST['environment']; } if ((!empty($service)) && (!empty($env))) { $sql="SQLQUERY REMOVE"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } $result = mysqli_query($con,$sql); /* * send response headers to the browser * following headers instruct the browser to treat the data as a csv file called export.csv */ header('Content-Type: text/csv'); header('Content-Disposition: attachment;filename=export.csv'); /* * output header row (if atleast one row exists) */ $row = mysqli_fetch_assoc($result); if ($row) { echocsv(array_keys($row)); } /* * output data rows (if atleast one row exists) */ while ($row) { echocsv($row); $row = mysqli_fetch_assoc($result); } /* * echo the input array as csv data maintaining consistency with most CSV implementations * - uses double-quotes as enclosure when necessary * - uses double double-quotes to escape double-quotes * - uses CRLF as a line separator */ function echocsv($fields) { $separator = ''; foreach ($fields as $field) { if (preg_match('/\\r|\\n|,|"/', $field)) { $field = '"' . str_replace('"', '""', $field) . '"'; } echo $separator . $field; $separator = ','; } echo "\r\n"; } } }
  7. Newb here trying to build a form that works with ints to count how many red shirts die in a classic episode of star trek (exercise to get better with forms and ints). I have an error which reads as '7 Error message: Undefined index: rsTot'. I have tried a few things and read that setting it(casting it?) as a float was the safest way to work with the int, however each thing i've attempted results in some sort of error so after a day of reading and trying i'm very confused and hoping for an answer I can understand here. I have read through stackOverflow for an answer but not seen one which i can understand and apply that speaks to the problem i'm having of initially entering and process a number as an int which i can later do some math on. error can be seen here: http://zephir.seattlecentral.edu/~jstein11/itc250/z14/w03c0102_OOPform/w03c0102_OOPform.php <?php //w03c0102_OOPform require '../inc_0700/config_inc.php'; #provides configuration, pathing, error handling, db credentials //END CONFIG AREA ---------------------------------------------------------- $rsTot = (float)$_POST['rsTot'];// float more forgiving int $rsSurvived = (float)$_POST['rsSurvived']; $rsSum = $rsTot - $rsSurvived; $rsRatio = 0; # Read the value of 'action' whether it is passed via $_POST or $_GET with $_REQUEST if(isset($_REQUEST['act'])){$myAction = (trim($_REQUEST['act']));}else{$myAction = "";} switch ($myAction) {//check 'act' for type of process case "display": # 2)Display user's name! showName(); break; default: # 1)Ask user to enter their name showForm(); } function showForm() {# shows form so user can enter their name. Initial scenario get_header(); #defaults to header_inc.php ?> <script type="text/javascript" src="<?=VIRTUAL_PATH;?>include/util.js"></script> <script type="text/javascript"> function checkForm(thisForm) {//check form data for valid info if(empty(thisForm.YourName,"Field Empty, please fill out")){return false;} return true;//if all is passed, submit! } </script> <p align="center"><?=smartTitle();?></p> <h3 align="center">Star Trek Classic</h3> <h2 align="center">Death-Shirt Calculator</h2> <form action="<?=THIS_PAGE;?>" method="post" onsubmit="return checkForm(this);"> <p align="center">Classic Star Trek Episode Name<br /> <input type="text" name="epName" /><br /><br /> Esitmated number of officers with red shirts<br /> <input type="text" name="rsTot" /><br /><br /> Esitmated number of officers with red shirts<br /> to actually survive the episode<br /> <input type="int" name="rsSurvived" /><br /><br /> <input type="submit" value="Go!"> </p> <input type="hidden" name="act" value="display" /> </form> <?php get_footer(); #defaults to footer_inc.php } function showName() {#form submits here we show entered name get_header(); #defaults to footer_inc.php if(!isset($_POST['epName']) || $_POST['epName'] == '') {//data must be sent feedback("No form data submitted"); #will feedback to submitting page via session variable myRedirect(THIS_PAGE); } if(!ctype_alnum($_POST['epName'])) {//data must be alphanumeric only feedback("Only letters and numbers are allowed. Please re-enter your name."); #will feedback to submitting page via session variable myRedirect(THIS_PAGE); } $epSubmitted = strip_tags($_POST['epName']);# strip data entered echo '<h3 align="center">' . smartTitle() . '</h3>'; echo '<p align="center">Episode Name: <b>' . $epSubmitted . '</b><br />'; echo '<p align="center">Total Red Shirts Appearing: <b>' . $rsTot . '<br />'; echo 'Red Shirts Still Breathing at End of Episode: <b>' . $rsSurvived . '<br />'; echo 'Red Shirt Episode Survival Ratio: <b>' . $rsRatio . '</b>!</p>'; echo '<p align="center"><a href="' . THIS_PAGE . '">RESET</a></p>'; get_footer(); #defaults to footer_inc.php } ?>
  8. hi there is this game i play and i am trying to accomplish a code which adds items coming from the games xml. the game is called zwinky and i'm having a small problem which can maybe be easily fixed. Here are the codes: http://paste.ee/p/JHMow http://paste.ee/p/pIEUt they are written differently. Okay So the problem is a little message when used on my webhost comes up on browser saying : "HTTP/1.1 100 Continue HTTP/1.1 200 OK Date: Sat, 24 May 2014 22:52:31 GMT Server: Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8c DAV/2 mod_jk/1.2.28 Cache-Control: max-age=0, must-revalidate Expires: Thu, 01 Jan 1970 00:00:00 GMT Set-Cookie: anx="os=-&g=-&oc=-&sn=dfprdzwinky4&od=none&op=-&fv=1400971951270&ob=-&om=-&lv=1400971951270&ok=-&nv=1"; Version=1; Domain=.zwinky.com; Max-Age=7776000; Expires=Fri, 22-Aug-2014 22:52:31 GMT; Path=/ Content-Language: en-US Content-Length: 92 Connection: close Content-Type: application/xml;charset=UTF-8 User not signed in" as you can see it says "user not signed in" yet i am signed in into the game.. So i believe somewhere in the code the cookies are wrong or the code doesn't have the necessary elements to show that you are being logged in. to get the cookies/ login info you need to create a game account which takes 10-20 seconds: http://registration.zwinky.com/registration/register.jhtml and then using fiddler/charles or any other method displaying the accounts cookies it should show them up. I don't know what is needed to add to the code to make it work here our other topics on this issue never solved which might help: http://forum.ragezone.com/f144/help-920369/ http://www.webdeveloper.com/forum/showthread.php?268129-php-execute if anyone could help please! it's not hard making the game accounts and viewing the cookies, please and thank you!!!!
  9. Hello, I am trying to convert the Date,Month,Year, Hour:Minutes:Seconds to Timestamp and Timestamp to Date,Month,Year, Hour:Minutes:Seconds . I ve setted the Timezone as Asia/Calcutta in the code . The Code works well when I run in my localhost , But when I run the code in my server located in Dallas,TX,USA the data changes largely . For example : The Timestamp generated for 24-May-2014 00:00:00 is 1400889600 in my localhost (Chennai, India). The Timestamp generated for 24-May-2014 00:00:00 is 1400914800 in my server (Dallas, TX, USA). why this changes occurs even though I ve setted the timezone ? Code: <?php $date = new DateTime(null, new DateTimeZone('Asia/Calcutta')); $ist = ($date->getTimestamp() + $date->getOffset()); echo "<h1>Current Timestamp and Date and Time for India</h1> <b>".$ist.'</b>';echo " ";echo '<b>'.date('D, d M Y H:i:s ',$ist).'+0530</b>'; echo "<br />"; ?> <h1>Timestamp to Date and Time Converter</h1> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="number" name="timestamp_to_dt_timestamp" id="timestamp_to_dt_timestamp" /> <input type="submit" id="submit" name="submit" value="Submit" /> </form> <?php if (isset($_POST['timestamp_to_dt_timestamp'])) { $timestamp_to_dt_timestamp = $_POST['timestamp_to_dt_timestamp']; echo 'Date and Time for the Timestamp :'.$timestamp_to_dt_timestamp.' is : '.date('D, d M Y H:i:s ',$timestamp_to_dt_timestamp); } ?> <h1>Date and Time to TimeStamp Converter</h1> <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"> Date (no preceeding zeros): <input type="text" name="dt_to_timestamp__date" id="dt_to_timestamp__date" value="<?php echo date('j',$ist) ?>" /><br /> Month (number): <input type="text" name="dt_to_timestamp__month" id="dt_to_timestamp__month" value="<?php echo date('n',$ist) ?>" /><br /> Year : <input type="text" name="dt_to_timestamp__year" id="dt_to_timestamp__year" value="<?php echo date('Y',$ist) ?>" /><br /> Hours : <input type="text" name="dt_to_timestamp__hours" id="dt_to_timestamp__hours" value="00" /><br /> Minutes : <input type="text" name="dt_to_timestamp__mins" id="dt_to_timestamp__mins" value="00" /><br /> Seconds : <input type="text" name="dt_to_timestamp__sec" id="dt_to_timestamp__sec" value="00" /><br /> <input type="submit" id="submit" name="submit" value="Submit" /> <p>Leave the time field(s) if you don't know the exact time.</p> </form> <?php if (isset($_POST['dt_to_timestamp__date'])) { $dt_to_timestamp__date = $_POST['dt_to_timestamp__date']; } if (isset($_POST['dt_to_timestamp__month'])) { $dt_to_timestamp__month = $_POST['dt_to_timestamp__month']; } if (isset($_POST['dt_to_timestamp__year'])) { $dt_to_timestamp__year = $_POST['dt_to_timestamp__year']; } if (isset($_POST['dt_to_timestamp__hours'])) { $dt_to_timestamp__hours = $_POST['dt_to_timestamp__hours']; } if (isset($_POST['dt_to_timestamp__mins'])) { $dt_to_timestamp__mins = $_POST['dt_to_timestamp__mins']; } if (isset($_POST['dt_to_timestamp__sec'])) { $dt_to_timestamp__sec = $_POST['dt_to_timestamp__sec']; } if (isset($_POST['dt_to_timestamp__date'])) { if (isset($_POST['dt_to_timestamp__month'])) { if (isset($_POST['dt_to_timestamp__year'])) { if (isset($_POST['dt_to_timestamp__hours'])) { if (isset($_POST['dt_to_timestamp__mins'])) { if (isset($_POST['dt_to_timestamp__sec'])) { echo date(mktime($dt_to_timestamp__hours, $dt_to_timestamp__mins, $dt_to_timestamp__sec, $dt_to_timestamp__month, $dt_to_timestamp__date, $dt_to_timestamp__year)); } } } } } } ?> What I am missing ? -Thanks timestamp.php
  10. I have a black and white image dividing a city into zip codes. So a bunch of shapes and that's it. I load it (imagecreatefrompng) and I'm filling the zipcodes with color based on coordinates of a spot in the zipcode and a color relevant to information about it. If I use imagefill (or imagefilltoborder) to fill a zip code it works great. But - I also need to apply text and lines to that image on top of those filled shapes. My problem is it's always doing the fill last no matter what order I put it in the code - so anywhere a line crosses a zipcode it only gets half filled in. For example I attached an image - if i turn off the lines the white box is filled in with a shade of red. Not a great example since I think the line is right on top of the coordinate of the fill but it does it all over the image. What am I missing? Is there not a way to choose the order your draw to the image object? Is there a way to apply a change before doign the next one short of writing and reloading the file?
  11. Hey, I'm really new to PHP and having some difficulties with $_SESSION and getting userid from the database. I've managed to put content to my database and also a login script. Though, adding sessions has been a pain. Here's what I got so far: $sql = "SELECT username, password FROM users WHERE username = '$username' and password = '$pas'"; $query_login = $db->prepare($sql); $query_login->execute(array('userid' => $userid, 'username' => $username, 'password' => $pas)); $result = $query_login->rowcount(); if ($result>0) { session_start(); $_SESSION['username'] = $username; $_SESSION['logged'] = 1; $_SESSION['userid'] = $result['userid']; header('Location: ../user/user.php'); }
  12. Hi! I have read like crazy to find a tutorial on a login page without My_SQL. Anyway I am working on a easy login/logged out page with sessions. Here is the login page with tree users in an array. The things that I need some hints to solve is, when clicking on login the error message don't show. Instead the script goes to the logged in page right away. And when you write the wrong password you get loged in anyway. I am not sure how or if it's possible to write a varible to a file this way. But I tried and recived a parse error with the txt varible. When searching for topics I get more confused with the My_SQL varibles. I am near a breaking point at cracking the first step on PHP, but need some advice. <?php $page_title = 'Logged in'; //Dynamic title include('C:/wamp/www/PHP/includes/header.html'); ?> <?php session_start(); //A array for the sites users with passwords $users = array( 'Dexter'=>'meow1', 'Garfield'=>'meow2', 'Miro'=>'meow3' ); //A handle to save the varible users to file on a new line from the last entry $handle = fopen("newusers.txt, \n\r") $txt = $users; fclose($handle); if(isset($_GET['logout'])) { $_SESSION['username'] = ''; header('Location: ' . $_SERVER['PHP_SELF']); } if(isset($_POST['username'])) { if($users[$_POST['username']] == $_POST['password']) { $_SESSION['username'] = $_POST['username']; }else { echo "Something went wrong, Please try again"; } } ?> <?php echo "<h3>Login</h3>"; echo "<br />"; ?> <!--A legend form to login--> <fieldset><legend>Fill in your username and password</legend> <form name="login" action="777log.php" method="post"> Username: <br /> <input type="text" name="username" value="" /><br /> Password: <br /> <input type="password" name="password" value="" /><br /> <br /> <input type="submit" name="submit" value="Login" /> </fieldset> </form> <?php //Footer include file include('C:/wamp/www/PHP/includes/footer.html'); ?> The logged in page <?php //Header $page_title = 'Reading a file'; include('C:/wamp/www/PHP/includes/header.html'); ?> <?php session_start(); //Use an array forthe sites users $users = array( 'Dexter'=>'meow1', 'Garfield'=>'meow2', 'Miro'=>'meow3' ); // if(isset($_GET['logout'])) { $_SESSION['username'] = ''; echo "You are now loged out"; //The user is loged out and returned to the login page header('Location: ' . $_SERVER['PHP_SELF']); } if(isset($_POST['username'])) { //Something goes wrong here when login without any boxes filled if($users[$_POST['username']] == $_POST['password']) { $_SESSION['username'] = $_POST['username']; }else { echo "Something went wrong, Please try again"; $redirect = "Location: 777.php"; } } ?> <?php if($_SESSION['username']): ?> <p><h2>Welcome <?=$_SESSION['username']?></h2></p> <p align="right"><a href="777.php">Logga ut</a></p><?php endif; ?> <p>Today Ben&Jerrys Chunky Monkey is my favorite!</p> <?php //Footer include('C:/wamp/www/PHP/includes/footer.html'); ?>
  13. Hi there to everyone I have a bit of an issue, I am still new to all this coding, I need help on to display my images in my uploads folder with some sort of image lightbox viewer: <?php require 'database.php'; $propertyid = null; if ( !empty($_GET['PropertyId'])) { $propertyid = $_REQUEST['PropertyId']; } if ( null==$propertyid ) { header("Location: sale.php"); } else { $pdo = Database::connect(); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = "SELECT * FROM properties where PropertyId = ?"; $q = $pdo->prepare($sql); $q->execute(array($propertyid)); $dataproperty = $q->fetch(PDO::FETCH_ASSOC); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql1 = "SELECT * FROM images WHERE PropertyId = ?"; $q1 = $pdo->prepare($sql1); $q1->execute(array($propertyid)); } echo '<li class="col-md-12">'; while ($row = $q1->fetch(PDO::FETCH_ASSOC) ) { Below is my images that need to be displayed in a lightbox way: echo ' <a href="'.$row['ImageUrl'].'"><img width="200px" src="'.$row['ImageUrl'].'"></a>'; } echo '<br />'; echo '<br />'; echo '<div class="proj_descr1"><h1>'. $dataproperty['Title'] . '</h1>'.'<br />'; echo '<div class="proj_descr_txt">'.'<h4><b>Location: </b></h4>'. $dataproperty['Location'] . '</div>'; echo '<br />'; echo '<div class="proj_descr_txt">'.'<h4><b>Bedrooms: </b></h4>'. $dataproperty['Bedrooms'] . '</div>'; echo '<br />'; echo '<div class="proj_descr_txt">'.'<h4><b>Bathrooms: </b></h4>'. $dataproperty['Bathrooms'] . '</div>'; echo '<br />'; echo '<div class="proj_descr_txt">'.'<h4><b>Parking: </b></h4>'. $dataproperty['Parking'] . '</div>'; echo '<br />'; echo '<div class="proj_descr_txt">'.'<h4><b>Property Type: </b></h4>'. $dataproperty['Type'] . '</div>'; echo '<br />'; echo '<div class="proj_descr_txt">'.'<h4><b>Status: </b></h4>'. $dataproperty['Status'] . '</div>'; echo '<br />'; echo '<div class="proj_descr_txt">'.'<h4><b>Description: </b></h4>'. $dataproperty['Description'] . '</div>'; echo '<br />'; echo '<div class="proj_descr_txt">'.'<h4><b>From: </b></h4>'. $dataproperty['FromThe'] . '</div>'; echo '<br />'; echo '<div class="proj_descr_txt">'.'<h4><b>Contact Details: </b></h4>'. $dataproperty['ContactDetails'] . '</div>'; echo '<br />'; echo '<div class="proj_descr_txt">'.'<h4><b>Price: </b>R</h4>'. $dataproperty['Price'] . '</div>'; echo '<A HREF="#" onClick="history.back();return false;">Go back</A>'; echo '</li>'; any help would be much appreciated.
  14. I'm trying to convert a one dimensional array into a multidimensional array by grouping matching parts of the keys, i.e. array('onetwothreefour'=>'value', 'onetwothreesix'=>'value2') would become array('onetwothree'=>array('four'=>'value', 'six'=>'value2')); Essentially I'm trying to convert XML to YML and have a one dimensional array of the XML with index => value. I've been staring at it for a while now and have tried a few recursive functions to build it though I've come to a few dead ends and would appreciate any words of wisdom if someone can spot the answer easier than I
  15. Hello every body I want to track unique visitors of a website but failed to do.. first I thought of tracking their ip but ip changes very frequently. second I thought of tracking their mac address and date from which I can track unique visits but in some server tracking mac address is returning thier servers mac address instead of returning the visitors. so is their any way I can acheive it. I can easily do it with cookies but cookies can be altered by their owner so making this option as in blacklist. so is there any other way to do it... thanks in advance...
  16. Good Day I have a bit of an issue with my website I loaded on my domain. I am getting an error: SQLSTATE[HY000] [1130] Host 'xxx.xxx.xx.xxx' is not allowed to connect to this MySQL server Can some one please explain to me in detail how do fix this? It only shows on my Sale and Rent pages
  17. Hello! I have a php page which shows a list of customers displayed in an html table format, The first column in the table contains a link for the user to select the row which then navigates to another php page, which is the customer order page. On this page, I want to get certain information based on the name of the customer to prepopulate the customer fields on this form, so I have some php code near the top of the page, as per attached document. I have checked to ensure that the $_GET['business_name'] contains a value. The query runs fine in myssql and returns only one record when I provide a value for the business_name, however when I run the code in php, the $result variable shows 'Resource id ='7' type='mySQL result'. I am a total newbie on PHP/MySQL and inherited this application. I have tried to find solutions on line through various forums, but no luck. Perhaps I am not asking/looking for the right question. Anyway, any assistance would be greatly appreciated. customer_order_php.php
  18. Over the past few days I have been running into some issues with my server crashing due to apache max connections issues. I am running my site off of a hosted Cloud VPS with 200GB of storage, 8192MB Memory, 8TB of transfer, Apache, MySQL, PHP5, and CentOS. I am afraid the issue doesn't necessarily lay in the configuration of Apache, but the way I have scripted the php on my site, the reason I am reaching out here. My site isn't your average website, it is more of a web-based customer management program. There are currently only 2 pages you can actually access via the url bar (signin.php and index.php). All other content is loaded via AJAX and JQuery processes (.load and $.getScript). All AJAX requests are pointed toward a single file called functions.php where a _POST parameter contains the function name and any additional _POST data required by the function. FOR EXAMPLE: AJAX Call: $.post('functions/functions.php',{func:'myFunctionName',ops:'whatever',a:'whatever',b:'whatever'},function(data){ DO WHATEVER I WANT WITH THE RETURN DATA HERE },"json"); PHP (functions.php) require 'dbcon.php'; include 'main_class.php'; include 'f_customerdetail.php'; include 'f_listoptions.php'; include 'f_route.php'; include 'f_useractions.php'; if (isset($_POST['func'])){ $userfunc = $_POST['func']; $funcops = $_POST['ops']; if ($funcops != ''){ $userfunc($funcops); }else{ $userfunc(); } } The functions.php file includes all of my other php files containing all of the functions. Each of the other files (f_customerdata.php, f_route.php, f_payroll.php, etc.) contains a number of functions which handle that specific genre of the site; this was more of an organization method I used to keep track of things. Now that you have a little background, I want to know if that is a toxic way to do things? If I currently have 100 people using the site and anytime they navigate it requests data from the functions.php file then that means there are going to be a ton of requests pointing to that single file, thus causing apache to crash; correct? There are multiple functions which use cURL to scrape data from another website as well. Therefore, a connection to the functions.php file may last in upwards of 5 minutes depending upon the function. A large issue as that all of the content on the site is completely dynamic; it is completely driven by getting data from the database and displaying it. Am I going about this correctly by having a single file handling all of the functions? Or, do I need to re-approach it by pointing the AJAX requests directly to the file containing the functions for that particular situation? I know this is a large question. I am completely self-taught, 4 years experience, and have developed a massive project over the last 6 months. I just want to be sure I am going about this the correct way. Thank you for your input, Josh
  19. I got my search page error and the server pop up below message: Notice: Undefined variable: query in /home/tz005/public_html/COMP1687/search.php on line 64 Minimum length is 3 Where should I make a correction in the script? Here is my php script: <?php $min_length = 3; //min length of the search if(strlen($query) >= $min_length){ $query = htmlspecialchars($query); $raw_results = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT * FROM item_information WHERE (`itemtitle` LIKE '%".$query."%')") or die(((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false))); if(mysqli_num_rows($raw_results) > 0){ // If it find's more than 0 results... while($results = mysqli_fetch_array($raw_results)){ echo "<p>".$results['itemtitle']."</p>"; // show's the results.. } } else{ // If found nothing.. echo "No results"; } } else{ // if length of the search is less than defined on variable... echo "Minimum length is ".$min_length; } ?>
  20. i want to make a webpage search want to make a script which search the existing webpage & echo them if response is 200 or 403
  21. Hi, I got 1 warning form the server, It said: Warning: extract() expects parameter 1 to be array, null given in /home/tz005/public_html/COMP1687/edit.php on line 113 extract($row); how to fix the warning,should I replace it with extract($array);?
  22. Why does php show undefined variable? I researched and found out that if the variables aren't set then they will likely show undefined variable. However, I used the isset function to check if the variable is undefined and if it is then set it to $varaible ="" . That didn't work and then later i tried $variable = NULL. What should I do Can you please see the code and tell me what shall i do. Thanks a million <?php require_once("includes/connection.php")?> <?php require_once("includes/function.php") ?> <?php require_once("includes/header.php") ?> <?php if(isset($_GET['subj'])){ $sel_subj = NULL; $sel_subj = $_GET['subj']; } elseif (isset($_GET['page'])){ $sel_page = NULL; $sel_page = $_GET['page'] ; } else { $sel_subj= NULL; $sel_page =NULL; } ?> <table id = "structure" > <tr> <td id = "navigation" > <ul class= "subjects" > <?php $subject_set = get_all_subjects(); while ($subject = mysql_fetch_array($subject_set)){ // <a href = "content.php?subj=1" > if ($sel_subj == $subject["id"]){ echo "<li class = \"selected\" "; }else{ echo "<li> "; } "<a href = \"content.php?subj=" . urlencode($subject["id"]) . "\">" . $subject["menu_name"]. "</a></li>" ; $page_set = get_pages_for_subjects( $subject["id"] ) ; echo " <ul class = \"pages\"> "; while ($page = mysql_fetch_array($page_set)){ echo "<li><a href = \"content.php?page=" . urlencode($page["id"]) . "\">" . $page["menu_name"] . "</a></li>" ; } echo "</ul>" ; } ?> </ul> </td> <td id= "page" > <h1> Main Area To Get Your Information </h1> <?php echo $sel_subj ; ?> <br/> <?php echo $sel_page ; ?> <br/> </td> </tr> </table> <?php include ("includes/footer.php") ?> The variable im refering to is $sel_subj and $sel_page at the top of the code. Here is an attachment of the error
  23. Good Day Guys I have a bit of a urgent problem. Here is my Query: $query = "SELECT distinct Img.propertyId as PropertyId, Title, ImageUrl, Location, Bedrooms, Bathrooms, Parking, Price FROM PROPERTIES as Prop LEFT JOIN IMAGES as Img ON Img.PropertyId = Prop.PropertyId WHERE 1=1 AND Price >=1000 AND Price <=5000 "; I have a problem and the problem is here - AND Price >=1000 AND Price <=5000. This works fine but the problem comes as soon as I add more: For example: if I add OR Price >5000 AND Price <=10000 then it displays all my results from 1000 to 10000 and I want it to be if I select 5000 - 10000 it needs to display only the results between 5000 and 10000. Can someone please help me?
  24. I cannot redirect to other page even I enter correct information and recaptcha in activation form. Anyone who can check what going wrong in my activation script? Here is my php activation check script: <?php require_once('recaptchalib.php'); $privatekey = "6LfTwvMSAAAAABt03yGb0_12rgLNrCDuoibU4gbh"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")"); } else { $username = $_POST['username']; $activation_code = $_POST['activation_code']; $db_host = "server"; $db_name = "table"; $db_use = "use"; $db_pass = "pass"; $link = mysqli_connect($db_host, $db_use, $db_pass); mysqli_select_db($link, $db_name); $command = "UPDATE email_activation SET check_activation='$activation_code' WHERE username='$username' and activation='$activation_code'"; $result = mysqli_query($command); if ($result) { $query = "SELECT * FROM email_activation where username LIKE '%$username%' LIMIT 0 , 1 "; $result = mysqli_query($query) OR die(mysqli_error()); while($row = mysqli_fetch_array($result)) { $username = $row['username']; $password = $row['password']; $email = $row['email']; $postcode = $row['postcode']; $query = "INSERT INTO member (username, password, email, postcode) VALUES ('$username','$password','$email','$postcode')"; $result = mysqli_query($link, $query) OR die(mysqli_error()); if ($result) { $_SESSION['user_logged'] = '1'; header("location:index.html"); echo "Congratulations. Your membership has been activated redirecting..."; }else{ header("location:index.html"); echo ("Congratulations. Your membership has been activated but it's can't saved in database."); } } }else{ header("location:activation-form.php"); echo ("You've entered an invalid username / activation code – please retry"); } } ?>
  25. i want do do something like this i am using filegetcontent & it give me something like <tag1><tag2>abc</tag2><tag3>....[some junk]</tag5></tag1> & in another case it give me <tag1><tag2>123</tag2><tag3>....[some junk]</tag5></tag1> so i want to do something like this if with filegetcontent i get abc { do this } if with filegetcontent i get 123 {do that} else {die();} how to do that ??? plz help me
×
×
  • 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.