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. I have created 5 websites under 5 different domains. Contents of this websites' are similar and using a same template for each one. Now I need to create an admin panel to control these websites. PHP and MySql I will use for this backend. My problem is how can I manage these five website with one backend? Reason is I will use different domain for my backend. My all 5 client will use this same backend system to manage their own website. So can I know from the professionals here, is it possible to display mysql data on these 5 website. If it is possible then how? Any links to article or tutorials would be welcome and appreciated. NOTE: I checked mysql federated storage engine but no idea? Is it the way where do I need to go? Thank you.
  2. Evening everyone and Merry X-Mas (Happy Holidays) or whatever fits you best.... I have been trying over and over for about 12 hours to figure out how to get data from a specific JSON response and assign the specific values to a new array key/value pair. The various ways I have tried to figure this out are numerous so i'm going to avoid the runnig list of "I trieid this...and this...and this... etc etc." just understand I have reached a dead end point where I need help badly. Here is what our end goal is: "The company" is a "service industry" provider (plumbing, electrical etc. etc.) who wants to dispatch its technicians to new jobs based on which technician has the shortest travel time from any existing address where they already have a scheduled appointment that day and has available time in there schedule. Thus the dispatching system when a new service call is entered is going to give "recommended" technicians (up to 4) to be assigned the new service call based on the above mentioned criteria. (Efficient routing to save company gas cost) 1.) We have a "New service" street address assigned to the $to variable: $to = "4813 River Basin Dr S, Jacksonville FL 32207"; 2.) We will have "records" array which containes a series of records, each record consists of a ticket# a technician id# and a street address: $records = array( array("DV1012","30453423","9890 Hutchinson Park Dr Jacksonville, FL 32225"), array("DB3434","30404041","821 Orange Ave Crescent City, FL 32112"), array("DB3434","30605060","1972 Wells Road, Orange Park FL 32073"), array("DB4578","30605060","2 Independent Drive, Jacksonville FL 32202"), array("DB7841","30605060","5000 Norwood Avenue, Jacksonville FL 32208"), array("DB3235","30605060","9501 Arlington Expressway, Jacksonville FL 32225"), array("DB7894","30605060","Massey Avenue, Jacksonville, FL 32227"), array("DB2020","30121212","11200 Central Pkwy Jacksonville, FL 32224") ); 3.) We are going to prepare the records array for submission to Google's Distance Matrix API by URL encoding each array value into a single variable and then submit it: foreach ($records as $key => $value) {$from = $from.urlencode($value[2])."|";} $to = urlencode($to); $data = file_get_contents("//maps.googleapis.com/maps/api/distancematrix/json?origins=$from&destinations=$to&language=en-EN&units=imperial&mode=driving&sensor=false"); $res=json_decode($data) or die("Error: Cannot read object"); You may look at the ACTUAL live Google response from this here: http://tiny.cc/i6eerx (We have applied <pre> and var_dump($res) to the output) We are looking to get the following information back: The distance and travel time between the "New Service" address ($to) and each of the address' in the $records array ($from), now once that information is returned from Google (JSON response) we need to parse the response and narrow it down to 4 or less (Based on the 4 lowest drive times) to form a new array which ends like this: $results = array( array("DV1012","30453423","2.3 Miles","8 mins"), array("DB3434","30404041","2.8 Miles","9 mins"), array("DB3434","30605060","4.6 Miles","13.8 mins"), array("DB4578","30605060","5.7 Miles","15.2 min") ); OUR PROBLEM: Everything up until the the Google API response is fine, but iterating over the multidimensional arrays within multidimensional arrays of the JSON response is just not coming together in my head (or 2 dozen code attempts). I am able to ECHO an individual value like ( echo $res->rows[0]->elements[0]->distance->text; ) but this has no value for the end result i need to get to. My last thoughts and efforts was that that I was going to have to embed foreach statements within foreach statements to drill down through the various arrays but that hasn't worked very well and it seems like it shouldn't be how it has to be done. I would appreciate any help in showing me how the iteration code should be written and any explanation about the code so i can wrap my head around it.
  3. i have a code in c# and here use GetBytes(msg) for SSlStream.write, here send and received data correctly, here all work fine, now i want to make the same event in php, but here i cant see a SslSteam or similar(i think no problem, becouse i working with socket_connection, and i think SSL is only for security), now for compare i stop the code in c# for see what data is sending and try to convert in php, for send here, i can see a data byte{} in c# and with ` $message=unpack('C*',$message);` i can convert the string to byte[], comparing with c# value is the same so, here all is ok, my problem is when i try to write the request, becouse in SslStream.write accpet byte[] but socket_write no accept whe i try send ` socket_write($socket, '\n', strlen($message))` i have a error : socket_write() expects parameter 2 to be string and obvius is becouse socket_write() only accept string, but so.. as i can send my byte[], becouse the server only accept a byte[] please help me PD> my problem is how i can send the byte[], i dont know if can send eq socket_write($socket, $message[1], strlen($message)), or what is which is the right way, note please $message first is a string as the server only accept byte i use unpack for create a $message[] as byte/integer eq with 70 items, etc, here is ok, becouse comparing with my program in c# give the same value(same array), but now i need send this $message[], but i cant becouse $message now is a byte or integer[], and socket_write only aceppt string, please help me
  4. Hi all. In my database, i have a column recurring which is derived from a multiple option form field with values: Weekly, Bi-Monthly, Monthly, Quarterly, Half Yearly and Yearly. I want to have as next due the current date plus the recurring value. eg current date = 2014-11-24 recurring = monthly next due = current date + recurring (in the next due will be 2014-12-24) so i did: $stmt = $pdo->query("SELECT recurring, due_date FROM $table"); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $recur = $row['recurring']; $date_due = $row['due_date']; } $weekly = "Weekly"; $bi_monthly = "Bi-Monthly"; $monthly = "Monthly"; $quarterly = "Quarterly"; $half_yearly = "Half Yearly"; $yearly = "Yearly"; if(strcmp($recur, $weekly) == 0){ $recurs = "7 DAY"; }elseif(strcmp($recur, $bi_monthly) == 0){ $recurs = "14 DAY"; }elseif(strcmp($recur, $monthly) == 0){ $recurs = "1 MONTH"; }elseif(strcmp($recur, $quarterly) == 0){ $recurs = "3 MONTH"; }elseif(strcmp($recur, $half_yearly) == 0){ $recurs = "6 MONTH"; }elseif(strcmp($recur, $yearly) == 0){ $recurs = "1 YEAR"; } $stmt = $pdo->query("SELECT ADDDATE('$date_due', INTERVAL $recurs) as nex_due FROM $table"); $row = $stmt->fetch(PDO::FETCH_ASSOC); $nex_due = $row['nex_due']; $stmt = $pdo->prepare("SELECT * FROM $table ORDER BY trans_id DESC"); $stmt->execute(); $num_rows = $stmt->rowCount(); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['trans_ref']; echo "</td><td>"; echo $row['acct_num']; echo "</td><td>"; echo ucwords($row['payee']); echo "</td><td>"; echo ucwords($row['company']); echo "</td><td>"; echo $row['acct_no']; echo "</td><td>"; echo number_format($row['amt'],2); echo "</td><td>"; echo $row['purpose']; echo "</td><td>"; echo $row['recurring']; echo "</td><td>"; echo $row['due_date']; echo "</td><td>"; echo $nex_due; echo "</td><td>"; echo "<strong>".$row['status']."</strong>"; echo "</td><td>"; echo "<strong>".$row['pay_status']."</strong>"; echo "</td><td>"; } The problem is that it's giving me as next due the value of the first row even when the recurring is different!
  5. Hey guys so my code below is not working, it will get the app information for the user but its only display 3 results like every time a new user "installs" an new app like it stops showing the last result and starts displaying the new result. Like for example right now it should be showing 7 results but only displaying 3 is there something wrong with my query. (PS: this is just developement testing purposes so thats why my code is sorta sloppy) Thanks! $default_apps = mysql_query("SELECT * FROM apps WHERE `default`='1'") or die(mysql_error()); $user_apps = mysql_query("SELECT * FROM user_apps WHERE `user_id`='$user_id'") or die(mysql_error()); while($row = mysql_fetch_array($default_apps)) { $url = $row['download_url']; $name = $row['name']; echo $row['name']; echo "<a href='$url'>$name</a><br />"; } while($raw = mysql_fetch_array($user_apps)){ $app_id = $raw['app_id']; } $select_user_apps = mysql_query("SELECT * FROM apps WHERE `app_id`='$app_id' "); while($rop = mysql_fetch_array($select_user_apps)) { $name = $rop['name']; $url = $rop['download_url']; echo $name; echo $url; }
  6. Hey guys so I am making an App website and somehow need to make a developer section. So like developers can come and setup their app name,description etc. Then be able to program there own app and use like an API service to get the user username etc. So what would I need to let developers do a such thing like let them make an API key and all that is there some tutorial to make such service. (This will be an important feature to my website so please help, thanks)
  7. Hey guys so I am making an online App website. So I need to it to be so some apps will be added by default. Then users can search for apps and "install" apps but really just have them show up on the homepage. So how would the database design work like have a field that is updated to 1 if the user has it installed and 0 if its not. And then do like an if statement to pull all the fields with 1 where username='$username'. And when it pulls it should I add like a URL field to it to so when it pulls the app information there will be a link to the app url. Could somebody please help me with what I should do because I am really confused on what design and if statements I should use
  8. Hello everyone. I have a fully working form that gets data from a user (with $_post array) , and stores it in a database (mysql). After successfulIy filling the form, I refer him to the "dashboard" page. In this page, i am having trouble to get his details from the database. How should I recognize him as the user that just registered? should I use a $_post? or maybe a session? could you please give me a clue how to solve this?
  9. For eg. I have a page with a query that retrives records from the database and I want to have options of filtering out the shown records by date, time, likes, views..etc; how would I go about doing that? The way I am thinking is having a html form with those filter inputs and using a relative query based on the filter selection to retrive the results. What you think?
  10. I have these two tables... schedule (gameid, homeid, awayid, weekno, seasonno) teams (teamid, location, nickname) This mysql query below gets me schedule info for ALL 32 teams in an array... $sql = "SELECT h.nickname AS home, a.nickname AS away, h.teamid AS homeid, a.teamid AS awayid, s.weekno FROM schedule s INNER JOIN teams h ON s.homeid = h.teamid LEFT JOIN teams a ON s.awayid = a.teamid WHERE s.seasonno =2014"; $schedule= mysqli_query($connection, $sql); if (!$schedule) { die("Database query failed: " . mysqli_error($connection)); } else { // Placeholder for data $data = array(); while($row = mysqli_fetch_assoc($schedule)) { if ($row['away'] == "") {$row['away']="BYE";} $data[$row['homeid']][$row['weekno']] = $row['away']; $data[$row['awayid']][$row['weekno']] = '@ '.$row['home']; } } However, I only want to get info for one specific team, which is stored in the $teamid variable. This should be very easy, right? I have tried multiple things, including this one below (where I added an AND statement of "AND (h.teamid=$teamid OR a.teamid=$teamid)"), but this one still outputs too much... $sql = "SELECT h.nickname AS home, a.nickname AS away, h.teamid AS homeid, a.teamid AS awayid, s.weekno FROM schedule s INNER JOIN teams h ON s.homeid = h.teamid LEFT JOIN teams a ON s.awayid = a.teamid WHERE s.seasonno =2014 AND (h.teamid=$teamid OR a.teamid=$teamid)"; $schedule= mysqli_query($connection, $sql); if (!$schedule) { die("Database query failed: " . mysqli_error($connection)); } else { // Placeholder for data $data = array(); while($row = mysqli_fetch_assoc($schedule)) { if ($row['away'] == "") {$row['away']="BYE";} $data[$row['homeid']][$row['weekno']] = $row['away']; $data[$row['awayid']][$row['weekno']] = '@ '.$row['home']; } } Below is the array that the above outputs. In a nutshell, all I want is that 1st array ([1]) which has, in this example, the Eagles full schedule. It's not giving me too much else and I guess I could live with it and just ignore the other stuff, but I'd rather be as efficient as possible and only get what I need... Array ( [1] => Array ( [1] => Jaguars [2] => @ Colts [3] => Redskins [4] => @ 49ers [5] => Rams [6] => Giants [7] => BYE [8] => @ Cardinals [9] => @ Texans [10] => Panthers [11] => @ Packers [12] => Titans [13] => @ Cowboys [14] => Seahawks [15] => Cowboys [16] => @ Redskins [17] => @ Giants ) [27] => Array ( [1] => @ Eagles ) [28] => Array ( [2] => Eagles ) [4] => Array ( [3] => @ Eagles [16] => Eagles ) [14] => Array ( [4] => Eagles ) [15] => Array ( [5] => @ Eagles ) [3] => Array ( [6] => @ Eagles [17] => Eagles ) [] => Array ( [7] => @ Eagles ) [16] => Array ( [8] => Eagles ) [25] => Array ( [9] => Eagles ) [11] => Array ( [10] => @ Eagles ) [7] => Array ( [11] => Eagles ) [26] => Array ( [12] => @ Eagles ) [2] => Array ( [13] => Eagles [15] => @ Eagles ) [13] => Array ( [14] => @ Eagles ) )
  11. Say I have a table called artists with these fields (artistid, rank). Then say I have an array called $rankadjustments with a value for each artist (like 1, 7, 3,-3, 5, 9, etc). I am doing a MYSQL query that gets the info from artists table and sorts according to the rank field like this... $sql = "SELECT * FROM artists ORDER BY rank"; Easy enough. But what if I would like to bring that data back sorted by (rank + rankadjustment). For example, if the artist ranked 1st had a rank of "1" from mysql, but had a rankadjustment of "5" from the rankadjustment array, his "true" rank would be "6". Again, rankadjustment is NOT a field in my table, otherwise it would obviously be simple. It's calculated on the fly and stored in an array. FYI, the array has an index with their "artistid". For example, $rankadjustment[341][8] would be the artist with an artistid of "341" has a rank adjustment of 8. Is there a way to do this IN the query itself? It doesn't seem possible but wanted to find out for sure. If not, what is best way to do? I assume... Get the data sorted JUST by rank and put it all into an array, then create a new array that adds rank to rankadjustment and reorder by the "new" rank amount? I guess that wouldn't be too bad but again, wanted to make sure I'm not missing something that would allow me to do it all in the query (or just more efficiently). Thanks!
  12. I am using xampp. <a href="/">Home Page</a> The above code (when clicked in browser) takes me to the localhost instead of localhost/website How can i clear this issue?
  13. hello dear folks good evening dear PHP-Freaks, well i am not sure if this question fits here - in miscellaneous. but i am pretty sure that many many calc and excel-experts are here in this great forum. what is aimed: want to create a calendar - with 365-chunks that are imported into a caleandar form see some ideas where i can import this i posted the example-calc spreassheet that i want to import. note it has got 365 lines - for 365 days of the next year 2015 what needs to be done ; whats needs to be achieved: i need to impoort the example into the calendar form. see some of the examples -.. if i am able to import the texts (of the collumn ) in a writer or word document each line of the calc needs to get on a sheed of the word or writer. i need to know how to arrange this export of calc into the writer document. if i need to explain it more thoroughiy - just let me know! greetings you matze see some examples of calendar templates Blank daily calendar - Templates Daily lesson planner (color, landscape) - Templates note: all i need to know is to be able to export from calc to any word or calc document... see the attached sample below... 2015_sample_version_.ods.zip
  14. I'm a beginner here and i am learning the basic in converting from MySQL to MySQLi. I am currently working on this registration page which I would want to convert to MySQLi. Please advise me how to modify this script, I would prefer the procedural style. The MySQLi coding is not working because it would notg insert into the database like the MySQL coding would, would appreciate if your can help me. MYSQL <?php error_reporting(1); $submit = $_POST['submit']; //form data $name = mysql_real_escape_string($_POST['name']); $name2 = mysql_real_escape_string($_POST['name2']); $email = mysql_real_escape_string($_POST['email']); $password = mysql_real_escape_string($_POST['password']); $password2 = mysql_real_escape_string($_POST['password2']); $email2 = mysql_real_escape_string($_POST['email2']); $address = mysql_real_escape_string($_POST['address']); $address2 = mysql_real_escape_string($_POST['address2']); $address3 = mysql_real_escape_string($_POST['address3']); $address4 = mysql_real_escape_string($_POST['address4']); $error = array(); if ($submit) { //open database $connect = mysql_connect("localhost", "root", "Passw0rd") or die("Connection Error"); //select database mysql_select_db("logindb") or die("Selection Error"); //namecheck $namecheck = mysql_query("SELECT * FROM users WHERE email='{$email}'"); $count = mysql_num_rows($namecheck); if($count==0) { } else { if($count==1) { $error[] = "<p><b>User ID taken. Try another?</b></p>"; } } //check for existance if($name&&$name2&&$email&&$password&&$password2&&$email2&&$address&&$address2&&$address3&&$address4) { if(strlen($password)< { $error[] = "<p><b>Password must be least 8 characters</b></p>"; } if(!preg_match("#[A-Z]+#",$password)) { $error[] = "<p><b>Password must have at least 1 upper case characters</b></p>"; } if(!preg_match("#[0-9]+#",$password)) { $error[] = "<p><b>Password must have at least 1 number</b></p>"; } if(!preg_match("#[\W]+#",$password)) { $error[] = "<p><b>Password must have at least 1 symbol</b></p>"; } //encrypt password $password = sha1($password); $password2 = sha1($password2); if($_POST['password'] != $_POST['password2']) { $error[] = "<p><b>Password does not match</b></p>"; } //rescue email match check if($_POST['email2'] == $_POST['email']) { $error[] = "<p><b>Rescue Email must not be the same as User ID</b></p>"; } //generate random code $random = rand(11111111,99999999); //check for error messages if(isset($error)&&!empty($error)) { implode($error); } else { //Registering to database $queryreg = mysql_query("INSERT INTO users VALUES ('','$name','$name2','$email','$password','$password2','$email2','$address','$address2','$address3','$address4','$random','0')"); $lastid = mysql_insert_id(); echo "<meta http-equiv='refresh' content='0; url=Activate.php?id=$lastid&code=$random'>"; die (); } } } ?> MYSQLi (NOT WORKING AFTER CONVERTING) <?php error_reporting(1); $submit = $_POST['submit']; //form data $name = mysqli_real_escape_string($connect, $_POST['name']); $name2 = mysqli_real_escape_string($connect, $_POST['name2']); $email = mysqli_real_escape_string($connect, $_POST['email']); $password = mysqli_real_escape_string($connect, $_POST['password']); $password2 = mysqli_real_escape_string($connect, $_POST['password2']); $email2 = mysqli_real_escape_string($connect, $_POST['email2']); $address = mysqli_real_escape_string($connect, $_POST['address']); $address2 = mysqli_real_escape_string($connect, $_POST['address2']); $address3 = mysqli_real_escape_string($connect, $_POST['address3']); $address4 = mysqli_real_escape_string($connect, $_POST['address4']); $error = array(); if ($submit) { //open database $connect = mysqli_connect("localhost", "root", "Passw0rd", "logindb") or die("Connection Error"); //namecheck $namecheck = mysqli_query($connect, "SELECT * FROM users WHERE email='{$email}'"); $count = mysqli_num_rows($namecheck); if($count==0) { } else { if($count==1) { $error[] = "<p><b>User ID taken. Try another?</b></p>"; } } //check for existance if($name&&$name2&&$email&&$password&&$password2&&$email2&&$address&&$address2&&$address3&&$address4) { if(strlen($password)< { $error[] = "<p><b>Password must be least 8 characters</b></p>"; } if(!preg_match("#[A-Z]+#",$password)) { $error[] = "<p><b>Password must have at least 1 upper case characters</b></p>"; } if(!preg_match("#[0-9]+#",$password)) { $error[] = "<p><b>Password must have at least 1 number</b></p>"; } if(!preg_match("#[\W]+#",$password)) { $error[] = "<p><b>Password must have at least 1 symbol</b></p>"; } //encrypt password $password = sha1($password); $password2 = sha1($password2); if($_POST['password'] != $_POST['password2']) { $error[] = "<p><b>Password does not match</b></p>"; } //rescue email match check if($_POST['email2'] == $_POST['email']) { $error[] = "<p><b>Rescue Email must not be the same as User ID</b></p>"; } //generate random code $random = rand(11111111,99999999); //check for error messages if(isset($error)&&!empty($error)) { implode($error); } else { //Registering to database $queryreg = mysqli_query($connect, "INSERT INTO users VALUES ('','$name','$name2','$email','$password','$password2','$email2','$address','$address2','$address3','$address4','$random','0')"); $lastid = mysqli_insert_id(); echo "<meta http-equiv='refresh' content='0; url=Activate.php?id=$lastid&code=$random'>"; die (); } } } ?>
  15. Hello every1, I'm trying to create a magazine wesite and I dont want anybody to access my images folder which is located in the root directory. I want some thing like this... I want to call the images in my website using <img> tag but I dont want any1 to access the directory directly. It should also protect from software bots also like (HTTrack or website Copier) It should show "Access forbidden". Any help will be greatly appreciated. Thank you...
  16. Below is my code that is suppose to insert and show records from database using ajax. Retrieving the records from the database works. However it won't insert a record. I do not get any errors. The page simply refreshes when I hit submit button. Can you see what might be wrong in my code? index.php <script> $(document).ready(function(){ function showComment(){ $.ajax({ type:"post", url:"process.php", data:"action=showcomment", success:function(data){ $(".wrapper").html(data); } }); } showComment(); $("#submit").click(function(){ var name=$("#name").val(); var message=$("#details").val(); $.ajax({ type:"post", url:"process.php", data:"name="+name+"&details="+message+"&action=addcomment", success:function(data){ showComment(); } }); }); }); </script> $id = $_GET['id']; $title = $_GET['title']; $_SESSION['id'] = $id; $_SESSION['title'] = $title; <div class="wrapper"></div> <form action="" method="post" enctype="multipart/form-data"> <div class="newfield"> <label for="title">Name <span class="highlight">*</span></label> <input id="name" type="text" name="name"> </div> <div class="newfield"> <label for="details">Details <span class="highlight">*</span></label> <textarea id="details" name="details""></textarea> </div> <input type="submit" name="submit" id="submit" value="Submit Tale"> </form> process.php <?php require_once '/core/init.php'; $id = $_SESSION['id']; $action = $_POST['action']; if($action == 'showcomment') { try { $get = $db->prepare("SELECT * FROM sub_posts WHERE id = :id"); $get->bindParam('id', $id); $get->execute(); $getStmt = $get->fetchAll(PDO::FETCH_ASSOC); if(count($getStmt) > 0) { foreach($getStmt as $row) { $new_name = $row['name']; $new_details = $row['details']; ?> <ul> <li> <?php echo $new_name; ?> </li> <li> <?php echo $new_details; ?> </li> </ul> <?php } } else { // no records found. } } catch(Exception $e) { die($e->getMessage()); } } else if($action == 'addcomment') { $name = $_GET['name']; $details = $_GET['details']; try { $insert = $db->prepare("INSERT INTO sub_posts(id, name, details) VALUES(:id, :name, :details)"); $insert->bindParam('id', $id); $insert->bindParam('name', $name); $insert->bindParam('details', $details); $insert->execute(); if($insert == false){ echo 'record could not be inserted.'; } else { echo 'record has been inserted.'; } } catch(Exception $e) { die($e->getMessage()); } } else { echo 'no results.'; }
  17. hello dear linux-community if a server needs to meed some requirements - eg for installation wordpress and if the server needs to run eg see here: https://wordpress.org/about/requirements/ then i need to have a closer look at the apache2handler in the php-ini Apache Version Apache all the mentioned are listed in the php-info.file note: here are no mod_rewrite Apache module so what
  18. I have this code I have been trying ot use but it doesnt sent an email to my account when someone enters there email address into it and hots the submit button this is the php side of it <?php if ( isset( $_POST['newsletter_submit'] ) ) { // Initialize error array $newsletter_errors = array(); // Check email input field if ( trim( $_POST['newsletter_email'] ) === '' ) $newsletter_errors[] = 'Email address is required'; elseif ( !preg_match( "/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,4}$/i", trim( $_POST['newsletter_email'] ) ) ) $newsletter_errors[] = 'Email address is not valid'; else $newsletter_email = trim( $_POST['newsletter_email'] ); // Send email if no input errors if ( empty( $newsletter_errors ) ) { $email_to = "news@upperhuntercomputers.com"; // Change to your own email address $subject = "Newsletter Subscription"; $body = "Subscriber details: " . $newsletter_email . "\r\n"; $headers = "Newsletter Subscription <" . $email_to . ">\r\nReply-To: " . $newsletter_email . "\r\n"; mail( $email_to, $subject, $body, $headers ); echo 'Thank you for subscribing!'; } else { echo 'Please go back and correct the following errors:<br />'; foreach ( $newsletter_errors as $error ) { echo $error . '<br />'; } } } ?> and this is the html side of it <!-- Newsletter form --> <div class="newsletter"> <form action="subscribe.php" method="post" id="newsletter-form"> <p class="form-field"> <label for="newsletter_email" class="visually-hidden">Your email address</label> <i class="icon ion-paper-airplane" aria-hidden="true"></i> <input type="text" name="newsletter_email" id="newsletter_email" value="" placeholder="Your email address" /> </p> <p class="form-submit"> <input type="submit" name="newsletter_submit" id="newsletter_submit" value="Get Notified" /> </p> </form> </div> </div> cant figure out why its not working properly
  19. <?php if(isset($_POST['submit'])){ //collect form data $location = $_POST['location']; $ID = $_POST['ID']; $section = $_POST['section']; //check name is set if($location ==''){ $error[] = 'Name is required'; } //if no errors carry on if(!isset($error)){ # Title of the CSV $Content = "location, ID, section\n"; //set the data of the CSV $Content .= "$location, $ID, $section\n"; # set the file name and create CSV file $my_file = ("$location$ID$section.cvs"); $handle = fopen("$my_file", "w") or die('Cannot open file: '.$my_file); header('Content-Type: application/csv'); header('Content-Disposition: attachment; filename="' . $FileName . '"'); echo $Content; exit(); } } //if their are errors display them if(isset($error)){ foreach($error as $error){ echo "<p style='color:#ff0000'>$error</p>"; } } ?> <form action='' method='post'> <p><label>Location:</label><br><input type='text' name='location' value=''></p> <p><label>ID:</label><br><input type='text' name='ID' value=''></p> <p><label>Section:</label><br><input type='text' name='section' value=''></p> <p><input type='submit' name='submit' value='Submit'></p> </form> I have wrote a .php file which is a form with 3 different fields, in these fields I want to write entries which lateron will be submitted into a .csv generating a csv file on my server with the name of the entries. The issue is that the file is not being generated on my server. With the current code the entries are being recognized and being placed in the filename of the csv. The point is not to make it downloadable sinds I want to have it on my webserver and keep editing information in it. My code is top of this post. My .php file replies that: Cannot open file: BOD10Buffer.csv Pardon my sloppy code everyone, I am not really a person that codes but this "form" may save me a lot of time in the longrun, just difficult and I am asking for help on this. Is there anyone that may be kind enough to help me? and as to what I might be doing wrong? All help is much appreciated!
  20. hi everyone i keep seeing the following Comparison Operators: <> i see it used in the following context: if ($connection <> 'SSL') { $connection = 'NONSSL'; } be grateful if somone would tell me what it means, i looked online but could not find the symbol thanks
  21. Hello Guys. I am having a trouble viewing a specific column content both in phpMyAdmin and console.It only shows a partial info about the contents inside that column. I have attached a screenshot of this to give you a demonstration inside that link: http://i59.tinypic.com/2n6ymqf.jpg as you can see , the user picked hamburger ,steak and ground beef (and some more), but it seems that it stops showing it right in the middle of the word. Is there any limit for characters in this case? What would be possible to figure that out please? Thanks in advance..
  22. I'm having two issues: (1) The correct mysql query for multiple rows (2) The if/elseif/else to pull data from these rows, and process it based on the row data I'm only pulling data where A=1 and B=1,2 -- so two possible entries there (call them B1 and B2). I need a php if statement to choose whether the output of B is one of two urls (b1=google,b2=bing). The actual script is far more complex, with more than just 1,2 from B. I've stripped all the excesses down to this one if/else issue and the db query. The output php doesn't matter here. And I can add more elseif once this problem is solved. <?php mysql_connect(localhost, $db_username, $db_password); @mysql_select_db($db_database) or die("No connection"); $query = "Select * FROM table WHERE column='stuff' AND parent='1,2' ORDER BY id DESC LIMIT 10"; $query_result = mysql_query($query); $num_rows = mysql_num_rows($query_result); mysql_close(); ?> <?php for($i=0; $i< $num_rows; $i++){ //start a loop $stuff = mysql_result($query_result, $i, "column"); $row = mysql_fetch_assoc($query_result, $i); if($row['parent'] == 1) { $url = 'http://google.com'; } else { $url = 'http://www.bing.com'; } ?> My own first attempt at a if/then was 500. I got help on another site to redo it (new code shown here), but the new if/else always show the else (Bing). It was also at this time that I learned that "1,2" only showed 1. Hoping that this site is far more friendly than StackOverflow. .
  23. Is it possible to do this with one query? Tried with union and join but no luck. <?php $query = 'SELECT cashReward, pointsReward FROM pts WHERE signupsAvailable > 0 AND status = "active" AND id = :id'; $select = $db->prepare($query); $select->bindParam(':id', $id, PDO::PARAM_INT); $select->execute(); $rowCount = $select->rowCount(); $queryC = 'SELECT COUNT(id) FROM ignored_pts WHERE user = :username AND ptsId = :id'; $selectC = $db->prepare($queryC); $selectC->bindParam(':username', $userInfo['username'], PDO::PARAM_INT); $selectC->bindParam(':id', $id, PDO::PARAM_INT); $selectC->execute(); $count = $selectC->fetch(PDO::FETCH_COLUMN); if($rowCount == 1){// PTS // $row = $select->fetch(PDO::FETCH_ASSOC); if($count == 0){// IGNORED PTS // // ...................... // // INSERT INTO ignored_pts TABLE $row['cashReward'], $row['pointsReward']// // ...................... // print 'PTS IGNORED'; }else{ print 'You have already ignored this PTS!'; } }else{ print 'An invalid PTS was provided!'; } $db = NULL; ?>
  24. Before I get into my problem a couple of things. First, this is a work project. My organization cannot afford a full time developer so as a database guy I'm being asked to develop a web based data system using php/html/mysql/javacript/etc. So I am not asking anyone to help me cheat or violate an honor code for a school project. Also I am having to learn PHP on the fly, by the seat of my pants. Second, my organization is using a version of PHP older that 5.5.X and I am powerless to update the version. So I know that some of the syntax I am using has been deprecated in more recent PHP versions. I don't mean to sound snarky or ungrateful but I really need some help solving this problem versus unhelpful comments about deprecated code. Third I am adapting code from the guys at TechStream so H/T to them. Here is what I am trying to build. My office helps other offices in my large organization manage their records through the creation of a file plan. We are currently using a clunky, user-unfriendly Access database that was created back in 2009. I am tasked to transition that Access hoopty into a proper, web-based, user friendly system. The index.php form page consists of 2 parts. You can see the original TechStream demo here: http://demo.techstream.org/Dynamic-Form-Processing-with-PHP/ I've adapted the top part of the form ("Travel Information") for my users to enter information about their office such as Office Name, Office Code, Office Chief, Creator (the user), Status and date. I've adapted the bottom part of the form ("Passenger Details") to be "Folder Details". This is an html table where users can add up to 10000 rows to list all the folders for their office by entering the folder name in the text box and then assign descriptors to each folder using the drop down menus. I've changed the drop down menus to reflect the descriptors we need, i.e. file-series, classification, media type. The user needs the flexibility to add folders as the number of folders will vary between offices. This adding and deleting of folders is accomplished dynamically through a javascript script.js file. Now, here's my problem. When the user clicks submit button that fires a php script that runs an insert into query to place the array data into the backend mysql database. However, when the foreach loop is only inserting the office office from the top portion of the form with the first folder in the bottom portion of the form. In other words let's say the user fills out the top part with his office information and then adds 5 folders into the html table at the botton. The first folder will be inserted into the database table with both office information and folder information. However the subsequent 4 folders will have their folder information inserted into the table but the office information fields will be null. The office information needs to be inserted with each folder the user adds to the html table piece. I suspect that my foreach loop is only capturing that office information on the first iteration of the loop and then flushing or deleting the office information after the first loop. Also, I suspect there is some disconnect between the html table for entering individual folders and the top part of the form that is not in html format. Any help I can get is most welcome. Thanks in advance! Code is below. index.php <?php session_start(); if(!isset($_SESSION['myusername'])) { header('Location:index.php'); } echo $_SESSION['myusername']; echo '<a href="logout.php"><span>Logout</span></a></li>'; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Records Management File Plan Application</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link rel="stylesheet" type="text/css" href="css/default.css"/> <script type="text/javascript" src="js/script.js"></script> </head> <body> <form action="InsertFileDetailArraytoDB.php" class="register" method="POST"> <h1>Office File Plan Application/h1> <fieldset class="row1"> <legend>Office Information</legend> <p> <label>Office Code * </label> <input name="officecode[]" type="text" required="required"/> <label>Date* </label> <select class="date" name="day[]"> <option value="1">01 </option> <option value="2">02 </option> <option value="3">03 </option> <option value="4">04 </option> <option value="5">05 </option> <option value="6">06 </option> <option value="7">07 </option> <option value="8">08 </option> <option value="9">09 </option> <option value="10">10 </option> <option value="11">11 </option> <option value="12">12 </option> <option value="13">13 </option> <option value="14">14 </option> <option value="15">15 </option> <option value="16">16 </option> <option value="17">17 </option> <option value="18">18 </option> <option value="19">19 </option> <option value="20">20 </option> <option value="21">21 </option> <option value="22">22 </option> <option value="23">23 </option> <option value="24">24 </option> <option value="25">25 </option> <option value="26">26 </option> <option value="27">27 </option> <option value="28">28 </option> <option value="29">29 </option> <option value="30">30 </option> <option value="31">31 </option> </select> <select name="month[]"> <option value="1">January </option> <option value="2">February </option> <option value="3">March </option> <option value="4">April </option> <option value="5">May </option> <option value="6">June </option> <option value="7">July </option> <option value="8">August </option> <option value="9">September </option> <option value="10">October </option> <option value="11">November </option> <option value="12">December </option> </select> <select name="year[]"> <option value="2013">2013 </option> <option value="2014">2014 </option> <option value="2015">2015 </option> <option value="2016">2016 </option> </select> </p> <p> <label>Office Chief* </label> <input name="officechief[]" required="required" type="text"/> <label>Status* </label> <select name="status[]"> <option value="Draft">Draft </option> <option value="Submitted">Submitted </option> <option value="Approved">Approved </option> </select> </p> <p> <label>Creator * </label> <input name="creator[]" required="required" type="text"/> </p> <div class="clear"></div> </fieldset> <fieldset class="row2"> <legend>Folder Details</legend> <p> <input type="button" value="Add Folder" onClick="addRow('dataTable')" /> <input type="button" value="Remove Folder" onClick="deleteRow('dataTable')" /> <p>(All actions apply only to entries with check marked check boxes.)</p> </p> <table id="dataTable" class="form" border="1"> <tbody> <tr> <p> <td><input type="checkbox" required="required" name="chk[]" checked="checked" /></td> <td> <label>Folder Name</label> <input type="text" required="required" name="BX_NAME[]"> </td> <td> <label for="BX_fileseries">File Series</label> <select id="BX_fileseries required="required" name="BX_fileseries[]"> <option>100-01-Inspection and Survey/PII-NO</option> <option>200-02-Credit Card Purchases/PII-NO</option> <option>300-07-Time and Attendance/PII-YES</option> </td> <td> <label for="BX_classification">Classification</label> <select id="BX_classification" name="BX_classification" required="required"> <option>Unclassified</option> <option>Confidential</option> <option>Secret</option> <option>Top Secret</option> <option>Ridiculous Top Secret</option> <option>Ludicrous Top Secret</option> </select> </td> <td> <label for="BX_media">Media</label> <select id="BX_media" name="BX_media" required="required"> <option>Paper</option> <option>Shared Drive</option> <option>Film</option> <option>Floppy Disk</option> <option>Mixed</option> <option>Other</option> </select> </td> </p> </tr> </tbody> </table> <div class="clear"></div> </fieldset> <input class="submit" type="submit" value="File Plan Complete ยป" /> <div class="clear"></div> </form> </body> </html>PHP script with foreach loop to loop through the array from index.php and insert into database: InsertFileDetailArrayToDB.php /* When the user has finished entering their folders, reviewed the form inputs for accuracy and clicks the submit button, this will loop through all folder entries and using the SQL insert into query will place them in the database. When it completes data insertion it will redirect the user back to the file detail input form*/ <?php /*this part requires the user to be logged in and allows their user name to be included in the insert into query. If you remove the "ob_start();" piece it will screw up the header statement down at the botton. See the comments by the header statement for an explanation of its purpose*/ ob_start(); session_start(); if(!isset($_SESSION['myusername'])) { header('Location:index.php') } /*these two lines would ordinarily display the user name and a link a allowing the user to log out. However this php script does not output anything so the user will never it.*/ echo $_SESSION['myusername']; echo '<a href="logout.php"><span>Logout</span></a></li>'; ?> <?php /*this include statement connects this script to the MySQL database so the user form inputs can be inserted into the file_plan_details table*/ include ('database_connection.php'); foreach($_POST['BX_NAME'] as $row=>$BX_NAME) { $BX_NAME1 = mysql_real_escape_string($_POST['BX_NAME'); $officecode1 = mysql_real_escape_string($_POST['officecode'][$row]); $username1 = mysql_real_escape_string($_SESSION['myusername'][$row]); $day1 = mysql_real_escape_string($_POST['day'][$row]); $month1 = mysql_real_escape_string($_POST['month'][$row]); $year1 = mysql_real_escape_string($_POST['year'][$row]); $creator1 = mysql_real_escape_string($_POST['creator'][$row]); $officechief1 = mysql_real_escape_string($_POST['officechief'][$row]); $status1 = mysql_real_escape_string($_POST['status'][$row]); $BX_fileseries1 = mysql_real_escape_string($_POST['BX_fileseries'][$row]); $BX_classification1 = mysql_real_escape_string($_POST['BX_classification'][$row]); $BX_media1 = mysql_real_escape_string($_POST['BX_media'][$row]); $fileplandetailinsert1 = "INSERT INTO file_plan_details (folder_name, office_code, user_name, day, month, year, creator, office_chief, status, file_series, classification, media) VALUES ('$BX_NAME1','$officecode1','$username1','$day1','$month1','$year1','$creator1','$officechief1','$status1','$BX_fileseries1','$BX_classification1','$BX_media1')"; mysql_query($fileplandetailinsert1); } /*this header statement redirects the user back to the folder detail input form after it inserts data into the db After I build a main navigation page, I will switch out index.php with whatever I name the script that will produce the main navigation page*/ header('Location:index.php'); ?> script.js function addRow(tableID) { var table = document.getElementById(tableID); var rowCount = table.rows.length; if(rowCount < 10000){ // limit the user from creating fields more than your limits var row = table.insertRow(rowCount); var colCount = table.rows[0].cells.length; for(var i=0; i<colCount; i++) { var newcell = row.insertCell(i); newcell.innerHTML = table.rows[0].cells[i].innerHTML; } }else{ alert("Maximum Passenger per ticket is 5."); } } function deleteRow(tableID) { var table = document.getElementById(tableID); var rowCount = table.rows.length; for(var i=0; i<rowCount; i++) { var row = table.rows[i]; var chkbox = row.cells[0].childNodes[0]; if(null != chkbox && true == chkbox.checked) { if(rowCount <= 1) { // limit the user from removing all the fields alert("Cannot Remove all the Passenger."); break; } table.deleteRow(i); rowCount--; i--; } } }
  25. Hello, I am trying to run a report as per the below mssql query: $query = "SELECT tblWJCItem.AddedDescription, tblWJC.WJCPrefix, tblWJC.WJCNo, tblWJCItem.MaterialName, tblStockFamily.StockFamily, tblWJCItem.WeightToSend, tblWJC.DateCreated, tblWJC.WJCStatusID FROM tblWJC INNER JOIN tblCustomer ON tblWJC.CustomerID = tblCustomer.CustomerID INNER JOIN tblWJCStockStatus ON tblWJC.WJCStockStatusID = tblWJCStockStatus.WJCStockStatusID INNER JOIN tblStockStatus ON tblWJC.WJCID = tblStockStatus.WJCID LEFT OUTER JOIN tblWJCProductLine ON tblWJC.WJCID = tblWJCProductLine.WJCID LEFT OUTER JOIN tblWJCStockItem ON tblWJCProductLine.WJCProductLineID = tblWJCStockItem.tblWJCStockItem INNER JOIN tblStockFamily ON tblWJCItem.ProductFamilyID = tblStockFamily.StockFamilyID WHERE tblCustomer.CustomerName = 'NAME' AND tblWJCStockStatus.WJCStockStatus <> 'Stock Usage Confirmed' ORDER BY tblWJC.WJCID"; and then fetch the results by the following php code: $result = sqlsrv_query($conn, $query); while($row = sqlsrv_fetch_object($result)){ echo $row->AddedDescription .",".$row->WJCPrefix .",".$row->WJCNo.",".$row->MaterialName.",".$row->StockFamily.",".$row->WeightToSend.",".$row->DateCreated->format('d-m-Y').",".$row->WJCStatusID ."<br />"; } The connection to the database does get established but no results come through, i've got error reporting on in my php and the following message gets given: Warning: sqlsrv_fetch_object() expects parameter 1 to be resource, boolean given in C:\inetpub\wwwroot\kris\abs\test\rollsroyce.php on line 31 Line 31 is the while($row = sqlsrv_fetch_object($result)) Can anyone help with sorting this out its really starting to annoy me now. .
×
×
  • 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.