Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

I'm really sorry, but I guess my confusion is:

  1. How is the existing functionality different from the expected functionality? Is it just that the user cannot use a credit card but only their debit card?
  2. Upon paying for the digital goods, is the user presented with a way of downloading them? Or is that the part that isn't working?
  3. What are the contents of your thankyou.php page? I know that you've been having a difficult time posting code, so posting it here as an attachment should work just as well.
  4. What are you hoping that utilizing IPN will accomplish for you?
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

If you're using jQuery (which it doesn't look like you are, but I thought i'd just mention it in case), you can do something as simple as $('figure img) to find all images that are children of figures, or $('img[src="images/start.png"]) to find all images that have images/start.png as their source URI, etc.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Which lines in the code above correspond to lines 118-120 of public.php?

Also, I'm including the image here for reference.

6926d234978766542f544ed1e31e465c.png

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Thanks for the comment. That makes me think you need to use the following function to convert numerics to strings.

PHP is an untyped language. There's no need to type cast it to a string. Use the PHP substr() function to get the digit you want (first, last, middle.)

rproffitt commented: Hmm, my reading was they were making a string, not extracting. +15
RC_820 commented: where i can reply my post? i want reply for the answer +0
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

I guess the basic question is whether there is an easier quicker way to do this other then creating a mysql table to keep track of the visitor count per sub-domain?

It depends on what you need to track. If you just want to track traffic count, then simply use ?utm_ variables and track them with Google Analytics. They'll also track conversions for you.

If you actually need to split commissions, etc. you need to set up a database to manage this, or use a third-party affiliate suite.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

So sorry for not seeing this question until now. This can be managed yourself, through a database. However, you don't need a subdomain for each traffic source. You can easily pass in a UTM parameter for each traffic source, which has the added benefit of being recognized and stored in Google Analytics.

Another option is to use many of the affiliate suites that exist to manage this, but of course that would mean sharing commission.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

When the function is called I get a blank screen

This happens when there's a PHP fatal error. Usually, it's a syntax error, but it can also be when a function call can't be made, parse error, or any number of different things. At the top of the PHP script, you can put the following to display on screen what the error actually is (just do this in developer mode and not in production so your end users won't see it):

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

Also, and this is just a recommendation, you might wish to use PHP short tags. You may need to enable this on your server if it's not enabled by default, but they make it much easier to write PHP templates. Instead of your existing PHP template, when using PHP short tags, you can write it as the following instead, which makes it much clearer to understand:

<tbody>
    <?php foreach ($friends as $row): ?>
            <tr>
                <td>
                    <span class="font-w600"><?= $row['user'] ?></span>
                </td>
                <td class="d-none d-sm-table-cell text-center">
                    <?= $row['fname'] ?> <?= $row['lname'] ?>
                </td>
                <td class="font-w600">
                    <?= $row['mem_status'] ?>
                </td>
                <td class="d-none d-sm-table-cell text-center">
                    <?= $row['join_date'] ?>
                </td>
           </tr>
     <?php endforeach; ?>
</tbody>
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

The three list items don't all fit together on the same line. The third item is being wrapped around to the next line. If you do white-space: nowrap; that should fix the problem. Another idea is to use CSS flex boxes instead of float: left but that's a whole different thing. Try using the white-space property to tell it not to wrap to the next line and let me know if that fixes your problem.

Pocokos commented: Thank you but I have already applied white-space: no wrap, I have attached some screenshots, that might better explain it better than I did :D +0
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

So basically what you want is to be able to pass a parameter into index.php. For example, domain.com/index.php?username=dani or domain.com/index.php?username=fred

Your PHP code can then use $username = $_REQUEST['username']; in order to retrieve the username that is passed into PHP.

You'll then want to use .htaccess and mod_rewrite (You guessed it!!) to translate domain.com/dani into domain.com/index.php?username=dani

This will only work if you are using an Apache web server, not nginx, since only Apache supports .htaccess files.

If you don't already have an .htaccess file, create one in your domain root directory. It can look something like this:

RewriteEngine on

RewriteRule ^([a-z+])$ /index.php?username=$1 [L]

The above will quietly redirect something such as domain.com/abc to index.php?username=abc where abc is any string of one or more lowercase characters.

showman13 commented: Hey Dani, thanks for the response... +5
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

If it’s in the same directory, then you can do:

echo ‘<a href=“‘, rawurlencode($l_filename) , ’”>click here</a>’;

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

In the line $l_filename = $stmt->fetch(); does $l_filename what is an example of what it gets set to? A complete URI, just a filename, filepath + filename, etc.?

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Articles in their entirety are marked as solved by the OP. Recommended answers are not. They are recommended by our platform. There can be more than one per article. Basically they’re just replies that have been voted up, posted by members known to be knowledgeable in the subject area, etc. They’re designed to be recommended reading points for longer threads.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

You mention that in order to get to the form, the user has already been authenticated and variables have been added to the session. If that's the case, can't the beginning of insUpSel.php simply check whether the proper session variables exist, and if not, do an HTTP header redirect to the login page?

On insupsel.php, you can do any of the following:

// 'submitted' field with specific value was passed into form
if (isset($_POST['submitted']) AND $_POST['submitted'] == 'value') { ... }

// 'user_id' cookie with specific value is set
if (isset($_COOKIE['user_id']) AND $_COOKIE['submitted'] == 'value') { ... }

// 'session_var' session variable with specific value exists
if (isset($_SESSION['session_var']) AND $_SESSION['submitted'] == 'value') { ... }
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

A single quote indicates treating everything inside as a literal string. Double quotes indicate parsing out variables inside the string. For example:

$foo = 'World';

echo 'Hello $foo'; // Prints Hello $foo
echo "Hello $foo"; // Prints Hello World

You can use single quotes inside a double-quoted string, or double quotes inside a single-quoted string. But if you're going to try to encase double quotes within double quotes, it is treated as a premature end to the string. You need to escape the quote with a backslash as so:

echo '<select id="nm" name="name">'; // This will work
echo "<select id=\"nm\" name=\"name\">"; // This will work too
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Your problem appears to be on line 9 of the code you provided:

echo "<select id=''nm'' name=''Name''>";

Instead, try:

echo '<select id="nm" name="name">';

I'm not sure why you had the two single quotes next to each other, so that needed to be fixed. Also, while group and btype are lowercase, you have the name of the select field Name but then you were trying to retrieve $_POST['name'].

Let me know if this works.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

I'm not too good with regex, but if you're using jQuery, there's a built-in utility where you pass it an HTML string, and it converts that string to valid dom nodes for you to do what you want with. Hope maybe this will help with whatever it is you're trying to do.

bprosic commented: Thanks for reply. Instead of regex, how can I achieve my goal using cheerio or node-html-parser or with jquery? +2
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Looks to be that a post was created in the database and then rolled back, because the transaction failed for one reason or another. I'll inspect the server log in a bit to see if I can figure out why the query didn't go through.

rproffitt commented: Marking solved. Not a big issue. More an observe and report thread. +0
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Fixed.

rproffitt commented: Looks fixed. Marking solved. +0
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Sorry about that. Something weird was going on and PHP had to be restarted.

cat-tree.jpg

rproffitt commented: Thanks. Also "Tee-hee!" +0
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Please email me the images that didn’t work. Thanks!!

Email address provided on contact us page.

rproffitt commented: Done. Just two since well, don't want to clog up the works. +0
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

If this is reproducable, it would be great if you could give me the full error message.

Use Chrome DevTools (or Firefox Developer Tools, Safari, Edge, etc.)

I just had surgery yesterday and am filled up with anesthesia and as groggy as hell, so I can't really describe how to do this if you don't already know.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

The best thing you could do is provide the full HTTP responses for all xhr requests. I'm not sure how to do that if I don't already have DevTools open when I make the request.

The second best thing you could do is log the exact UNIX epoch time that the issue happened so that I can see if I can find something going on in the logs.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

OK so it looks like there are two things at play here.

Firstly, it looks like you accidentally double posted, which is the same thing that the member here did. Did you double click the submit button?

Secondly, I'm not sure what you mean by the abiilty to share images is broken. I just posted with an image. What error message are you getting?

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Test test test.

logo.png

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Sometimes race conditions occur in which the post count gets miscalculated. A nightly cron job fixes the counters.

In this case, it looks as if the topic was accidentally double posted. Double-clicking the submit button apparently caught a race condition in which the member's post count was only incremented once instead of twice. A moderator deleted one of the accidental duplicates, which reduced the post count from 1 to 0, instead of from 2 to 1.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Looks like you have now purchaed an SSL certificate and have a secure website.

This question was asked on March 19th and it looks like an SSL certificate was purchased April 8th.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Otherwise, you can change lines 7-9 to be something like:

<?php if ($i == 0): ?>
    <article> 6th Element </article>
<?php endif; ?>
<article>
    Element
</article>

That will inject the 6th element in at the beginning, before we increment $i.

fecapeluda commented: Dani, that worked pertect! Gracias! +0
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

What is <?php START LOOP ?> ?? I assume it's some logic you have that loops through articles?

I'm having a hard time following your code because of your indenting.

I actually have to run in just a moment so I don't have much time to figure out what you're trying to do here ... my guess is that you want to use modular division so that when you loop through the articles, you increment $i each time. Then, if $i is even, open the div, and if $i is odd, close the div.

Does the code that you have do just that and work properly?

If so, at which point are you trying to add another article? Do you have data about the article? Why can't you just add it to the stack of articles that you are loopng through on line 2?

In other words, it sounds to me like the 6th article should be added by the controller, not the view.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Sorry, I can't help, because unfortunately I have no python experience. But I've tagged this thread pygame so hopefully it will get more eyeballs and someone will be able to help.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Here's a link to where you can configure your Facebook widget.

https://developers.facebook.com/docs/plugins/like-button/

Change the layout to anything other than 'button' to include a count of how many people have liked the page.

Here's a wizard where you can embed a count of how many Tweets the page has gotten: https://publish.twitter.com/#

SubbuPD commented: This worked for me +0
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

There’s a snippet of Javascript you can put on your site to show how many Facebook likes it got, how many Tweets, etc.

I’m on my cell now not near my computer but I’ll find specific code for you a bit later.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

I spent about an hour on this yesterday hoping to be able to come up with a workaround but, unfortunately, no dice.

The only way to do it is to send an AJAX request each time you click next in the form, and doing so would be a bit too much additional PHP code than I’d like to spend on it. I don’t feel it’s that big of a pain point.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

This is by design. It’s all one single Contribute form that was broken up into a wizard to make it easier for newer members to digest it little by little.

However, we don’t actually touch the server until that final submit button is pressed.

It was hard enough work to get it to bring you back to the step that had the errors instead of the first step every time.

Technically speaking, it would not be completely impossible to validate each page before continuing to the next. However, it would be a significant amount of work, and I’m not convinced it’s a big enough pain point to warrant it.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Sorry, I forgot to mention that I fixed this a couple of hours ago.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

That’s weird. I’ll fix this in just a bit. Thanks for the catch.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

What does the data in your database look like? Line 20 of your code is retrieving all the data within the row(s) of the Calendar_Data table for today's date.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

You want to modify row 20 to be $temp = $row['ip_address'];

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

In your while loop, your variable $row is like a record with a column for each thing you are pulling. Therefore, it's a PHP array with an array field for each thing you're pulling. In this case, you're just pulling one field (ip_address) so it's an array with just one element.

$row['ip_address'] can be used to retrieve the IP address within your loop.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Hi,

Sorry, unfortunately I know you tried to explain, but unfortunately I'm still confused. For example, you are saying that you have items categorized in different groups, so for example you have a table category with columns parent and item. So I see you want to fetch a list of items where the parent is a specific thing. Firstly, I would escape $parent in the database so it is parent = '$parent' or you could end up with a MySQL injection attack or worse. Secondly, what is your for loop on line 13 supposed to do? Why can't you just do:

        while($row = mysqli_fetch_assoc($r)){
             echo '<a class="text" href="">' . $row['item'] . '</a><br />';
        }
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

What error message are you seeing?

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

So I see you are pulling in a first name, last name, and email addess from a form. You're then sanitizing the data preparing it for your MySQL statement.

However, your SQL statement needs to have quotes around $email as so:

$sql = "SELECT * FROM `users` WHERE `email` = '$email'";

You're then querying hte database with that SQL statement, and if a row exists, saying it does, and if it doesn't, it looks like you have some extraneous spaces between your open-single-quote and your variables, which they shouldn't have. Lines 18/19 should read:

$sql = "
    INSERT INTO `users` (fname, lname, email, reg_date)
    VALUES ('$fname', '$lname', '$email', NOW())
";
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

The code is already very heavily commented so it would be hard for us to explain what it does more than the programmer who wrote it and commented their code while doing so.

Perhaps if you could give us a better example of what you're looking for? You say the process of moving the elevator ... the entire thing simulates an elevator moving. Do you mean your homework assignment is to convert the existing code to pseudocode?

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

The problem is I converted your PHP array to JSON using the json_encode() function and then ran it through a few different JSON to XML php parsers, and it broke in all of them.

e.g. https://github.com/mevdschee/json2xml.php

The reason I converted it to JSON first is because all of the PHP array to XML parsers I found on the web didn't work and some of the JSON to XML parsers seemed more robust.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

I see. It's just that sometimes when something is more difficult than it should be, there's a way to somehow work around dealing with it.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

What I'm saying is why do you need XML at all? Why can you just not work with JSON and only JSON? JSON is super easy to convert to and from a PHP array and it also can be stored as a string and outputted in a pretty format. IMHO it has all the benefits of XML and more.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Aww, I really wish I could help you, but unfortunately I don't know Python. Perhaps the least I can do is bump this thread and hopefully it can get some renewed interest. That is, unless you have already figured out what was wrong.

You're referring to the while loop that begins on line 74, correct?

I'm completely grasping at straws here, but what about a do while loop instead of a while loop?

ppel123 commented: Hi Dani, thanks for answering, after a lot of search I managed to solve it with threading events of Python. Thanks for the interest. +0
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

I played around with it a bit, but SimpleXML really needs to change it's name because it's not simple to work with at all. I might take another crack at it in a little bit.

That being said, is there a reason that you are forced to use XML? PHP makes it sooooo easy to work with the JSON format and JSON is even more portable than XML is.

You can literally just do: $output = json_encode($data, JSON_PRETTY_PRINT) to nicely format $output into a JSON text string.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Your code <a href="<?php echo "/{$file}";?>"> is a link to the actual .iso file you want them to download.

Instead, you want to create a new page such as download.php?file=123 where an ID for the file is passed in as a parameter. When that page is accessed, it increments a counter in a database for file 123, and then it redirects the browser to the location of the file.

Do you already have a database set up for this web app?

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Try <input type="image" src="images/button_send-email.png" alt="Email">

You can see according to W3 that type="image" creates a graphical submit button.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

I'm marking this question as solved. In the future, click the Question Solved toggle :)