Error |
Error |
tudsy |
Aug 19 2017, 12:35 AM
Post
#1
|
Advanced Member Group: Members Posts: 246 Joined: 30-September 14 Member No.: 21,611 |
Hi
With this query string, I get the error: [19-Aug-2017 05:13:26 UTC] PHP Parse error: syntax error, unexpected '<' in /home/ecovibdc/public_html/ECOVIB2D/MYART/processmidpage.php on line 135 [19-Aug-2017 05:17:15 UTC] PHP Notice: Undefined index: username in /home/ecovibdc/public_html/ECOVIB2D/MYART/ecovib2d1.php on line 187 [19-Aug-2017 05:17:15 UTC] PHP Notice: Undefined index: email in /home/ecovibdc/public_html/ECOVIB2D/MYART/ecovib2d1.php on line 187 When I load ecovib2d1.php, load the graphic and hover over the buy button, I get a 'NaNNaN.........' type of output on the status bar. I do not know what is happening? I think I have defined username and email correctly in the query string? document.getElementById('form').action="http://103.226.223.161/~ecovibdc/ECOVIB2D/MYART/processmidpage.php?username=" + <?php echo $_GET['username'];?> + "&email=" + <?php echo $_GET['email'];?> + "&Person=" + personname + "&Price=" + Priceofart + "&Graphic=" + picname.replace('w.bmp','.bmp'); Thanks. Attached File(s) processmidpage.php ( 3.82k ) Number of downloads: 506 ecovib2d1.php ( 10.02k ) Number of downloads: 465 |
CharlesEF |
Aug 19 2017, 06:50 PM
Post
#2
|
Programming Fanatic Group: Members Posts: 1,981 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
According to your code, in 'ecovib2d1.php' line 187, you should have 'username' and 'email' in the query string. I suspect that when 'ecovib2d1.php' loads there is no query string for the page. That is the reason for the 2 undefined index errors. If 'ecovib2d1.php' does have the query string then I would need to see the code for the page that loads it.
In 'processmidpage.php' this section of code is totally wrong: CODE <?php It should be: $name=<?php echo $_GET['username']?>; $email=<?php echo $_GET['email'] ?>; $graph=<?php echo $_GET['Graphic']?>; $Priceof=<?php echo $_GET['Price']?>; $pers=<?php echo $_GET['Person']?>; ?> CODE <?php And that is the reason for the parse error. You can't use, and don't need to use, PHP tags inside another PHP tag.$name=$_GET['username']; $email=$_GET['email']; $graph=$_GET['Graphic']; $Priceof=$_GET['Price']; $pers=$_GET['Person']; ?> Also, on line 112 I see this line of code: CODE <script type='text/javascript' src='//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit'></script> You might want to check the 'src' value to be sure it is correct.This post has been edited by CharlesEF: Aug 19 2017, 07:05 PM |
tudsy |
Aug 20 2017, 12:15 AM
Post
#3
|
Advanced Member Group: Members Posts: 246 Joined: 30-September 14 Member No.: 21,611 |
According to your code, in 'ecovib2d1.php' line 187, you should have 'username' and 'email' in the query string. I suspect that when 'ecovib2d1.php' loads there is no query string for the page. That is the reason for the 2 undefined index errors. If 'ecovib2d1.php' does have the query string then I would need to see the code for the page that loads it. In 'processmidpage.php' this section of code is totally wrong: CODE <?php It should be: $name=<?php echo $_GET['username']?>; $email=<?php echo $_GET['email'] ?>; $graph=<?php echo $_GET['Graphic']?>; $Priceof=<?php echo $_GET['Price']?>; $pers=<?php echo $_GET['Person']?>; ?> CODE <?php And that is the reason for the parse error. You can't use, and don't need to use, PHP tags inside another PHP tag.$name=$_GET['username']; $email=$_GET['email']; $graph=$_GET['Graphic']; $Priceof=$_GET['Price']; $pers=$_GET['Person']; ?> Also, on line 112 I see this line of code: CODE <script type='text/javascript' src='//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit'></script> You might want to check the 'src' value to be sure it is correct.Hi Thanks for that. I have just on question. What do you mean 'username' and 'email' must be inside the query string? Thanks. |
tudsy |
Aug 20 2017, 05:39 AM
Post
#4
|
Advanced Member Group: Members Posts: 246 Joined: 30-September 14 Member No.: 21,611 |
According to your code, in 'ecovib2d1.php' line 187, you should have 'username' and 'email' in the query string. I suspect that when 'ecovib2d1.php' loads there is no query string for the page. That is the reason for the 2 undefined index errors. If 'ecovib2d1.php' does have the query string then I would need to see the code for the page that loads it. In 'processmidpage.php' this section of code is totally wrong: CODE <?php It should be: $name=<?php echo $_GET['username']?>; $email=<?php echo $_GET['email'] ?>; $graph=<?php echo $_GET['Graphic']?>; $Priceof=<?php echo $_GET['Price']?>; $pers=<?php echo $_GET['Person']?>; ?> CODE <?php And that is the reason for the parse error. You can't use, and don't need to use, PHP tags inside another PHP tag.$name=$_GET['username']; $email=$_GET['email']; $graph=$_GET['Graphic']; $Priceof=$_GET['Price']; $pers=$_GET['Person']; ?> Also, on line 112 I see this line of code: CODE <script type='text/javascript' src='//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit'></script> You might want to check the 'src' value to be sure it is correct.Hi Thanks for that. I have just on question. What do you mean 'username' and 'email' must be inside the query string? Thanks. Hi Do you mean: document.getElementById('form').action='http://103.226.223.161/~ecovibdc/ECOVIB2D/MYART/processmidpage.php?username=' + username + '&email=' + email + '&Person=' + personname + '&Price=' + Priceofart + '&Graphic=' + picname.replace('w.bmp','.bmp'); |
CharlesEF |
Aug 20 2017, 09:49 AM
Post
#5
|
Programming Fanatic Group: Members Posts: 1,981 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
I have just on question. What do you mean 'username' and 'email' must be inside the query string? document.getElementById('form').action='http://103.226.223.161/~ecovibdc/ECOVIB2D/MYART/processmidpage.php?username=' + username + '&email=' + email + '&Person=' + personname + '&Price=' + Priceofart + '&Graphic=' + picname.replace('w.bmp','.bmp'); CODE document.getElementById('form').action='http://103.226.223.161/~ecovibdc/ECOVIB2D/MYART/processmidpage.php?username=' + <?php echo $_GET['username']?> + '&email=' + <?php echo $_GET['email']?> + '&Person=' + personname + '&Price=' + Priceofart + '&Graphic='+ picname.replace('w.bmp','.bmp'); Here you use PHP $_GET to retrieve 2 query string values, username and email. This means 'ecovib2d1.php' needs the 2 query string values in the URL.Your new version uses only JS variables instead. Why would you attach files that don't match with your current code? |
tudsy |
Aug 20 2017, 04:30 PM
Post
#6
|
Advanced Member Group: Members Posts: 246 Joined: 30-September 14 Member No.: 21,611 |
I have just on question. What do you mean 'username' and 'email' must be inside the query string? document.getElementById('form').action='http://103.226.223.161/~ecovibdc/ECOVIB2D/MYART/processmidpage.php?username=' + username + '&email=' + email + '&Person=' + personname + '&Price=' + Priceofart + '&Graphic=' + picname.replace('w.bmp','.bmp'); CODE document.getElementById('form').action='http://103.226.223.161/~ecovibdc/ECOVIB2D/MYART/processmidpage.php?username=' + <?php echo $_GET['username']?> + '&email=' + <?php echo $_GET['email']?> + '&Person=' + personname + '&Price=' + Priceofart + '&Graphic='+ picname.replace('w.bmp','.bmp'); Here you use PHP $_GET to retrieve 2 query string values, username and email. This means 'ecovib2d1.php' needs the 2 query string values in the URL.Your new version uses only JS variables instead. Why would you attach files that don't match with your current code? Thanks for that. Just an oversight. When I go through the process, the URL for processmidpage.php shows a truncated query string. I have reinstated the original code. Thanks. |
CharlesEF |
Aug 20 2017, 09:01 PM
Post
#7
|
Programming Fanatic Group: Members Posts: 1,981 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
Well, can't you post the URL so I can see how it looks? Also, post new files (the 2 posted before). I want to make sure I'm working with the version as you.
I didn't go over every line of code, I only looked until I found the reason for the error/warning messages you posted in your 1st post. There still could be more errors. |
tudsy |
Aug 20 2017, 10:40 PM
Post
#8
|
Advanced Member Group: Members Posts: 246 Joined: 30-September 14 Member No.: 21,611 |
Well, can't you post the URL so I can see how it looks? Also, post new files (the 2 posted before). I want to make sure I'm working with the version as you. I didn't go over every line of code, I only looked until I found the reason for the error/warning messages you posted in your 1st post. There still could be more errors. Hi Thanks for that. I have attached the latest versions of the 2 files. Thanks Attached File(s) processmidpage.php ( 3.74k ) Number of downloads: 487 ecovib2d1.php ( 9.97k ) Number of downloads: 458 |
CharlesEF |
Aug 20 2017, 10:48 PM
Post
#9
|
Programming Fanatic Group: Members Posts: 1,981 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
You didn't post any URL's. Please post the 'ecovib2d1.php' URL and also post the 'processmidpage.php' URL. I need to see the URL of both pages after they are loaded.
And post any error/warning messages you still get. This post has been edited by CharlesEF: Aug 20 2017, 10:56 PM |
tudsy |
Aug 20 2017, 11:23 PM
Post
#10
|
Advanced Member Group: Members Posts: 246 Joined: 30-September 14 Member No.: 21,611 |
You didn't post any URL's. Please post the 'ecovib2d1.php' URL and also post the 'processmidpage.php' URL. I need to see the URL of both pages after they are loaded. And post any error/warning messages you still get. http://103.226.223.161/~ecovibdc/ECOVIB2D/...T/ecovib2d1.php - when ecovib2d1.php is first loaded. username entered: Adrian Tudini email entered: stg@gmail.com http://103.226.223.161/~ecovibdc/ECOVIB2D/...stg%40gmail.com [21-Aug-2017 04:20:03 UTC] PHP Notice: Undefined index: username in /home/ecovibdc/public_html/ECOVIB2D/MYART/ecovib2d1.php on line 187 [21-Aug-2017 04:20:03 UTC] PHP Notice: Undefined index: email in /home/ecovibdc/public_html/ECOVIB2D/MYART/ecovib2d1.php on line 187 [21-Aug-2017 04:21:39 UTC] PHP Notice: Undefined index: Graphic in /home/ecovibdc/public_html/ECOVIB2D/MYART/processmidpage.php on line 31 [21-Aug-2017 04:21:39 UTC] PHP Notice: Undefined index: Price in /home/ecovibdc/public_html/ECOVIB2D/MYART/processmidpage.php on line 33 [21-Aug-2017 04:21:39 UTC] PHP Notice: Undefined index: Graphic in /home/ecovibdc/public_html/ECOVIB2D/MYART/processmidpage.php on line 137 [21-Aug-2017 04:21:39 UTC] PHP Notice: Undefined index: Price in /home/ecovibdc/public_html/ECOVIB2D/MYART/processmidpage.php on line 138 [21-Aug-2017 04:21:39 UTC] PHP Notice: Undefined index: Person in /home/ecovibdc/public_html/ECOVIB2D/MYART/processmidpage.php on line 139 |
CharlesEF |
Aug 20 2017, 11:38 PM
Post
#11
|
Programming Fanatic Group: Members Posts: 1,981 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
I can't see the entire URL of this:
http://103.226.223.161/~ecovibdc/ECOVIB2D/...stg%40gmail.com Which looks like it might be the URL for 'processmidpage.php'. Is that how your browser shows the URL? Those '...' in the URL are hiding info I need to see. Or are you using the built-in browser in some editor? I need to see the complete URL. Use a real browser. This post has been edited by CharlesEF: Aug 20 2017, 11:41 PM |
pandy |
Aug 21 2017, 02:21 AM
Post
#12
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,730 Joined: 9-August 06 Member No.: 6 |
But it is complete? It's just the forum software that shortens the link text. Look at the status bar (if you are lucky enough to still have one...) or copy the URL.
CODE http://103.226.223.161/~ecovibdc/ECOVIB2D/MYART/ecovib2d1.php http://103.226.223.161/~ecovibdc/ECOVIB2D/MYART/processmidpage.php?username=Adrian+Tudini&email=stg%40gmail.com |
CharlesEF |
Aug 21 2017, 02:10 PM
Post
#13
|
Programming Fanatic Group: Members Posts: 1,981 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
Based on pandy's post (you should have used code blocks for the URL's) I can confirm my idea. But your logic/code is confusing. Take 'ecovib2d1.php', line 187 for example:
CODE document.getElementById('form').action='processmidpage.php?username=' + <?php echo $_GET['username']?> + '&email=' + <?php echo $_GET['email']?> + '&Person=' + personname + '&Price=' + Priceofart + '&Graphic='+ picname.replace('w.bmp','.bmp'); Based on the URL there are no query string values for 'username' and 'email'. Therefore, PHP has nothing to do with it.Questions, where do the values for 'username' and 'email' come from? Are they supposed to be the values from your <form>? Based on your previous post I 'assume' the values should come from the <form>. That means you are trying to set the 'action' attribute of the <form> before the values are filled in. Also, that explains why the 'processmidpage.php' URL only shows 'username' and 'email' query string values (and they are URL encoded, so you have to unencode them before using). My suggestion is that you delete/remove line 187 completely. In your <form> put 'processmidpage.php' in the 'action' attribute. Also, inside the <form>...</form> tags place hidden inputs for any other values you want passed to 'processmidpage.php'. |
CharlesEF |
Aug 21 2017, 02:13 PM
Post
#14
|
Programming Fanatic Group: Members Posts: 1,981 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
But it is complete? It's just the forum software that shortens the link text. Look at the status bar (if you are lucky enough to still have one...) or copy the URL. CODE http://103.226.223.161/~ecovibdc/ECOVIB2D/MYART/ecovib2d1.php http://103.226.223.161/~ecovibdc/ECOVIB2D/MYART/processmidpage.php?username=Adrian+Tudini&email=stg%40gmail.com Thanks pandy, I keep forgetting that the forum software plays tricks. |
tudsy |
Aug 22 2017, 07:44 AM
Post
#15
|
Advanced Member Group: Members Posts: 246 Joined: 30-September 14 Member No.: 21,611 |
But it is complete? It's just the forum software that shortens the link text. Look at the status bar (if you are lucky enough to still have one...) or copy the URL. CODE http://103.226.223.161/~ecovibdc/ECOVIB2D/MYART/ecovib2d1.php http://103.226.223.161/~ecovibdc/ECOVIB2D/MYART/processmidpage.php?username=Adrian+Tudini&email=stg%40gmail.com Thanks pandy, I keep forgetting that the forum software plays tricks. Hi Thanks all. Another question: How do you handle spaces in URLs? I.e. http://103.226.223.161/~ecovibdc/ECOVIB2D/...ib2d%40live.com Space where the + sign is. Thanks. |
CharlesEF |
Aug 22 2017, 10:41 AM
Post
#16
|
Programming Fanatic Group: Members Posts: 1,981 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
I already gave you a hint. I said that the URL was encoded and that you would need to decode them before using. For Javascript look at 'decodeURIComponent'.
|
CharlesEF |
Aug 22 2017, 10:49 PM
Post
#17
|
Programming Fanatic Group: Members Posts: 1,981 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
Oh, sorry I forgot. You want to decode in PHP for use with $_GET. Look into the PHP command 'urldecode'.
|
tudsy |
Aug 23 2017, 06:16 AM
Post
#18
|
Advanced Member Group: Members Posts: 246 Joined: 30-September 14 Member No.: 21,611 |
Oh, sorry I forgot. You want to decode in PHP for use with $_GET. Look into the PHP command 'urldecode'. From the manual: Warning The superglobals $_GET and $_REQUEST are already decoded. Using urldecode() on an element in $_GET or $_REQUEST could have unexpected and dangerous results. Hi Thanks for that. I have created a function in ecovib2d1.php called dec() and it removes the ' ' in the url (username component) and it replaces it with a '%20'. <script> function dec(){ var url = 'http://103.226.223.161/~ecovibdc/ECOVIB2D/MYART/processmidpage.php?Person=personname&Price=priceofart&Graphic=picname&username='; var url1 = <?php echo $_GET['username'] ?> ; // has a space between the first name and last name var url2 = '&email=' + <?php echo $_GET['email'] ?> ; document.getElementById('form').action = url + url1.replace(' ','%20') + url2; }; </script> with the corresponding form as follows: <center> <form id='form' action='processmidpage.php' onsubmit='dec();' method="GET"/> <input type='hidden' id='person' name='Person'/> <input type='hidden' id='Cost' name='Price' /> <input type='hidden' id='pic' name='Graphic'/> <p align='center' id='freename'>Enter Full Name:</p> <p align='center'><input id='Nameofperson' maxlength='50' name='username' size='50' type='text' /></p> <p align='center' id='freeaddress'>Enter Email-Address:</p> <p align='center'><input id='e-address' maxlength='50' name='email' size='50' type='text' /></p> <input type='submit' id="Buy" value='Buy Now'/> </form> </center> Also the javascript code for the hidden input tags(inside function picname() in ecovib2d1.php): document.getElementById('person').value = personname; document.getElementById('Cost').value = Priceofart; document.getElementById('pic').value = picname; A question is what gets executed first the action attribute or the onsubmit button? Maybe we have to split the username into two: first name and last name? Thanks. This post has been edited by tudsy: Aug 23 2017, 06:19 AM Attached File(s) processmidpage__1_.php ( 3.41k ) Number of downloads: 410 ecovib2d1__1_.php ( 10.49k ) Number of downloads: 535 |
CharlesEF |
Aug 23 2017, 10:36 AM
Post
#19
|
Programming Fanatic Group: Members Posts: 1,981 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
I don't use $_GET very often. I didn't know $_GET would unencode query string values.
You seem to have missed the point of my suggestion. Seems you did remove line 187 but you replaced it with this: CODE function dec(){ Using PHP here is wrong. PHP is only active when the page is loading. When the page loads there is no query string values for 'username' and 'email'. And, you can't use $_GET to retrieve values that haven't been entered yet. Forget about building the query string yourself. PHP will do that for you when the form is submitted.var url = 'http://103.226.223.161/~ecovibdc/ECOVIB2D/MYART/processmidpage.php?Person=personname&Price=priceofart&Graphic=picname&username='; var url1 = <?php echo $_GET['username'] ?>; alert(url1); var url2 = '&email=' + <?php echo $_GET['email'] ?>; document.getElementById('form').action = url + url1.replace('+','%20') + url2; This is your current form: CODE <form id='form' action='processmidpage.php' onsubmit='dec();' method="GET"/> Any Javascript that affects 'Person', 'Price' or 'Graphic' values will have to be changed to use these inputs. Remove the function dec(), you don't need it. Be sure to remove the 'onsubmit' event from the form. After you make these changes and load the page again, all you need to do is fill in the username and email then click the submit button.<input type='hidden' id='person' name='Person'/> <input type='hidden' id='Cost' name='Price' /> <input type='hidden' id='pic' name='Graphic'/> <p align='center' id='freename'>Enter Full Name:</p> <p align='center'><input id='Nameofperson' maxlength='50' name='username' size='50' type='text' /></p> <p align='center' id='freeaddress'>Enter Email-Address:</p> <p align='center'><input id='e-address' maxlength='50' name='email' size='50' type='text' /></p> <input type='submit' id="Buy" value='Buy Now'/> </form> When 'processmidpage.php' loads it will have a query string like this: CODE http://103.226.223.161/~ecovibdc/ECOVIB2D/MYART/processmidpage.php?Person=value&Price=value&Graphic=value&username=value&email=value PHP will build the query string for you, based on the fields in between the <form>...</form> tags.This post has been edited by CharlesEF: Aug 23 2017, 10:42 AM |
Lo-Fi Version | Time is now: 18th April 2024 - 10:07 PM |