Search found 167 matches

by AdoptiveSolution
Mon Jan 09, 2017 6:01 am
Forum: PHP coding => General
Topic: Help w/ Include File
Replies: 2
Views: 855

Re: Help w/ Include File

The file should be named index.php.

Or you should configure your webserver to handle php code in .htm(l) files.
by AdoptiveSolution
Sun Jan 08, 2017 5:57 am
Forum: PHP General
Topic: How might I upload a image file?
Replies: 1
Views: 1163

Re: How might I upload a image file?

Here you can get the fully functional code to upload an image :

http://www.w3schools.com/php/php_file_upload.asp
by AdoptiveSolution
Sun Jan 08, 2017 4:35 am
Forum: JavaScript
Topic: Show edited input by php function from html form in realtime
Replies: 2
Views: 2268

Re: Show edited input by php function from html form in realtime

I changed it to this. The HTML File : <script> $(document).ready(function(){ $('#topicInput').on('change',function(){ var topicInput = $(this).val(); if(topicInput){ $.ajax({ type:'POST', url:'ajaxStringScript.php', data:'topic='+topicInput, success:function(html){ $('#contentInput').html(html); } }...
by AdoptiveSolution
Thu Jan 05, 2017 2:44 am
Forum: mySQL & php coding
Topic: How can I execute this code inside a class?
Replies: 1
Views: 875

Re: How can I execute this code inside a class?

Use this :

Code: Select all

<?php
$thetext = 'huge string of text. Just an example, the texts are usually 8 lines long';
$text = new Summarizer;
$text->function_name($thetext);
?>
by AdoptiveSolution
Thu Jan 05, 2017 1:52 am
Forum: PHP Scripts
Topic: $_SESSION error:Notice: Undefined offset: 0
Replies: 1
Views: 1181

Re: $_SESSION error:Notice: Undefined offset: 0

To show the value, echo it :

Code: Select all

echo '<p>' . $_SESSION['username'] . '</p>';
by AdoptiveSolution
Mon Jan 02, 2017 7:55 am
Forum: PHP coding => Images
Topic: I cant make my upload image work
Replies: 4
Views: 2709

Re: I cant make my upload image work

Also, the quotes are wrong :

Code: Select all

$sql = "INSERT INTO images (image,text) VALUES ('$image',''$text')";
by AdoptiveSolution
Mon Jan 02, 2017 7:53 am
Forum: PHP coding => Images
Topic: I cant make my upload image work
Replies: 4
Views: 2709

Re: I cant make my upload image work

Please use the code button if you paste code. It's easier to read.

Next, I notice a missing ; at the end of some lines.
by AdoptiveSolution
Wed Dec 14, 2016 9:31 am
Forum: PHP coding => Images
Topic: Download image to desktop from database
Replies: 2
Views: 2260

Re: Download image to desktop from database

If you are familiar with the internet search feature, why not search for the answer?

http://www.google.com/search?q=upload+a ... s+file+php

BTW, I do both both : save images in a database and as file. Depending on my needs I retrieve one or the other. Works fine.
by AdoptiveSolution
Tue Dec 13, 2016 3:25 pm
Forum: PHP coding => General
Topic: Php statement not evaluating in html-help please
Replies: 0
Views: 677

Re: Php statement not evaluating in html-help please

The closing " of the style is missing :

Code: Select all

endif; ?>"> content
by AdoptiveSolution
Sun Dec 11, 2016 7:25 am
Forum: PHP coding => Images
Topic: Download image to desktop from database
Replies: 2
Views: 2260

Re: Download image to desktop from database

This page has code that shows how to store and retrieve images from a database :

https://phpro.org/tutorials/Storing-Ima ... h-PHP.html
by AdoptiveSolution
Sun Dec 11, 2016 4:13 am
Forum: mySQL & php coding
Topic: What is the correct method to connect to mySql Database please?
Replies: 2
Views: 1805

Re: What is the correct method to connect to mySql Database please?

Here's the simplest way to connect : <?php $db = new mysqli('localhost','user','password','database'); $query = "SELECT * FROM table"; if ( $result = $db->query( $query ) ) { if ( $result->num_rows > 0 ) { while ( $row = $result->fetch_object() ) { echo $row->name . '<br />'; echo $row->contact . '<...
by AdoptiveSolution
Sun Dec 04, 2016 4:08 pm
Forum: PHP coding => General
Topic: PHP function not working
Replies: 0
Views: 810

Re: PHP function not working

The code is not mine, I probably found it in this forum or elsewhere. The original code showed the full pathname. I added the substr() to cut out the getcwd() part. The print_r() in the function is there, so you can see what's happening. <?php function find_all_files($dir) { $root = scandir($dir); e...
by AdoptiveSolution
Fri Nov 18, 2016 8:32 am
Forum: PHP coding => General
Topic: How to transfer two variables from purchases.php to index.php?
Replies: 8
Views: 1802

Re: How to transfer two variables from purchases.php to index.php?

It is sample code to show how a session works. Part of the learning process is to recognize the answer. What you need is this : session_start(); $_SESSION['x'] = $x; $_SESSION['y'] = $y; on one page. And this: session_start(); $x = $_SESSION['x']; $y = $_SESSION['y']; on the other page. This : heade...
by AdoptiveSolution
Fri Nov 18, 2016 2:58 am
Forum: PHP Scripts
Topic: storing and retrieving session from one page to another
Replies: 2
Views: 2477

Re: storing and retrieving session from one page to another

You have to start a session on each page.

Add this at the top of each page :

Code: Select all

<?php
session_start();
?>
Oh, and use the CODE button when you add code to your post. It's easier to read and to copy.
by AdoptiveSolution
Fri Nov 18, 2016 2:53 am
Forum: PHP coding => General
Topic: How to transfer two variables from purchases.php to index.php?
Replies: 8
Views: 1802

Re: How to transfer two variables from purchases.php to index.php?

Use sessions. The sending page session_send.php : <?php session_start(); echo "<h3>Sending Session Vars</h3>"; $x = 'this is x'; $y = 'this is y'; echo $x . '<br />'; echo $y . '<br />'; $_SESSION['x'] = $x; $_SESSION['y'] = $y; header('Refresh:5; url=session_receive.php'); ?> The receiving page ses...
by AdoptiveSolution
Mon Nov 14, 2016 10:16 am
Forum: PHP General
Topic: URGENT help required with PHP contact form
Replies: 0
Views: 965

Re: URGENT help required with PHP contact form

The template only has the code to display the form in HTML. The send_email.php file has the code to send an email. You have to create it yourself, unless the site that provided the template also provides the php. Anyway, here's a page that shows how to do it : http://www.html-form-guide.com/email-fo...
by AdoptiveSolution
Mon Nov 14, 2016 10:10 am
Forum: PHP coding => General
Topic: Warning: in_array() expects parameter 2 to be array, string given in
Replies: 1
Views: 736

Re: Warning: in_array() expects parameter 2 to be array, string given in

The variables $reducepadding and $singlecolumnbullets should be arrays. Are they? To find out, echo them: echo $reducepadding; echo $singlecolumnbullets; or : echo '<pre>'; print_r($reducepadding); print_r($singlecolumnbullets); echo '</pre>'; Here's sample code of what in_array() is : http://www.w3...
by AdoptiveSolution
Sat Nov 12, 2016 7:48 am
Forum: mySQL & php coding
Topic: Populating a table in database
Replies: 1
Views: 1187

Re: Populating a table in database

And here's a sample query to select from the 3 tables: <?php $query = "SELECT user.name as Name, department.departmentId as 'Dept Id', department.departmentName as 'Dept. Name', department.departmentDesc as 'Dept. Description' FROM resident INNER JOIN user ON user.userId = resident.userId INNER JOIN...
by AdoptiveSolution
Sat Nov 12, 2016 7:31 am
Forum: mySQL & php coding
Topic: Populating a table in database
Replies: 1
Views: 1187

Re: Populating a table in database

Here's a solution : <?php $data = 1; //assuming saved user ID from the user insert"; $query = "SELECT departmentId FROM department"; $result = $db->query($query); $comma = 0; $insertquery = "INSERT INTO resident VALUES "; while ( $row = $result->fetch_object() ) { $insertquery .= ($comma > 0) ? ',' ...
by AdoptiveSolution
Fri Nov 04, 2016 5:24 am
Forum: PHP coding => General
Topic: Changing my users' passwords in my db
Replies: 2
Views: 1113

Re: Changing my users' passwords in my db

Here's a sample page that will create a password with verify : http://adoptive.esy.es/crypt_pw/ Here's the page as text : http://adoptive.esy.es/crypt_pw/crypt_pw.txt Create a new password for each user, copy the result from the shaded area and manually store them in the database. I.e. in the user_p...