< ? Php $string ? > Within Html Statements?
I'm trying to reduce my code in html by calling a page.php file which blocks out the html for me. I was having a hell of a time since my html wouldn't parse the php code so in page.php I ended and started php and used regular html in between.
my problem is that I'm trying to use a string to lable my blocks of html (you know .... a links menu < home > < go here > < go there > with the $ string lableling each header area. Everything is parsing except for the $ string name --- so I have lots of nested tables with everything filling except the title of the block, Code:
View Complete Forum Thread with Replies
Related Forum Messages:
Statements In Html Not Getting Parsed
I want to write a simple html-page to get the first step in starting with php: <html> <body> <?php echo "Hello World";?> </body> </html> ... when save it as "test.html", ftp it to my webhoster and open it via a browser, it is not giving any output. First I thought that it would be the webhoster not having php active, but php is included in my hosting package and any .php script is working (they have the infophp.php in my main directory and I recently added a mail.php and both work properly). Code:
View Replies !
Variables Combined With String In SQL Statements
I get this error "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' , , , , , , , , , , , )' at line 1" My sql statement is this: mysql_query("INSERT INTO players (player_id, match_id, kills, deaths) VALUES ('$user_id', ".$_POST['match_id'].",".$_POST['kills$username'].", ".$_POST['deaths$username'].")") or die ('Error adding new player '.mysql_error()); I'm thinking it must be to do with me combining string and variables together. So is ".$_POST['kills$username']." correct?
View Replies !
Mysql Real Escape String() In Conditional Statements
I created the following bit of code that allows me to pass a MySQL conditional statement to a function. I am trying to figure out where and how would I go about incorporating the mysql_real_escape_string() function? Is there a way to call the mysql_real_escape_string() in the function itself? Code:
View Replies !
Remove A Html Tag In A $string
I am parsing a rss. While parsing i am getting some images inside the description. Actually i dont want it. so i try to remove <img tags. $desc = "this is the sample image <img src='image.jpg'> have a look on it"; I need $desc like "this is the sample image <!-- <image src='image.jpg'> --> have a look on it" any help?
View Replies !
HTML-type String
I'm trying to figure out how to take something like this: Code: <TAG name="something" title="first"> And extract the information using Regular Expressions so it is put into a multidimensional array like this: Code: TAG |--- name -> something |--- title -> first Is it possible to do this with one of the PHP preg_* functions?
View Replies !
Replace String Within HTML
We parse our HTML as PHP. All pages within the site are with “.html†extension. We would like to apply additional variable to all internal links within each page. Instead of maintaining manually, we would like to have a script that would automatically: Code:
View Replies !
Find A Html Tag In String
$string=' this is image 1 <img src="www.abc.com/abc.gif"'> and second is <img src="www.df.com/edfg.jpg">; function getAttribs($t, $a, $s) { preg_match_all("/(<".$t." .*?".$a.".*?=.*?")(.*?)(".*?>)/", $s, $m); return $m[2]; } $arr=getAttribs('img', 'src', $string); Here i get all the src of <img> tag.
View Replies !
Html Formatted String To Attachment
I working on an email form that takes user's input converts it into a html formatted page and emails this page as an attachment. I am looking into several mime email classes for php that support this feature. One thing I'm not clear about is whether attachments can be created on the fly or must they be a file on the server before they can be "attached" to the email. for example, can I create an html string stored in a variable and make that string become the attached file for the message? or do I have to first write the html string into a file on the server then create the email header to retreive that file from the server and send it to the user, then go back and delete the temp file?
View Replies !
Mail Html String Longer Than 255
I've got this script that I found on the Internet with which I want to send an email with HTML in it. So I make a string in which I put all my HTML, but that is longer than 255. Is there a blob or something else that I can use ? I need it really bad.
View Replies !
Php File As String Generated To Html
I have a page going on a local server but the pages are going to be hosted on another server, which doesn't support php and MySQL. So basicly have to generate the php files into html files. The pages on the localserver are all based on a template page Main.php?Cat=Home So this is what I'm trying to do. either...open the php template pages in another file then write them as html or...export the php template as html when viewed.So far all I got to see is resource id # 1 Just a little push on the file handling as a string would be much appriciated.
View Replies !
Decode Html Input String
Probably not the correct words in the subject but I'll try to explain. I have software in c++ that sends data to a php file on my website. I have all the connections in place since it echoes back an ok to my code. Problem is the data portion is not being read by the php. I dont know how to reference it. Code:
View Replies !
Removing HTML Tags From String
I have a bit of code that selects data from a MySQL LONGTEXT field. The data will typically contain some HTML tags. The PHP then cuts this down to 100 characters, and adds ".....[more]" as a clickable link at the end which loads a new page containing the complete data. If you like, this will produce a list of snippets of ALL entries in the table and the user can choose which one to read in its entirity. It works brilliantly, but if there are any HTML tags around the 100 character position then random results occur. Well, not random but difficult to calculate. My solution is to strip out these HTML tags using a PHP function, and then cutting the data down to 100 chars. Code:
View Replies !
Grabbing Html Tags Out Of String
I have a string that contains text and html. Basically, I would like to grab the HTML tags from the string and wrap some comment tags around it. Does anyone know how I would do this? I was thinking about using the str_replace function, but this won't work for certain html tags, such as <A href=#"> since the "#" won't be known beforehand. Maybe a simple regular expression?
View Replies !
Converting The Posted String To The Value Of Html Element
I've been very confused in dealing with posted strings. For example, if I fill in a text element with "(double quote), submit it and display it in a text and a textarea, I get "(backslash followed by double quote) in the textarea element but (backslash only) in the text element. Code: <input name="somename" value="<?php if(isset($HTTP_POST_VARS['submitName'])) echo $HTTP_POST_VARS['somename']; ?>" /> I made a function which correct the misbehavings:
View Replies !
PHP String Concatination With Html Select Combo Box
I have problem in PHP String concatination with html select combo box. There are 3 files addressbook.sql : concat1.php concat2.php In concat1.php , if we select User Name in combo box & give input as 3 in text box. It display following output subhash kanade,3 sk@yahoo.com But, it is not display in that way. So, please see that code & tell me correction. addressbook.sql -- Table structure for table `addressbook` -- CREATE TABLE `addressbook` ( `id` int(11) NOT NULL auto_increment, `name` varchar(50) NOT NULL, `email` varchar(50) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ; -- -- Dumping data for table `addressbook` -- INSERT INTO `addressbook` (`id`, `name`, `email`) VALUES (1, 'pramod kumar', 'pk@hotmail.com'), (2, 'vinod wagh', 'vinod@rediff.com'), (3, 'subhash kanade', 'sk@yahoo.com'), (4, 'ketan patil', 'kp@hotmail.com'); concat1.php <?php mysql_connect("localhost","root")or die("Database Failed"); mysql_select_db("pradeep")or die("Failed to Connect Database"); $arr=array("concat(concat(name,','),id)","email"); $str="select ".$arr[0].", ".$arr[1]." from addressbook"; $res=mysql_query($str) or die("resultset error"); echo "<table><tr><th>User</th><th>Email</th></tr>"; while($row=mysql_fetch_array($res)){ echo "<tr><td>".$row[0]."</td><td>".$row[1]."</td></tr>"; }
View Replies !
Regular Expression To Get A Page's HTML Into A String
First wanted to say that PHPBuilder seems like an amazing site to me so far. Until a couple weeks ago I had no idea what PHP was. I recently bought a book and have already learned a decent amount, and am excited by how much PHP has to offer. Anyway, here's my question: I want to get a page's HTML into a string, and then parse the string and return the first expression in standard US dollar form... $(one or more digits).(2 digits) How do I go about doing this with, let's say, this page? That is just an example, it doesn't have to be Amazon.
View Replies !
Improve String Catching Of Html Page
I scripted a prog that extract a string from an html page excluding all the tags. The problem is that it works quite slowly and I wanted to know if somebody of us as an idea how to improve his performance. CODE $start="start_str"; //begin string $end="end_str"; //end string if($snoopy->fetch("http://www.informative.page.com";)) //get the html code { $string=$snoopy->results; //assign to $string all the html string - Hide quoted text - $i=1; $line = explode(" ", $string); //trim the html in lines while ($i<300) { //take only the middle if ($i>230) { //explode the line to control the content $piece = explode(" ", $line[$i]); $k=0; while ($k<200) { //if it content the string that i'm searching... :) if ($piece[$k] == "interesting_part") { $word=preg_split("/[s<>]+/", $line[$i]); //to eliminate html tags $j=1; $flag=0; //to say when print the word //extract the string without html while ($word[$j]) { if ($word[$j] == $begin) $flag = 1; if ($word[$j] == $stop) $flag = 0; if ($flag) echo "$word[$j] "; $j++; } } $k++; } } $i++; } }
View Replies !
Parsing String Of HTML Attributes Into Key/value Pairs?
I'm working on a project that requires a certain "parsing" functionality... Before I set down to coding this myself, I thought I'd ask in the community if anyone already has available a PHP function or routine that can parse a string of HTML-style attributes into key/value pairs? For example, an input string (attribute list) might be something like this, as would be applied to an INPUT tag: type="text" name=firstname size=10 maxlength="20" And the returned result of parsing this string would be something similar to the following array: PHP Code:
View Replies !
Parse String For Urls, But Not Html Links
I've got this function to convert any urls into the proper links for my CMS. However, if I want to put in my own link <a href="http://www.domain.com">A link to domain.com</a> (rather than the basic url www.domain.com), this function really stuff's it up. Code:
View Replies !
Problem Pulling String From Html Form
I made a simple "contact" form for my website. However in place of field names, I'm using strings that contain 12-character randomly generated names. The names re-generate each time the form is accessed. Code:
View Replies !
Removing Html Anchors From POST'ed Text String
I am having problems with trying to remove some tags using PHP. What I want is to perform a search and replace on a URL, so if someone tried to put a URL into a guestbook database, instead of the user inputting a link as: <a href="http://whatever.com">visit me</A> It goes into the database as: http://whatever.com I have tried the str_replace() function, but doesn't seem to work. I have also tried strip_tags() but then that just give the result: This is the code I've written. $AmendedComment = str_replace("<a href="", " ", $_POST['Comment']); $FinalComment = addslashes($AmendedComment); Checking the database and reading it out again, the first part of the URL remains intact, so the URL is clickable - not what I want. I've made an attempt at preg_replace() but it's difficult to get head around trying to write a pattern.
View Replies !
Regular Expressions Gsplit String By Html Tags
I need to split a string by any html tag and get the textparts without the tags but separated by parts so for example: 3 parts = "lorem<br>ispum<li><strong>dolor</strong></li>"; so 1 = lorem ; 2= ipsum; 3 = dolor; or "lorem<br>ipsum<br>dolor"; = also 3 parts like above at this point i get all but not the br Tags ....
View Replies !
HOW: To Exclude Html Special Chars From Encrypted Url Variable String
I am passing the username and password encrypted in my url strings... I have discovered that html special characters should be excluded from the string...specifically the ">" character which when included will display the rest of the encrypted characters as regular printable characters on the web page. Favor 1: Does anyone know which html chars should be excluded? Favor 2: Is there a faster way to check if a character already exists in a string besides substr()?...(this is for looking for a character substitute) Finally : Is there another way to pass parameters opaquely through an href link?
View Replies !
For Statements
i have two values i wish to use in the one for(); Ill make an example below which will make it easier to understand what im trying to do. <?php $value1=100; $value2=100; for($i=0;$i<???;$i++){ $value1=$value1-rand(0,10); $value2=$value2-rand(0,10); echo("Value1isnow$value1,AndValue2isnow$value2"); if($value1<0){???=1;} if($value2<0){???=1;} } The question marks () is the section that im not sure how to do... As i have two values that are 100 but $value1 or $value2 will reach 0 first and i wish it to stop once either have become 0.
View Replies !
Statements
I'm trying to add some data to a MYSQL table UNLESS it sees a duplicate entry for what is entered in the textbox and submit is hit. However it just submits the data anyway despite it being a duplicate. Code:
View Replies !
If Statements With OR
I want to say something like this: PHP Code: <? if($row['status'] == Ƈ' OR ƈ' ){ ?> Is there a way to simple state: if status is equal to 1 or 2, then.
View Replies !
If Statements
can i put an include in an if statement? this is my script: PHP Code: <?php if ( $user['close'] == 1 ) { header( 'location: closed.php' ); } else ( $user['close'] == 0 ) { header( 'location: index2.php' ); } ?> the error i get is:Parse error: syntax error, unexpected '{' in /home/twysted/public_html/game/index.php on line 5 how i would get this to work, i have scripters block at the moment.
View Replies !
IF ELSE Statements
I've search around and can't seem to find any references to it. Is there a way to make IF AND.. statements? Like - If (x=4 AND y=2) { } else if (x=2 AND y=4) { and so on... If not, what would be the best practice way to accomplish something like this?
View Replies !
If Ane Else Statements
Im trying to make it so that when someone goes to my website on the right there will be a login form if they arnt logged in, and if they are, I include a little welcome page. Code:
View Replies !
Else Statements
Normally I'd do something like this.<?php if (Something) { echo "Something..."; } else { echo ""; } ?> Would this work the same? <?php if (Something) { echo "Something..."; } else { } ?>
View Replies !
AND Statements
I have a tricky question. If there is a MySQL query that has Code: WHERE a=1 AND b=1 Will it still go to evaluate "b=1" if it finds "a is not equal to 1" first. If so, the order of WHERE statements can impact performance so I'm trying to find out.
View Replies !
If Then Statements
I'm trying to define several different styles in my web page based on one variable in the query string. So if I have www.mysite.com/index.php?style=1 then I want table cells to be a certain color, links to be a certain color, etc. Obviously style=2 would be a different color scheme. Code:
View Replies !
If Then Else Statements
I need to create a basic page that connects to a database and checks the date for a match, if the date matches, then I need it to display the text that goes along with it, other wise I need it to say a standard message. It's simple in theory and probably simple to code. It's been awhile since I've worked with this and am trying to brush up. This is what I have so far, and know a few parts of it aren't right (just filled some things in, so they weren't blank). Code:
View Replies !
Case Statements
I am fairly new to php and I was wondering if there was something similar to case statements in C++. It would be a lot easier than writing about 20 if statements.
View Replies !
Using Heredoc For SQL Statements
I've used heredocs for single SQL statements without a problem. Also, I've tried this using the SQL form on PhpMyAdmin and it works so I conclude it should work in PHP. Problem: getting syntax error with following SQL statement: $_sql = <<<SQLDOC LOCK TABLES `table_name` WRITE; INSERT INTO `table_name` ('col_a', 'col_b') VALUES ('value_a1', 'value_a2'); INSERT INTO `table_name` ('col_a', 'col_b') VALUES ('value_b1', 'value_b2'); UNLOCK TABLES; SQLDOC; Error Message: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' INSERT INTO `table_name`..."
View Replies !
Parsing SQL Statements
can anyone tell me whether there is a way to get SQL statements parsed. First idea that I could get out of my head is mysql's COMMIT-ROLLBACK syntax. But I am not sure about it. Actually deleting,inserting and redeleting-reinserting seems a bit unnecessary.
View Replies !
Two While Statements Not Working Together?
I have two while statements in a php script. However, the second one is not outputting the way it should. When I test them individually, both work. Can anyone have a look at the code and tell me what I must edit to get both working together. PHP Code:
View Replies !
Echo Statements
I'm trying to change the user password - how? First, the user enters his old password, enter the new password twice. If the old password does'nt match with that of in the table, displays an error message.If the new password entered twice is not the same, also displays an error message. If the old password matches with that of in the table and the new password entered twice is same, then the password is updated.MY CODE ALSO WORKS ABSOLUTELY FINE!!!! But, I've problems in displaying these error messages - Like, 1.If the old password does'nt match with that of in the table,and the newpassword which is entered twice is same, it has to display an error message "Old password is wrong" 2.If the entered old password matches with that of in the table, and the new password which is entered twice does'nt matches, then it has to display an error message "New password does'nt match" 3.If everything goes well, it has to display "Password updated successfully" PHP Code:
View Replies !
Ereg Statements
Is this a good ereg statement? if (!ereg("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]{1,})*.([a-z]{2,}){1}$",$email_1 or $email_2)) { unset($_GET['do']); $message_new = "<font color='#cc0000'>$email_1 or $email_2 is not a valid email address. Please try again.</font>"; include("login_form.php"); exit(); I am just trying to check if the e-mail fields _1 & _2 on the form contain valid characters, without getting to complicated. The form I am using it in keeps returning that I am not entering a valid e-mail address, such "chris.bolton@ntlworld.com", or "chris@myweb.co.uk",or "chris@ntlworld.com" not sure why this is the case?
View Replies !
|