i am having problems passing a variable from a php page to another php page using a hyperlink - get

I had the code working at one time but i changed something and it quit working.
The $id gets passed to the address bar on the browser but not to the next page.
I used the session_start
while($row = mysql_fetch_array($resultd))
{
$id = $row['id_num'];
echo "Edit "; //ln68
echo "<a href='del.php?id_num = $id'>Delete</a>";
echo $row['id_num'] . " " . $row['first_name'] . " " . $row['last_name'] . ", " . $row['title'] . ", " . $row['city'] . ", " . $row['phone_pri'] . ", " . $row['email_addr'];
echo ""; }
The receiving page is not getting the variable. I have used $_SESSION, $_GET, $_POST and nothing seems to work. I have even reversed the values in the href line and still nothing works. I used session_start here also.
this is page 2
$id = $_POST['id_num'];
// send query
$sql = 'delete FROM `delegate` WHERE `id_num`= $id';
Your comments would be most appreciated.

You are using GET request for passing the data via link
but in your second page, you are using POST
change it to $id = $_GET['id_num']; and try
and dont use spaces in href "
change it to "
space will be counted as a character

Related

Add character between column combine in a CSV

I'm looking for the correct syntax to add some (") between my variable.
I need something like that :
"firstname","lastname","email","",""
Here is the first script I have :
foreach($line in Get-Content .\extract.csv)
{ $firstname = $line.split(';')[0]
$lastname = $line.split(';')[1]
$email = $line.split(';')[2]
$newLine = "$firstname - $lastname - $email"
echo $newLine }
I'm really new in scripting and I'm a bit lost with all these (') (")
My second question is : I need to extract my data only from the second row and ignore the first one, can you help me for this too ?
Thanks !
Have you try escaping your " and ' ?
In powershell you can use backtick ` (AltGr + 7) or doubling the char to do so :
Example :
Write-Host(" `" ")
Write-Host(" "" ")
Please add more code if this doesn't solve you issue !

How to concatenate reverse if statement to string?

use DateTime::Format::Natural;
$parser = new DateTime::Format::Natural;
$dt = $parser->parse_datetime("1 Test 2010");
print "Date: " . ($dt->dmy('/') if $parser->success);
Why doesn't the last line compile?
It doesn't compile because that form of if is a statement modifier; it can only be used at the end of a statement, not elsewhere in an expression.
You can do:
print "Date: " . ( $parser->success ? $dt->dmy('/') : '' );
or:
print "Date: " . do { $dt->dmy('/') if $parser->success };
(though the latter will try to print $parser->success if it is false, and it will print "Date: 0" in that case).
Perhaps use the ternary operator here?
print 'Date: ' . ($parser->success ? $dt->dmy('/') : '');
Or split the code into two statements;
print 'Date: ';
print $dt->dmy('/') if $parser->success;

Why does Perl string become undefined?

What is the proper way to concatenate several scalar values into one Perl string?
The following code is deliberately a series of statements for debugging reasons.
my $bill_record;
$bill_record = $acct_no . " |";
$bill_record = $bill_record . defined($w_ptWtrMtrRecRef->{"mtr_addr_no"}) ? $w_ptWtrMtrRecRef->{"mtr_addr_no"} : " " . " |" ;
$bill_record = $bill_record . defined($w_ptWtrMtrRecRef->{"mtr_addr_str"}) ? $w_ptWtrMtrRecRef->{"mtr_addr_str"} : " " . " |" ;
$bill_record = $bill_record . defined($w_ptWtrMtrRecRef->{"mtr_addr_apt"}) ? $w_ptWtrMtrRecRef->{"mtr_addr_apt"} : " " . " |" ;
$bill_record = $bill_record . $issue_date . " |";
The | character is serving as a delimiter. Each line will be '\n terminated.
After the last line $bill_record = $bill_record . $issue_date . " |";
This error appears:
Use of uninitialized value $bill_record in concatenation (.) or string at /home/ics/include/WsBillFunc.pm line 1022.
at /home/ics/include/WsBillFunc.pm line 1022
$issue_date is defined when assigned.
What could be causing $bill_record to become undefined, and what is the proper way to concatenate a bunch of scalar values into one string?
I don't know specifically why $bill_record is undefined. But if I understand what you're trying to do, you're running into a precedence problem: the ?: operator has lower precedence than concatenation ., so that
$bill_record = $bill_record . defined($w_ptWtrMtrRecRef->{"mtr_addr_no"}) ? $w_ptWtrMtrRecRef->{"mtr_addr_no"} : " " . " |" ;
is treated as
$bill_record = ($bill_record . defined($w_ptWtrMtrRecRef->{"mtr_addr_no"})) ? $w_ptWtrMtrRecRef->{"mtr_addr_no"} : (" " . " |") ;
which I suspect is not what you want. Try adding parentheses:
$bill_record = $bill_record . (defined($w_ptWtrMtrRecRef->{"mtr_addr_no"}) ? $w_ptWtrMtrRecRef->{"mtr_addr_no"} : " ") . " |" ;
(Or use .= as another commenter suggested.)
I'd probably do that in one statement with a join:
$bill_record = join ' |',
map( {
defined( $_ ) ? $_ : ' '
} #{ $w_ptWtrMtrRecRef }{ qw( mtr_addr_no mtr_addr_str mtr_addr_apt ) }
),
$issue_date,
'';
In the map I limit with parens because I only want to apply it to the hash slice. After that is the $issue_date and the empty string. That empty string gets the final | you have.
But, for your problem, it looks like you have a precedence problem. One way to see this is to ask Perl to compile then deparse your program to see what it thinks you wanted. The B::Deparse module does this and I use the -p argument to add extra parentheses.
Here's a cut down version of your original program with the added call to the deparser at the top (it's the B::Deparse module but the namespace is O:
#!/usr/bin/perl
use O qw(Deparse -p);
my $b;
$b = $acct_no . " |";
$b = $b . defined($w->{"no"}) ? $w->{"no"} : " " . " |" ;
$b = $b . defined($w->{"str"}) ? $w->{"str"} : " " . " |" ;
$b = $b . defined($w->{"apt"}) ? $w->{"apt"} : " " . " |" ;
$b = $b . $issue_date . " |";
It outputs:
my($b);
($b = ($acct_no . ' |'));
($b = (($b . defined($$w{'no'})) ? $$w{'no'} : ' |'));
($b = (($b . defined($$w{'str'})) ? $$w{'str'} : ' |'));
($b = (($b . defined($$w{'apt'})) ? $$w{'apt'} : ' |'));
($b = (($b . $issue_date) . ' |'));
The key part is the (($b . defined($$w{'no'})). The current value of $b is concatenated with the return value of defined, then the conditional operator (? :) is done. If the test value is true, it returns the first value in the conditional.
When it gets to mgr_apt_no, there are probably many records that don't have that value set. However, the combined value of the previous $b and $$w{'apt'} is defined because $b is not empty. Thus, it chooses the value of $$w{'apt'} to assign to $b. When it does the last line, $b is empty for the concatenation with $issue_date.

Echo text color change?

I am trying to change the color of the text displayed through an echo command on my website. I have tried several different methods posted on here and other forms, and they do change the color... However the variable $session->username shows as that code text on the webpage and not the actual member's user name. I am trying to change only the color of the first line ("Welcome $session->username, you are logged in."). Is there anyway to change the color without loosing the member's displayed name? Here is the code without any color changes to it:
if($session->logged_in){
echo "Welcome <b>$session->username</b>, you are logged in. <br>"
."[My Account] "
."[Edit Account] ";
if($session->isAdmin()){
echo "[Admin Center] ";
}
echo "[Logout]";
}
else{
if($session->logged_in){
echo "<div class='color'> <b>". $session->username."</b>,
you are logged in. </div><br>"
."[<a href=\"userinfo.php?user=".$session->username."\">
My Account</a>] "
."[Edit Account] ";
if($session->isAdmin()){
echo "[Admin Center] ";
}
echo "[Logout]";
}
else{

Explore php man page with manpageview in vim

This feature isn't working like it supposed to work.
Example:
I write substr and I want open man page about substr command but when I hit K (cursor is on substr command) it shows
***warning*** sorry, no manpage exists for <substr>
but when I write
:Man substr.php
it shows substr description properly.
This page details how to open the PHP.net documentation for the keyword under the cursor, using the browser:
function OpenPHPManual(keyword)
let firefox = '/Applications/Firefox.app/Contents/MacOS/firefox-bin'
" you will need to create this profile in firefox
let profile = 'Profile for PHP Manual'
let url = 'http://www.php.net/' . a:keyword
exec '!' . firefox . ' -p "' . profile . '" "' . url . '"'
endfunction
noremap gd :call OpenPHPManual(expand('<cword>'))<CR>
Or, with lynx(1):
function OpenPHPManual(keyword)
let web = 'lynx -accept_all_cookies --cookie_file=/home/jon/.lynx_cookies --cookie_save_file=/home/jon/.lynx_cookies --cookies'
let url = 'http://jp2.php.net/' . a:keyword
exec '!' . web . ' "' . url . '"'
endfunction
You need to nstall the elinks web browser.
See help manpageviewphp for details.

Resources