-
Posts
24,511 -
Joined
-
Last visited
-
Days Won
819
Posts posted by Barand
-
-
36 minutes ago, joshualjohnson said:
mysqli_ is backwards compatible with mysql_.
In what respect?
-
here's an example for you
<?php $link1 = "<a class='LOOKUP' href='http://google.com' target='_blank'>Site 1</a>"; $link2 = "<a class='LOOKUP' href='http://yahoo.com' target='_blank'>Site 2</a>"; ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Example</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script type="text/javascript"> $().ready( function() { $(".LOOKUP").click( function(event) { event.preventDefault() var loc = $(this).attr("href") var linktext = $(this).html() $("#mytext").append(linktext + "\n") window.open(loc, '_blank'); }) }) </script </head> <body> <?=$link1?> <br> <?=$link2?> <br> <h3>Visited links</h3> <textarea rows="5" cols="35" id="mytext" ></textarea> </body> </html>
-
Then you want
echo "<td><a href='https://whatismyipaddress.com/ip/$col' target='_blank'>$col</a></td>";
-
What page do you want to link to? So far you have
- href = 'https://whatismyipaddress.com/ip-lookup'
- href = 'https://whatismyipaddress.com/ip'
Have you tested them by entering the link addresses in your browser?
-
3 hours ago, ajetrumpet said:
but i'm sent to the page: https://whatismyipaddress.com/ip-lookup
Why would you expect a link to pageXYZ not to send you to pageXYZ?
-
https://www.smarty.net/docs/en/what.is.smarty.tpl
Smarty and Twig are both template engines.
-
Smarty?
Twig?
-
31 minutes ago, Psycho said:
Put all of your logic at the start of the script and assign the output to variables
… but bear this in mind
-
2 hours ago, ajetrumpet said:
hit a deer with each one. those are easy to damage tho...made of plastic
You have plastic deer? We have concrete cows in Milton Keynes...
-
1 hour ago, requinix said:
I really wouldn't have expected ASP Classic to be that bad at handling strings
Bad enough that someone felt the need to publish an article about it!
-
It's a Mercedes CLK 500 V8 coupe.
About $8 (6.30 GBP) per gallon. Mine does around 12 miles / gallon around town
-
57 minutes ago, ajetrumpet said:
What in the world do you need anymore money for!?
Petrol (gas) and insurance to run my 5L (305 cu.in) car
-
I knew someone said it 😊
-
Around the turn of the century I had just discovered PHP and was currently using ASP with VB for intranet applications. One particular page enabled users to view log entries each day. This had worked fine for months when I received a complaint from one of the users that it was running very slowly. I tried it myself and, sure enough, it took about 15 seconds to display the data.
Examining the entries in the SQL Server table for that day I noticed that there were some abnormally long text entries, way longer than usual. Curious about the time taken I decided to write the application in PHP (for the practice if nothing else) and see if that improved things.
It did.
For the same day, the screen displayed in 0.25 seconds. That was 70 times faster! Too good to be true, I thought. So I compared the two programs.
The structure of the ASP program wasloop get record concatenate output into a string endloop outout the string
The PHP structure wasloop get record output endloop
The ASP structure was a better "separation of concerns" which is the method usually preached, but it did come at a cost as further experimentation was to prove.
My next task was to rewrite the ASP using the PHP structure and vice versa so that I could get a much fairer comparison.
As the chart below shows, concatenating does have an overhead (especially with long strings) and this is even more marked with VB which seemed extremely poor at handling the task. -
But as Mark Twain (?) commented "Canada's OK but not for the whole weekend"
-
That's sabotaged my freebie hoilday to the States
-
$50 per hour plus travel time and expenses
-
The PHP code embedded inside html tags is just generating more html code dynamically (usually containing data extracted from a database) which becomes part of the overall html page.
This then received by the browser (PHP's job is now done) on the client and rendered to display on the screen.
EDIT:
Your PHP code may look something like this
<html> <body> <table border='1'> <tr> <th>IP ADDRESS</th> <th>PAGE VISITED</th> <th>PREVIOUS PAGE</th> <th>DATE</th> <th>TIME</th> </tr> <?php // printing table rows while($row = mysqli_fetch_row($sql)) { echo '<tr>'; foreach ($row as $col) { echo "<td>$col</td>"; } echo "</tr>\n"; } ?> </table> </body> </html>
and what your browser then receives is something like this
<html> <body> <table border="1"> <tr> <th>IP ADDRESS</th> <th>PAGE VISITED</th> <th>PREVIOUS PAGE</th> <th>DATE</th> <th>TIME</th> </tr> <tr><td>111.222.001.123</td><td>a.php</td><td>N/A</td><td>10/11/19</td><td>9:00am</td></tr> <tr><td>111.222.001.123</td><td>a.php</td><td>N/A</td><td>10/12/19</td><td>8:00am</td></tr> <tr><td>111.222.001.123</td><td>a.php</td><td>xyz</td><td>10/12/19</td><td>12:00pm</td></tr> <tr><td>111.222.001.123</td><td>a.php</td><td>N/A</td><td>10/12/19</td><td>1:00pm</td></tr> </table> </body> </html>
-
You are creating variables that you never use ($column_count, $fields_num)
Your HTML markup for the table is wrong
- You have two table opening tags.
- You should have a <tr> tag at start of every row, not just when $i==1.
Use CSS styles instead of deprecated html attributes (eg width, align)
You don't need the $conn->close(); - that happens anyway at the end of the script.
Do not use "SELECT * ...". Specify the columns you want. (The table structure could be changed in future). I also told you earlier that dates should be stored as yyyy-mm-dd format. Same goes for times (hh:mm or hh:mm:ss). If you don't then you can't use them to order your data.
mysql> SELECT time12 , time24 FROM tbtime ORDER BY time12; +--------+--------+ | time12 | time24 | +--------+--------+ | 2:00AM | 02:00 | | 2:00PM | 14:00 | | 4:00AM | 04:00 | | 4:00PM | 16:00 | | 6:00PM | 18:00 | | 8:00AM | 08:00 | | 8:00PM | 20:00 | +--------+--------+
You can reformat them for human benefit.
<?php $dbHost = "localhost"; $dbName= "rptDatabase"; $dbUsername = "username"; $dbPassword = "password"; mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); $conn = mysqli_connect($dbHost, $dbUsername, $dbPassword, $dbName); $sql = mysqli_query($conn, "SELECT ip , page , CASE WHEN referrer = '' THEN 'N/A' ELSE referrer END as referrer , DATE_FORMAT(date, '%m/%d/%y') as formatdate , TIME_FORMAT(time, '%l:%i%p') as formattime FROM tblTraffic ORDER BY ip, date, time"); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Example</title> <style type="text/css"> table { font-family: verdana, sans-serif; font-size: 10pt; width: 100%; border-collapse: collapse; } th, td { width: 20%; text-align: center; padding: 8px; } th { background-color: #396; color: #FFF; } </style> </head> <body> <table border='1'> <tr> <th>IP ADDRESS</th> <th>PAGE VISITED</th> <th>PREVIOUS PAGE</th> <th>DATE</th> <th>TIME</th> </tr> <?php // printing table rows while($row = mysqli_fetch_row($sql)) { echo '<tr>'; foreach ($row as $col) { echo "<td>$col</td>"; } echo '</tr>'; } ?> </table> </body> </html>
-
I have yet to meet the developer who's happy with GoDaddy.
You are trying to connect to a MySQL database on GoDaddy's server, so the host is their server's server name or IP address.
The username and password also need to be valid for access to that database on that server.
Can you connect to the database using PhpMyAdmin? If so that's a good place to start with the right credentials.
-
1 hour ago, ajetrumpet said:
I added my username to the database as an authorized user and clicked "allow all privaleges".
Be careful what privileges you give to an online connection. Just give the bare minimum required for the site to function.
-
1 minute ago, ajetrumpet said:
$conn = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName)
You've removed the ";" from the end of the statement
-
1 minute ago, ajetrumpet said:
As far as REFERER goes, everything I read on the web mentions nothing about an array section of the variable that I have to specify.
-
This should fly better
<?php $dbHost = "ipaddress"; // USE $dbName= "rptDatabase"; // VALID $dbUsername = "username"; // CREDENTIALS $dbPassword = "password"; // HERE $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $page = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : ''; $referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; // check they exist $date = date("Y-m-d"); $time = date("h:i:a"); mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); // tells mysqli to automatically report errors $conn = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName);; $stmt = $conn->prepare("INSERT INTO tblTraffic (ip, page, referrer, date, time) VALUES (?, ?, ?, ?, ?)"); $stmt->bind_param("sssss", $ip, $page, $referrer, $date, $time); $stmt->execute(); $stmt->close(); $db->close(); ?>
populate textbox after clicking href URL
in PHP Coding Help
Posted
It's a link to jQuery function library