I am sending two data to my php from my javascript:
http://forum.research.bell-labs.com/zeeshan/publication/phpwithmysql11111.php?rowid=BL09.00001,0
1) BL09.00001
2) 0
How do I recognize them separately in my php?
I was trying to do:
$job=$_GET[rowid];
echo($job);
this gives me both the fields.
Just split $GET['rowid'] on the comma. See:
http://us2.php.net/manual/en/function.explode.php
I'd say you need to name the second parameter as well as the first in your GET request.
Use a URL like this: http://forum...../phpwithmysql11111.php?rowid=BL09.00001&other=1
Then, $_GET['rowid'] should be BL09.00001 and $_GET['other'] should be 1.
Related
I am trying to parse out the middle of the referrer information just to check from where the form submission is coming from.
Consider that the referrer is "https://www.somewebsite.com/someform.php
And what I want to extract is the part between those first two "//" and the next one "/".
I can get the string position, but how can I do a quick piece of code that will just parse out the part I need without several steps?
$ref=strpos($_SERVER['HTTP_REFERER'],'://');
gives me 5 (as the position where the "://" is found.
I want to use something like substr(string,start,length) the part out that is needed to get the pure referrer
the part that says "www.somewebsite.com"
without all the extra lines of code
used it
echo $_SERVER['HTTP_HOST'];
Hi im trying to do a SMS feature for my site. This code works well.
https://www.isms.com.my/isms_send.php?un=xxx&pwd=xxx&dstno=".$number."&msg=".rawurlencode($txt)."&type=1"
Although this code doesn't
https://www.isms.com.my/isms_send.php?un=xxx&pwd=xxx&dstno=".$number."&msg=".$msg."%0A".rawurlencode($txt)."&type=1"
As you can see in the &msg= im trying to send 2 variable but the site tells me there is an error of MISSING PARAMETER. How can I properly input that 2 variable for the same parameter?
I guess you want to send a multi line text message with $msg on the first line and $txt on the second.
As per the sparse documentation the end of line character is %0D instead of %0A.
One other remark: the documenation states that the msg parameter must be url encode, so shouldn't you use rawurlencode($msg) as well.
So, all in all the code should probably look like:
"https://www.isms.com.my/isms_send.php?
un=xxx&
pwd=xxx&
dstno=".$number."&
msg=".rawurlencode($msg)."%0D".rawurlencode($txt)."&
type=1"
Note: I've put it on multiple lines for readability only.
I have different php variables containing data that I want to put in one of the table in mysql database. The problem is I need to put the content in a specific format so another linked to the database can also use it.
I don't know what type of format is this. It doesn't look like JSON
a:1:{i:0;s:27:"my#example.com";}
a:17:{i:0;a:7:{s:2:"id";s:1:"1";s:4:"slug";s:19:"contact-information";s:4:"name";s:19:"Contact Information";s:4:"type";s:8:"fieldset";s:7:"options";s:0:"";s:9:"parent_id";s:1:"0";s:5:"value";s:0:"";}i:1;a:7:{s:2:"id";s:1:"6";s:4:"slug";s:12:"company-name";s:4:"name";s:12:"Company Name";s:4:"type";s:4:"text";s:7:"options";s:0:"";s:9:"parent_id";s:1:"0";s:5:"value";s:20:"Company Name is here";}i:2;a:7:{s:2:"id";s:1:"8";s:4:"slug";s:12:"contact-name";s:4:"name";s:12:"Contact Name";s:4:"type";s:4:"text";s:7:"options";s:0:"";s:9:"parent_id";s:1:"0";s:5:"value";s:8:"Name";}i:3;a:7:{s:2:"id";s:2:"10";s:4:"slug";s:13:"email-address";s:4:"name";s:13:"Email Address";s:4:"type";s:5:"email";s:7:"options";s:0:"";s:9:"parent_id";s:1:"0";s:5:"value";s:26:"example#gmail.com";}i:4;a:7:{s:2:"id";s:2:"12";s:4:"slug";s:15:"website-address";s:4:"name";s:15:"Website Address";s:4:"type";s:3:"url";s:7:"options";s:0:"";s:9:"parent_id";s:1:"0";s:5:"value";s:25:"http://example.com";}i:5;a:7:{s:2:"id";s:2:"15";s:4:"slug";s:13:"contact-phone";s:4:"name";s:13:"Contact Phone";s:4:"type";s:5:"phone";s:7:"options";s:0:"";s:9:"parent_id";s:1:"0";s:5:"value";s:12:"923246573632";}i:6;a:7:{s:2:"id";s:2:"16";s:4:"slug";s:12:"your-address";s:4:"name";s:12:"Your Address";s:4:"type";s:7:"address";s:7:"options";s:0:"";s:9:"parent_id";s:1:"0";s:5:"value";s:91:"House # 2, Street 27<br>Chah Mrain<br>Lahore, Punjab 54000<br>New Zealand";}i:7;a:7:{s:2:"id";s:2:"27";s:4:"slug";s:19:"listing-information";s:4:"name";s:19:"Listing Information";s:4:"type";s:8:"fieldset";s:7:"options";s:0:"";s:9:"parent_id";s:1:"0";s:5:"value";s:0:"";}i:8;a:7:{s:2:"id";s:2:"17";s:4:"slug";s:13:"listing-title";s:4:"name";s:13:"Listing Title";s:4:"type";s:4:"text";s:7:"options";s:0:"";s:9:"parent_id";s:1:"0";s:5:"value";s:17:"House of the Dead";}i:9;a:7:{s:2:"id";s:2:"19";s:4:"slug";s:12:"listing-type";s:4:"name";s:12:"Listing Type";s:4:"type";s:6:"select";s:7:"options";s:90:"a:4:{i:0;s:11:"Attractions";i:1;s:13:"Accommodation";i:2;s:5:"Tours";i:3;s:9:"Transport";}";s:9:"parent_id";s:1:"0";s:5:"value";s:13:"Accommodation";}i:10;a:7:{s:2:"id";s:2:"20";s:4:"slug";s:17:"listings-overview";s:4:"name";s:19:"Listing\'s Overview";s:4:"type";s:8:"textarea";s:7:"options";s:0:"";s:9:"parent_id";s:1:"0";s:5:"value";s:55:"Here is the overview of listing lets check what happens";}i:11;a:7:{s:2:"id";s:2:"21";s:4:"slug";s:10:"logo-image";s:4:"name";s:10:"Logo Image";s:4:"type";s:11:"file-upload";s:7:"options";s:31:"a:1:{i:0;s:13:"png|jpe?g|gif";}";s:9:"parent_id";s:1:"0";s:5:"value";s:80:"http://example.com/connect-icon.png";}i:12;a:7:{s:2:"id";s:2:"25";s:4:"slug";s:9:"longitude";s:4:"name";s:9:"Longitude";s:4:"type";s:4:"text";s:7:"options";s:0:"";s:9:"parent_id";s:1:"0";s:5:"value";s:0:"";}i:13;a:7:{s:2:"id";s:2:"26";s:4:"slug";s:8:"latitude";s:4:"name";s:8:"Latitude";s:4:"type";s:4:"text";s:7:"options";s:0:"";s:9:"parent_id";s:1:"0";s:5:"value";s:0:"";}i:14;a:7:{s:2:"id";s:1:"2";s:4:"slug";s:12:"verification";s:4:"name";s:12:"Verification";s:4:"type";s:12:"verification";s:7:"options";s:0:"";s:9:"parent_id";s:1:"0";s:5:"value";s:0:"";}i:15;a:7:{s:2:"id";s:1:"3";s:4:"slug";s:27:"please-enter-any-two-digits";s:4:"name";s:27:"Please enter any two digits";s:4:"type";s:6:"secret";s:7:"options";s:0:"";s:9:"parent_id";s:1:"2";s:5:"value";s:2:"14";}i:16;a:7:{s:2:"id";s:1:"4";s:4:"slug";s:6:"submit";s:4:"name";s:6:"Submit";s:4:"type";s:6:"submit";s:7:"options";s:0:"";s:9:"parent_id";s:1:"2";s:5:"value";s:0:"";}}
I just want to replace the value that I have in the variables and save it in database.
That format is the result of PHP's serialize() function. You can use unserialize() to decode it.
So I hava a problem. On client side users insert theris data in textbox, radio in textarea. All number of input is stored in hidden type, sove php script on my server side knows how many input does it has. Sometimes there is just 20 inputs, sometimes 25 or 30, so the holl stuf is daynamic.
I have two questions:
1. How on server side dynamic generate variables and use them as $input1, $input2 and os on.
2. Let's say that I have somehow managde first problem so my second question is how to make query which sometimes uses only 20 parameters, sometimes 25 and so on. I don't wanna use arrays and tables;
I stareted php code:
for($i=1;$i<=$num; $i++){ //I get num from a hidden type
${"question".$i}="j";
if(isset($_POST["${"question".$i}"])){
${"question".$i}=$_POST[${"question".$i}];
echo question1; //this doesn't work but I want make created variables
//to use like this
}
else
{
echo "You have error with reading ".$i." question";
}
}
Change echo question1; by echo $question1; (append $ symbol before your var name)
Or in dynamic way:
echo ${"question" . $i}
Why would you like to use the variables like this?
If the input is dynamic use it like an array! -> Easier and cleaner.
There is good example how to handle a dynamic array input: Post array from html to php
I have a file for a calendar made with javascript called calendar_db.js, in it there is this if statment:
if (d_current.getDay() != 3 && d_current.getDay() != 6)
a_class[a_class.length] = 'available';
it checks if the day is not the 3d or the 6th then. So my question is how to make a php mysql query to get those numbers (3 and 6) because I want to change them with mysql databse.
What are your suggestions?
Thank you for your time and help.
The short answer is:
You can't
However, you can use Ajax (Google it) to make calls to an external php file, which will process your request for you. Then, the php file can print out the result, which will send the information back to you.
Take a look here:
http://www.w3schools.com/ajax/default.asp
EDIT:
Read the javascript file by using fopen(), file_get_contents(), or CURL:
http://www.php-mysql-tutorial.com/wikis/php-tutorial/reading-a-remote-file-using-php.aspx
Use some kind of regex to parse the javascript file looking for the particular match of the line with your values. If your javascript file isn't going to change much, it might be easier to just count lines and characters and get the number at exactly some position. This assumes your numbers will always be single digits.
Is this what you're after?
You have to use AJAX to interact with the server via JavaScript.
Since the code to setup an AJAX request is a bit long and tedious, I'll show you how to do it with the jQuery framework.
Basically, just make the server spit the two values out (imagine this being the output of foo.php):
12,19
Now, with AJAX you can read that output. There are two types of requests: GET and POST. If you're familiar with PHP, you can change this according to what your application uses:
var day1, day2;
$.get('foo.php', function(data) {
var split = data.split(',');
day1 = parseInt(split[0]);
day2 = parseInt(split[1]);
});
Now day1 and day2 hold your two dates.