How could have i forgotten ???
push function .. btw for those of you have no clue either
syntax: push(@array_name, $value);
adds another key to the array..
How could have i forgotten ???
push function .. btw for those of you have no clue either
syntax: push(@array_name, $value);
adds another key to the array..
Hi all , just learned the basics of perl thru a website.
and i was just wondering what the perl equivalent of php code ....
for($i = 0; $i < 10; $i++)
{
$myarray[] = $i;
}
would be.
Any help appreciated thank you ..
ahh .. worked .. ahah
thank you .. wow ..
Hi All,
im having difficulty trying to match lets say a string that is between 1 to 3 chars long and are all capitals..
i tried .{1,3}[A-Z] but it didnt work..
for ex.. "blah blahBLAh" ..
what would be the reg ex code to match the BLA in the middle ??
any help would be appreciated. Thanx..
ooh alright thanx
sounds like php is not installed correctly in apache conf .. i think the easiest way to get apache mysql and php to work is to use XAMPP from apache friends .. thats what i use anyway .. if you need help installing the xampp just let me know
i guess if you use the date function to show/insert the date in YYYYMMDDHHMM format with the username .. then subtract the current time again in YYYYMMDDHHMM format from the login date and if the answer is more than 5 mins or whatever you want the users go offline after specific amount of time then delete the user from online users table
Is there a way to allow the php tags with the strip_tags() function ?
i've tried strip_tags($text, '<?>') and strip_tags($text, '<? ?>') but it doesnt work ..
any help would be appreciated thanx ..
Cool . Thanx .. I actuially realized i didnt even need the occurence postion to do that ..
this is what i did from the i dea you gave me ..
<?
$subject = '<a href="http://vids.myspace.com/index.cfm?fuseaction=vids.individual&videoid=35913278">Full Court Shot</a><br/><object width="430px" height="386px"><param name="wmode" value="transparent"/><param name="allowscriptaccess" value="always"/><param name="movie" value="http://lads.myspace.com/videos/vplayer.swf"/><param name="flashvars" value="culture=en-US&a=0&ap=0&y=0&m=35913278&userid=-1&showmenus=0&remove=0&t=&type=video"/><embed src="http://lads.myspace.com/videos/vplayer.swf" width="430" height="386" flashvars="culture=en-US&a=0&ap=0&y=0&m=35913278&userid=-1&showmenus=0&remove=0&t=&type=video" type="application/x-shockwave-flash" allowscriptaccess="always" /></object>';
$pattern = '/\<object.{1,700}\<\/object\>/';
preg_match($pattern, $subject, $matches);
$new_data = preg_split($pattern, $subject);
// print_r($new_data);
$article = htmlspecialchars($new_data[0]) . "<br>\n" . $matches[0][0] . "<br>\n" . htmlspecialchars($new_data[1]);
echo $article;
//
?>
its the closest thing to perfect that i was able to think of .. Thnax
or move line 10 all way to the bottom
if ($result)
echo"Insert record Successfully";
else
echo "Problem inserting data";
you have no braces included with if ...
try this
if ($result) {
echo"Insert record Successfully";
}
else {
echo "Problem inserting data"; }
You can create a nice looking conformation e-mail by using tables ...
is there a way to tell the occurence postition of the regex given ??
for example ..
$text = 'PHP Hypertext Preprocessor';
if (preg_match('xt', $text)){
echo 'Found Match';
}
Like in that example occurence position is 11.. I already know about the strpos() .. but that doesnt accept regex .. .
What im trying to do is take user input form a form and filter it ... convert everything to htmlspecialchars ... but only allow <object > </object> tags , and everything in between to stay intact .. " <object width=""></object>" tags...
Any help would be appreciated.
You could also use
$newtext = nl2br($text);
which has been around since PHP 4 for this purpose.
BTW this problem - if I get it correctly - does not originate from
echo
's behaviour, but rather from HTML, which does ignore all whitespace by default. So you have to substitute all\n
with<br />
in order to have the line breaks in your HTML output, too (e.g. by using yourpreg_replace
solution ornl2br
).Happy coding! :)
Cool thanx man .. peace
nevermind .. preg_Replace did the trick ..
$new_text = preg_replace('[\n]', '<br>', $text);
if there's and easier way it would be nice to know . .thnax anyway
echo removes white spaces from the text and stored text shows up w/o line breaks .. How can i correct this ?
When i view my db tables and contents in it using phpmyadmin, the text stored in them look normal .. the way i typed it .. but when i try to echo or print it out .. it does print the white spaces and everything print out together and confusing ... Is there anyway to correct this. ? Any help would be appreciated ..
nah i just want to make sure that these variables came from the form i have set up and not from someone who is trying to hack their way in ... just another security measurement in a login form
is there any way to get a form name from a page that the post or get variables sent from ?
for example : $_POST , $_POST .. What would it be if you wanted the form name to be sent ?
Try this.
//php.class.php <?php class page { var $title; var $keywords; var $content; function display() { $x="<html>\n<head>"; $x.=$this->displaykeywords(); $x.=$this->displaytitle(); $x.="</head>\n<body>"; $x.=$this->content; $x.='</body>'; $x.='</html>'; return $x; } function displaytitle() { echo '<title>' . $this->title . "</title>\n"; } function displaykeywords() { echo '<meta name="keywords" content="' . $this->title . '">'; } function setcontent($data) { $this->content = $data; //echo $data; } } ?>
And this is index.php
<?php include "page.class.php"; $clan911 = new page(); $data = "<p>Clan 911 </p>"; $clan911->title = 'Clan 911'; $clan911->keywords = 'CLAN 911'; $clan911->setcontent($data); $contents = $clan911->display(); echo $contents; ?>
Works Thanx Alot
Just started practicing classes and boom my first try cant get it to work ... maybe im not seeing something ... can someone look and point out the thing that i might have misssed .. ?any help would be appreciated .. thanx
here's the code :
index.php
<?
include "page.class.php";
$clan911 = new page;
$data = "<p>Clan 911 </p>";
$clan911->title = 'Clan 911';
$clan911->keywords = 'CLAN 911';
$clan911->setcontent($data);
$clan911->display();
?>
page.class.php
<?
class page
{
var $title;
var $keywords;
var $content;
function display()
{
echo "<html>\n<head>";
$this->displaykeywords();
$this->displaytitle();
echo "</head>\n<body>";
$this->content;
echo '</body>';
echo '</html>';
}
function displaytitle()
{
echo '<title>' . $this->title . "</title>\n";
}
function displaykeywords()
{
echo '<meta name="keywords" content="' . $this->title . '">';
}
function setcontent($data)
{
$this->content = $data;
//echo $data;
}
}
?>
It doesnt print out the content.. somehow the function, i think, is not getting the data sent by $clan911->setcontent($data);
this script is from someone else which i have found useful and used it in one of my
Processing Votes
This code should be placed below the database connection, but above the rest of the script.
//We only run this code if the user has just clicked a voting link
if ( $mode=="vote")
{
//If the user has already voted on the particular thing, we do not allow them to vote again $cookie = "Mysite$id";
if(isset($_COOKIE[$cookie]))
{
Echo "Sorry You have already ranked that site <p>";
}
//Otherwise, we set a cooking telling us they have now voted
else
{
$month = 2592000 + time();
setcookie(Mysite.$id, Voted, $month);
//Then we update the voting information by adding 1 to the total votes and adding their vote (1,2,3,etc) to the total rating
mysql_query ("UPDATE vote SET total = total+$voted, votes = votes+1 WHERE id = $id");
Echo "Your vote has been cast <p>";
}
}
The voting links we created in the previous step simply sent us back to the same page passing along the site ID we wanted to vote for and our rating for it.
In order to hinder people spamming the rankings, we place a cookie in their browser before we update the database. If we detect this cookie is already there, the script will not let the user vote again. Otherwise, the information is updated. If …
$query = "select * from table where home_phone like '%516%' OR work_phone like '%516%' OR mobile_phone like '%516%'";
thatnk it worked fine i just had to change OR TO ||
What would be the php mysql code to search more than 1 field in a table ?
Im trying to search for a given partial phone number in all three fields home mobile and work ..
im trying to use
$query = "SELECT `first`, `last`, `home_phone` , `work_phone` , `mobile_phone` FROM `profiles` WHERE LIKE '%516353%'
but this returns everything thats in the table
Any help would be appreciated
if the website that im trying to retrieve has a web browser check code or version check, wouldn't it return an incompatible browser message though ?
Hey my name's izzy and i have been around the web designing game for a while and i was trying to figure out how we can get the explode function to support javascript in a web page when splitting ..
here's the code :
<?
function snp($str_to_look_for, $str_to_stop_at, $html)
{
//echo $str_to_look_for . " " . $str_to_stop_at . " " . $html . "<br>\n";
//Start Reading Our Piece That We Need.
$output = explode($str_to_look_for, $html);
//print_r($output);
$output = $output[1]; // Array index 1 is the part we need it to start reading after.
//Stop Reading.
$output = explode($str_to_stop_at, $output);
//print_r($output);
$output = $output[0]; // Array index 0 is the part we need it to stop reading before which in this case is junk to us.
///// Replacements if needed to match fonts and colors etc. to your site. syntx. 'Search_For', 'Replace_with', $String
//$output = str_replace('<param name="movie" value="', '<param name="movie" value="http://www.flash-game.net/game/2910/', $output);
//$output = str_replace('<embed src="', '<embed src="http://www.flash-game.net/game/2910/', $output);
//echo $output;
return $output;
}
if (!isset($_GET['v']))
{
echo "No results";
exit;
}
$url_to_fetch = $_GET['v'];
$url_to_fetch = 'http://youtube.com/watch?v=' . $url_to_fetch;
//echo $url_to_fetch;
$html = implode('', file($url_to_fetch));
//Regular HTML, user single quotes, and for special characters, use double quotes(for ex. \n or \t etc.
$str_to_look_for = 'type="text" value=\'';
$str_to_stop_at = '\' onClick="javascript';
$player = snp($str_to_look_for, $str_to_stop_at, $html);
echo html_entity_decode($player);
?>
What this does is .. it visits youtube for a videeo that has been sent from other file on my webpage .. say .. …