Simple Simple String Question
When I take the input from a textarea and insert it into a mysql-base and then retrieve it and show it, all the line feeds/breaks are gone.
It is shown as one giant string. How can this be fixed, so the text will be shown as it was entered? Does it have something to do with stripslashes/addslashes or am I way off?
View Complete Forum Thread with Replies
Related Forum Messages:
Simple Script For Doing A Simple Photo Album And Journal?
I'm looking to quickly get a photo album online. Very simple, thumbnails, a few pages, maybe a description, but hopefully a small script that's easy to edit and work into my existing site. I know about hot scripts, etc. but I was wondering if any one could recommend one? Secondly, I also want to setup a journal. It's not really a "blog" although I guess blog software may work. But it isn't going to be a message board or anything like that. Just a place to put out random bits of news. Once again, same premise, I'm trying to find the most simple script possible that could basically traverse a directory of simple textfiles and produce a list. I know all about Blosxom and stuff like that, but I'd like a script that just did the above and didn't overtake my site like PHPNuke or something like that. I'll probably roll my own, but I thought I'd check first.
View Replies !
Simple String
Heres my code: Its the result of a simple AJax login form. The problem I am having is with the & sign in the $page variable. Keeps coming up with the following error: "A semi colon character was expected. Error processing resource " Im sure I just need to escape the & sign but not sure how. Code:
View Replies !
Simple String Manipulation
I have the following string: PHP Code: $str = "maryland, virginia, atlanta, new york"; I want to have an array containing each of the coma separated variables as follows: PHP Code: $strArr[0] = "maryland"; $strArr[1] = "virginia"; $strArr[2] = "atlanta"; $strArr[3] = "atlanta"; $strArr[4] = "new york"; I know this is relatively simple string manipulation, but i just cant figure it out. How can i do this?
View Replies !
Simple String Formatting
Suppose I have a string like (98823.43), where the ( and ) signify a negative number. How could I have the string be reformatted to be like <$98,823.43> ? But I would also need it not to add the < and > if the number is 98823.43 for example.
View Replies !
Simple String Replacement
If I have the following array... <?php $parameters = array( 'store="{STORE}"' => '$tags['stores'][{STORE}]', 'for="{QUESTION}"' => 'box_send("{QUESTION}");' ); ?> I would like that from a string, PHP could replace it. For example... $string = 'My string and for="MY STUFF" wohooo!' Is there anyway that from that array PHP would turn this string into: $resulting_string = 'My string and box_send("MY STUFF");' I have been googling and php.net'ing for two days now, and after many attempts and observation of other scripts, I couldn't make it.
View Replies !
Simple Query String Not Passing
I've been messing with PHP for a few months now, and have some basics down. However, I thought I understood this issue, but here I am posting... <heavy sigh>. Two files: register.php which is the form to allow a user to register with the site, and success.php which does the form validation, etc. If invalid input is found, I'm using the code below to go back to the register page. @header("Location: http://url/register.php?id=1"); The id is examined in a switch statement on the register page to generate a message on the register form telling the user exactly what field the problem occurred in. Here's the problem: The id value is not being passed in the redirect. Can anyone tell me what I'm doing wrong?
View Replies !
Variable And String Simple Question
this is my code: <?php $i=1; $g1R=10; $g2R=20; $g3R=30; switch ('$g$iR'): --> this syntax does not work!!! case 10: echo "it worked"; break; default: echo "it did not work"; endswitch;; ?> I define $g{1,2,3}R as variables and I want to use the switch on them with $i setting the value of which one of the three will be used. how do I write the term inside the switch condition?
View Replies !
Simple Question On String Extraction
I'm having to modify a PHP script even though I have little knowledge of PHP itself. The script extracts specific strings from an html file, and I need to it extract some further information. Specifically, each file represents an article written by an author. The author's name is typically preceded by a 'By' or a 'by', then it goes on till there's a carriage return. So for example, the file might contain something like this: The Need For Regeneration by <b>John Smith</b> We have seen the waste that has been produced.... (rest of article) or How To Make Lots and Lots of Money Writing PHP by The Supreme Coder The first thing you need to know about making money is... (rest of article) So I need code that will start searching the file from the beginning for the words 'by ' or 'By ', then grab everything that follows that until it gets to a new line and assign that to a variable. In the examples I have given above, it would grab '<b>John Smith</b>' and 'The Supreme Coder'. I've seen a function called preg_match which might do the job, but it uses regular expressions which I have little knowledge of. Would any person be so kind as to post what arguments I would need to call this function with?
View Replies !
Simple String To Date Question
I have dates like "8/27" or "9/4", and I need to convert them to date objects. When choosing a year, we should go backwards until we find the first match. That is, if the script runs on Jan 1, 2008 and encounters the string "8/27", it should return a date for "8/27/2007". I've been playing around with strtodate and some other functions but I can't figure this out, and as there must be a simple solution I'd like to avoid writing a custom function.
View Replies !
Simple String Manipulation Question
I would like to know how I can take a string that has 2 parts, split them in 2 and then assign a variable for each part. so it would look somthing like this: $string = "hello world"; ......I need to split this string now.... ...and then assign the variables... $first = "hello"; $second = "world"; does anyone know how this works?
View Replies !
Simple Question: Query String Variable And More
suppose i have two html-formatted documents with appropriately coded <?php ?> areas. a typical query is this: file.php?call=123.html in 123.html i define a variable $doctitle How can I display $doctitle in file.php (an html-formatted file as well)
View Replies !
Simple Row
I have this code that doesn't work - all it does is display "5 products returned" i want it to display the 5 records that are in my database - can someone tell me what stupid thing i've done wrong? <?php $query="SELECT * FROM products"; $result = mysql_query($query); $num_results = mysql_num_rows($result); echo "<p>$num_results products returned</p>"; for ($i=0; $i <num_results; $i++) {$row = mysql_fetch_array($result); echo "<p><strong>".($i+1).". ID: "; echo $row["ID"]; echo "</strong><br>Product: "; echo $row["Product"]; echo "<br>Description: "; echo $row["Description"]; echo "<br>image: "; echo $row["Image"]; echo "<br>Cost: "; echo $row["Cost"]; echo "</p>"; }?>
View Replies !
Simple PHP IF, ELSE IF
the levels staff and member have been defined on another page to determine a users access level. What i want to do is pretty obvious, if a staff member has logged in then it shows different content to when a member is logged in, and if nobody has logged in, it shows a generic login message. <?php if ($_SESSION['level'] == "staff") { ?> <p><b>Welcome staff member <br /> <a href="../chooseupdate.php"> <?php echo $_SESSION['username']; ?> </a> you're logged in.</b> <? } elseif ($_SESSION['level'] == "member") { ?> <p><b>Welcome user member <br /> <a href="../memberspage.php"> <?php echo $_SESSION['username']; ?> </a> you're logged in.</b> <? } else { ?> <p><b>You are not Logged in!</b> <a href="../login.php">Log in</a> to check your messages.<br /> Do you want to <a href="../login.php">Log in</a> or <a href="../register.php">register</a>?</p> <? } ?> Now when i add to this a page, i get the error "Parse error: parse error, unexpected $end" Happens with this one aswell <?php if ($_SESSION['loginFlag'] == 1) { ?> <p>Would you like to log-out? <a href="../log-out.php">Log-out</a> </p> <? } else { ?> <p>Please <a href="../login.php" class="style2" accesskey="6"><strong>[6]</strong>Sign in</a> or <a href="../register.php" class="style2" accesskey="7"><strong>[7]</strong>Register</a></p><? } ?> Now, I'm positive this worked on my colleges server, so it's got me thinking that maybe my php.ini file is messed up? Because this is also happening with my log-out file also, which is; <? // you must start session before destroying it session_start(); session_destroy(); sleep(1); header( 'Location: login.php' ) ; ?> On my college server it works perfectly, at home it just loads the log-out.php page and doesn't redirect back to login.php, it also doesn't destroy the session.# My php.ini is basically the default one, i got with WAMP. Except i enabled the header command to be used. Thanks in advance.
View Replies !
Simple If/else
I know, it's sad, but I can't figure it out for the life of me. The update works if you comment out the insert statement; if you comment out the update, the insert statement works. If you combine both, then only update works. I know it's with the if/else (or the actual placement/naming of the query), but I can't figure out where to place it. Â Â Â Â Â <input type="hidden" name="submitted" value="TRUE" /> Â Â Â Â <div align="center"><input type="submit" name="submit" value="Submit" /> Â Â <? ob_start(); session_start(); include ('./marketing/includes/post.php'); $date = date('m.d.Y'); if (isset($_POST['submitted'])) { //Handle form if(empty($_POST['name'])) { echo '<br /><i>Please insert an artist name. </i>'; ......................
View Replies !
Simple Bit Of PHP - HELP!
I have a site for use by some freinds, its basically a privacy proxy,but I want it to be password protected and have to get them to agree to terms and conditions. I have an index.php page in a subdomain, that has a short list of terms and conditions. I want them to have to check a box to say they agree & then also enter just a password to continue. It doesn't need to be secure. The password can be one for all. It would be good if it was all contained in the one Index file. Then when both the tick box and checkbox is checked it takes you onto a difficult domain that can't be remembered. Does that make sense? It would be good if a pop up said that you need to agree to the terms if the check box is not checked and a different message is a password is not entered or is incorrect.
View Replies !
Get Localhost - Very Simple
This is a very simple question I think, but I can't find a straight answer from the php documentation. What is the function or variable that I can use to get localhost information?
View Replies !
Simple Script
what i am doing is when a user goes to mysite and let's say that he is looking for a friend. Then he selects gender,country,age(selections). I have three categories to choose. Whatever a user select, the results comes from my database. If the results are 10 datas, it is 2pages. That's what I am trying to do but I got an error. PHP Code:
View Replies !
Simple Mark-up For CMS
I'm designing/coding a content management system in PHP and am currently considering how the users will add textual content. I would like them to be able to use some kind of simple mark-up, like a very limited subset of HTML, probably with a more friendly naming scheme. Does anybody have experience of such a thing? I'm thinking an XML application is the proper answer but when I consider the DTD and parser it seems like an overkill solution if I'm starting from scratch. Does anybody have any advice or suggestions on this? I'm sure it's been done before but I don't know where to look, is there something existing I can use or adapt? Has anybody tried this kind of thing before?
View Replies !
Simple URLs
I want to have a lot of control over my short urls. My site has guitar lessons and articles and I want to have short urls of the form: mysite.com/guitarlessons-scalelesson.html The original url is of the form: mysite/modules.php?op=modload&name=mainlessons&file=index&req=view_fulllesson&lessonid=8 In this case $lessonid 8 refers to scalelesson. All short URL examples I have seen take the original URL and directly translate it. In may case, the short URL scheme would have to query the database. I would like my forum to function similarly. That is, forum posts and forum pages would have forum category and post title in the short URL. Anyone know how to do advacned simple URLs of this sort? I really like how this forum does short urls actually. I can't imagine this is done with mod_rewrite() since the simple urls appear to be generated dynamically based on database calls.
View Replies !
Simple Redirect?
I've been searching through the forum, and the only solution offered for redirecting to another page seems to be this: header("Location: http://www.thispage.com "); Apparently, this doesn't work if it is not in the absolute beginning of the page. My question is the following: Isn't there a more simple command in PHP to tell this simple thing:"Go to this or that page now!".
View Replies !
Simple AJAX Example
Several times some members even me post for simple AJAX example with PHP. Some of experts will give URL of tutorial. Now with this attachment I send my simple test of AJAX +PHP with the help of w3schools. There is no alternative to study good tutorial but this simple example may give the fell of AJAX ...
View Replies !
Some Simple Security
I want to be able to add some simple security to one of my pages, basically my page allows users to submit a text field which gets parsed into MySQL db and displayed on other pages. At the moment anyone can submit text which opens the page to abuse. I don't want to implement a user login system. I had envisaged the addition of a password entry box which the Submit button checks against the db before proceeding, so if any user has the correct password then they can submit. Having never done password stuff before, could somebody please point me in the right direction? Also, if I have the config data to connect to the mysql db in a PHP file on my server, can anybody just open it?
View Replies !
Simple If Statement
How come this doesn't work? What am I doing wrong? $type = $_GET['functionType']; if ($type == 'Add'){ $AddSQL = "INSERT INTO..."; echo $AddSQL; }elseif ($type == 'Update'){ $UpdateSQL = "Update ..."; echo $UpdateSQL; }elseif ($type == 'Delete'){ $DelSQL = "DELETE FROM ..."; echo $DelSQL; }
View Replies !
Simple Opt-in Script?
I'm looking for a most simple but save opt-in mailing list script in php (linux Apache CGI, but shouldn't matter) best: * all in one single .php file; different functions by input vars / passwords; config vars on top of script * uses MySQL or a plain file (still no doubles) next to the .php (best both options) * double opt-in not necessary but nice * good would be "default topic" and at least up to 5 different lists/topic * takes directly my web forms like email=...&listname=...&sign=in ; repsonse page can be very simple. * I can read out the lists plain formatted also by web through the same ..php & password like: cmd=getlist&listname=...&password=... * hopefully no extreme installation tricks (thus php4, ..) looking at more than 10x google'd ones, always something was wrong, big or jerky or not as is should be...
View Replies !
Simple Parser In PHP?
I'm coming to the end of a large and exhausting project, done in my new favorite language PHP, and its time for a diversion. I'm wondering if anyone has experience with writing simple parsers. I've never done it myself, but I know they are not as mysterious as they may seem, it's a matter of finding the tools. The idea is to take something like CSS format, except that it allows nesting, and turn it into associative arrays, such as: anykey { property: value; property: value; nestedkey { property: value; property: value; } } could be processed by a command like: <?php $parsed = ParseMyFile(...) ?> and $parsed would hold the same as if we'd done this: $arr = array( anykey("property"=>"value",...
View Replies !
Simple Include
I have an include file called "my_inc_file.php" located in a subdirectly called "inc_files". I have a file both in my root directory, and in another subdirectory called "subdir", that uses the include file. My include is called in a template common to both, so has to have the exact same file structure. My local pc uses Windows, and my remote server uses Linux. How can I change my include statement so it works for both cases and both operating systems? include_once '/inc_files/my_inc_file.php'
View Replies !
Simple Counter
After a process opened, read and unlocked the counter.txt, some other process would open, read and even write its own count value. So the first process will write a count value less than the right value. And I guess it needs more exception handling codes. Code:
View Replies !
Simple Search
I 'm developing a site consisting of 5-10 html/php pages. I want to add a simple keyword search in my site. I can't seem to find any simple script, except risearch which can't search my Greek pages (el_GR.UTF-8).
View Replies !
Simple Stuff
i am really getting confused with php's curly brackets ok how do i assign a variable and then assign a value to it from a form parameter send to it..like below if i dont add the @ then i get errors, so how do i assign a value to $actionvar, and if $actionvar is empty then condition ? If (@$actionvar =="") { echo ("<b><FONT COLOR=#804040>Rates in RM</b></font><br><br>");} else{ echo ("<b><FONT COLOR=#804040>Converted to $cname</b></font><br><br>");}?> when i doing somthing like this: <?php if ($wed =="") {$wed =="not selected"}?> it is giving me error in the last "}" why ?
View Replies !
Simple XML Parser
I am trying to write a simple XML parser with PHP. What would be the best way to assign the string/text stored in between <TAG> … and … </TAG> to a variable? The 'content' between the XML tags can have multiple lines and may contain other html tags.
View Replies !
Simple Date
i just want to automatically add a date field to a mysql database everytime an entry is made. the date wont even be used, its just for my reference. i was wondering if i have to do this through php when i submit the other variables to any new table row....or if there is a command to do it in mysql.
View Replies !
Simple Calender
I am developing a very simple calendar that displays links to classes that fall within a given month. To have the page display the current month's classes, I have used: PHP Code:
View Replies !
Simple Ereg Help
I need two ereg expressions in my PHP code. One of them needs to check that a string only contains letters, and the other needs to check that the string only contains letters and commas (only one comma at each time). I thought that the code for only containing letters would be: eregi("^([a-z])", $keywords); But this only appears to be checking the first character. I also have no idea how to do the one that also allows commas (though not for lack of trying - believe me!) So, basically, I want one expression that only lets in letters: ie. hyasdlhlasdhl but not fhdilfd7800asdads;' and one expression that only lets in letters and commas (one at a time): ie. hasiaks,asdas,adsads but not hdasl,,ahodsa,ads
View Replies !
Simple $variable
I'm trying to fill in a form to insert info into a database. There are two fields to be filled out - one for the root of a thumbnail image, and one for the root of a full-size image. Since the names of the files are always the same, I would like to only fill out one text field in the form and have the code do the rest. Code:
View Replies !
Simple Idea For ERP - Please Help
I'm starting project.First stage is for my school work, but i want to develop it to the end. I want to create a ERP based on php for small company's I want to use as many as possible created opensource applications. First i need to choose some framework, maybye someone think that php is not a good idea..I'm waiting for propositions:) I need to add to this framework some graphic database manager. If it possible for all databases, but I did't found any ..I want to start with postgres and mysql., maybye firebird. Second I have to add soe functionality witch is needed for company worker, mayby webmail,small cms for documents... I also need to add sometching for making automatic documentation.(phpdocumentor ?) Thats the first stage.I need it in the short time :( Second i will be developing modules for all departments in small and medium company. More details on the webpage(i'm designing it ) and next posts..
View Replies !
Simple Test
Why does this test as not true. if (!1==2) echo 'true' else echo 'nottrue' It seems like it should be true.
View Replies !
Simple Question !
I want to know how many entries there is in a table : is there a simple function to do that ? By the way, does anyone know how to make an autorun on a CD rom, so that when the CD is inserted, it opens the user's internet browser (in full screen if possible).
View Replies !
Simple Php Problem...
I've just started learning some stuff about php and have been following a couple of tutorials. At the moment I'm stuck with this small piece of code which gives me an error "mysql_fetch_array():supplied argument is not a valid MySql result" <?php include 'config.php' include 'opendb.php' $query="SELECT cname, csubject, cmessage FROM contact"; $result=mysql_query($query); while($row= mysql_fetch_array($result,MYSQL_ASSOC)) { echo "Name :{$row['cname']} <br>" . "Subject : {$row['csubject']} <br>" . "Message : {$row['cmessage']} <br><br>"; } include 'closedb.php' ?> This should just display the content of a table..
View Replies !
Simple Php Queston
I have a multi select pick list in an html <FORM ACTION="/progs/read.php" METHOD="POST" target="_blank">^M <label for="CATEGORIES">Select one or more categories</label>^M <SELECT MULTIPLE name="CATEGORIES" size="10" id="CATEGORIES" class="select"> <option value="41">Auto Manufacturers</option> <option value="27">Biodiesel</option> <option value="38">Component Suppliers</option> <option value="39">Conversion Companies</option> <option value="40">Dealers</option> <option value="28">Electricity</option> </select> in read.php i try to read the value by: $categories=htmlspecialchars($_POST['CATEGORIES']); then try to print out the value and all I get is the last value. I tried to put in an array like: $categories=array($_POST['CATEGORIES']); and still got the same result.
View Replies !
Simple Sql Join
This is a simple join but I am having trouble with it. I feel like such an idiot. I start with this select statement, which works fine: $query = "SELECT a.auction, a.winner, b.id FROM PHPAUCTIONXL_winners a, PHPAUCTIONXL_auctions b WHERE a.auction=b.id"; Now I only want the results from auctions with ids that are not listed in the 'archived' field of the PHPAUCTIONXL_archived table. So I added another table and an AND to the SELECT statement. Now I don't understand why it doesn't show the auctions which are not archived. $query = "SELECT a.auction, a.winner, b.id FROM PHPAUCTIONXL_winners a, PHPAUCTIONXL_auctions b, PHPAUCTIONXL_archived c WHERE a.auction=b.id AND a.auction !=c.archived";
View Replies !
An AJAX Simple Example For PHP
An AJAX Simple Example for PHP Article from http://www.joyistar.com Introduction: AJAX WebShop 3 Beta2 supports PHP programming by integrating PHP5 development environment. Here we will give an simple example to show you how to develop web applications by PHP in AJAX WebShop. 1, Notice We will use Access database in this example. Of course, you can use others you like. Database name: demo.mdb; Table name: product; Fields: PRODUCT_ID, PRODUCT_NAME, PRODUCT_PRICE and PRODUCT_AREA. 2, Example Start AJAX WebShop 3 to new a project by "File->New Project" Give a project name in the popup window and select the web server as PHP. New a PHP Service by "File->New .PHP Service" and input the required content. Select the "ServiceType" as "Query Data". Click "OK", WebShop will generate codes automatically. Input the codes below(Notice: demo.mdb should be the same directory with the source code files.): $connstr = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=".realpath($_SERVER['PATH_TRANSLATED'])."demo.mdb"; $sql = "select * from product"; $sqlcount = "select count(*) from product"; The source code of testquery.php£º 1.Fill data to $xmlRequest in columns: //fill metadata fields for ($i=1; $i<=$fields_count; $i++) { $fieldname = odbc_field_name($result_id, $i); $datatype = odbc_field_type($result_id, $i); $xmlRequest->addField($fieldname, $datatype); } 2. Fill data to $xmlRequest in rows£º //fill data rows for ($i=0; $i<$record_count; $i++) { odbc_fetch_row($result_id); if($i>=$recNo && $i<$recNo+$maxRows) { $xmlRequest->append(); for ($j=1; $j<=$fields_count; $j++) { $xmlRequest->setValueByIndex($j-1, odbc_result($result_id, $j)); } } if($i>=$recNo+$maxRows) break; } 3£®Get the paged parameters, $xmlRequest->recNo is the first record, $xmlRequest->maxRows is the total records number in a page and to get the total records number by executing "select count(*) from product"£º $sqlcount = "select count(*) from product"; $result_id = @odbc_do($connid, $sqlcount); if($result_id==null) throw new Exception($sqlcount); odbc_fetch_row($result_id); $record_count = odbc_result($result_id,1); $xmlRequest->setRecordCount($record_count); $recNo = $xmlRequest->recNo; $maxRows = $xmlRequest->maxRows; if($maxRows==-1) $maxRows = $record_count; After the steps above, we need a web page to display the result. Select "File-New Page" and fill the file name.
View Replies !
>> With A Simple PHP Script
I am sure this will be a no-brainer for a lot of you. Put quite simply, I am looking for a way do a search within a string for all of my HTML tags. Once it finds those HTML tags, I will like to wrap some code around it. For example: <p /> ----> <![CDATA[ <p /> ]]> <b /> ----> <![CDATA[ <b /> ]]> <a href="someurl.html"> ----> <![CDATA[ <a href="someurl.html"> ]]>
View Replies !
Simple POST?
Using PHP, what is the simplest and most reliable way to POST variable data to a URL? This is for data that do not need to be secure.
View Replies !
Simple Arrays
I'm trying to learn php, since it seems to be more efficent than perl. Could someone show me how I can simply print out every element of an array, with a newline between each element?
View Replies !
Simple Spider
I reposted this from "Regex within PHP" because I feel this is a PHP lproblem not Regex. And what I am trying to do is start at a pre-defined page, find all the links on that page and run the spider on all of the pages that were found, and return the results from those pages that were spidered. Code:
View Replies !
A Simple IF Condition.
I have a simple IF condition to check whether an entered town name for a search actually exists in the database. The form search produces $townsearch The check should return "Cannot Find The Town" if $townsearch does not correspond to a recognised townname in the database. The database is correct, and the SQL query OK. So why can I type anything in and it accepts it? (Day 4 of learning PHP) <?php $townsearch = $_GET['town']; ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get"> <input type="text" name="town" size="20" value="<?php echo $townsearch; ?>" /> <input type="submit" value="GO" /> <?php $check = @mysql_query ("SELECT townname FROM site01_towns WHERE townname='$townsearch'"); if (!$check) { echo '<p>Cannot Find The Town</p>' exit(); } ?>
View Replies !
Simple Blog
Do you know anyway I can make a very simple blog eg a script for writing to the mysql and a script for reading from it?
View Replies !
GD Error. Simple Fix?
So im working on a dynamic signature script, by pulling halo 3 stats off bungie.net and applying them to an image and cacheing the image. Code:
View Replies !
Simple Array
Running some queries and get an array returned that looks like this: Array ( => Array ( [max] => 4 ) ) Just wondering how to access '4'. Been trying simple echo commands (echo $maxID; echo $maxID[0]; echo $maxID[1]; echo $maxID['max']; but cant get anything. Obviously its something stupid im not realizing, just need a shove in the right direction.
View Replies !
|