premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
<table border="0" cellspacing="2" cellpadding="2"> <!-- commented out cause this would not be useful with new version<tr> <th><font face="Arial, Helvetica, sans-serif">Name</font></th> <th><font face="Arial, Helvetica, sans-serif">Phone</font></th> <th><font face="Arial, Helvetica, sans-serif">Mobile</font></th> <th><font face="Arial, Helvetica, sans-serif">Fax</font></th> <th><font face="Arial, Helvetica, sans-serif">E-mail</font></th> <th><font face="Arial, Helvetica, sans-serif">Website</font></th> </tr> --> <?php $i=0; $output = "<tr>"; while ($row = mysql_fetch_assoc($result)) { if (($i%5) == 0) { $output .= "</tr><tr>"; } $output .= <<<OUTPUT <font face="Arial, Helvetica, sans-serif">{$row['first']} {$row['last']}</font><br /> <font face="Arial, Helvetica, sans-serif">{$row['phone']}</font><br /> <font face="Arial, Helvetica, sans-serif">{$row['mobile']}</font><br /> <font face="Arial, Helvetica, sans-serif">{$row['fax']}</font><br /> <font face="Arial, Helvetica, sans-serif"><a href="mailto:{$row['email']}">E-mail</a></font><br /> <font face="Arial, Helvetica, sans-serif"><a href="{$row['web']}">Website</a></font></td> OUTPUT; $i++; } $output .= "</tr>"; // just incase echo "{$output}</table>"; ?> The <<<OUTPUT OUTPUT; is HEREDOC syntax, incase you were wondering. See if the above is what you want.
-
echo nl2br($myrow['text2']); That should be the only line that needs it done, as I assume title does not allow for linebreaks.
-
I do know the table type has to be InnoDB for this functionality. http://dev.mysql.com/doc/refman/5.1/en/innodb.html For usage on creating the tables to link to each other: http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html
-
Well given that output, something is going wrong cause that value is incorrect. Is the column name "logotipo" ? Do some various checks, maybe even a print_r of the retrieved row from mysql to see what is being pulled out.
-
[SOLVED] Error - Bad parameters with PHP Mail funtion - please help
premiso replied to fatmikey's topic in PHP Coding Help
Does the new host require certain headers? I would contact your host and see what is required to get it to work. -
http://en.wikipedia.org/wiki/Join_(SQL) Search for "Inner Join" that explains it fairly well.
-
You only want to use nl2br when displaying content on a page as actual content. To store it, you want it in it's raw form, meaning leaving the \n's there. This goes true for putting it into a textarea for editing, you want the \n's there.
-
Works great on my end, are you using a host that does not fopen_url ? If so, grabbing the data via curl should solve that problem and make it work. Either way, I did test it and it is working great on my box.
-
Is there such thing as a timer or only page refresh time limit?
premiso replied to nutt318's topic in PHP Coding Help
If you set it that when the time is up, it uses location.href to redirect to your logout page which automatically logs them out, yes. If you want a more reliable system, you would need to store a timestamp in the DB of last activity and have a cron job run every minute checking if the activity was more than 5 minutes ago, if so kill the cookies and session which should log them out. -
I highly doubt that, at least on your remote server, try this and see what it spits out: echo 'The file name retrieved from the DB is: ' . $row["logotipo"] . " alternatively, if there is nothing there the DB column is either wrong, or there is no data for this row.<br />"; $logoname = $_SERVER['DOCUMENT_ROOT'] . '/' . $row["logotipo"]; if (file_exists($logoname)) { $fileinfo = substr(sprintf('%o', fileperms($logoname)), -4); if ($fileinfo != "0777") chmod($logoname, "0777"); if (!unlink($logoname)) { echo 'The file ' . $logoname . ' was not erased.<br />'; } }else { echo 'The file does not exist!'; } If that is the case, figure out why you are not getting the correct information out of the DB, do you need to insert a test record, since this record should have been erased each time you ran the script previously?
-
Why do you want 5 records in 1 row? It is possible, but is there a particular reason why? To do it your table headings would no longer be valid, you would have to create 4 more duplicates of your th tags. Explain the reasoning behind it, as I see no logical or reasonable reason why you would want it done this way.
-
For this simple of a deal, ajax would really be over kill. You would look into onClick in Javascript to doing this, alternatively here is a site with some cool JS code that maybe right up your alley. http://www.walterzorn.com/dragdrop/demos/dnd_snapandsort.htm Pretty cool jscript there.
-
Is there such thing as a timer or only page refresh time limit?
premiso replied to nutt318's topic in PHP Coding Help
Javascript can do this for you. When it triggers you make it redirect to the logout page to log them out. -
It sounds like the data from the mysql DB is not coming out right cause $row["logotipo"] is empty. Verify that in MySQL it contains the data needed.
-
<?php $content = file_get_contents('http://www.bbc.co.uk/'); preg_match('~"hpFeatureBoxInt">(.+?)</div>~s', $content, $matches); list($title, $body) = explode("</h3>", $matches[1]); $title = trim(strip_tags($title)); $body = trim(strip_tags($body)); echo "Title: $title <br />"; echo "Body: $body <br />"; die(); ?> First I viewed the source of the BB page you wanted to parse, second I looked for an identifing tag of what you wanted out of that page. I found <div id="hpFeatureBoxInt"> <h2><span class="dy">Top News Story</span></h2> <h3><a href="/go/homepage/i/int/news/world/1/-/news/1/hi/world/africa/7884282.stm"><img width="201" height="150" src="/feedengine/homepage/images/_45468316_84737466_201x150.jpg" alt="Morgan Tsvangirai addresses crowds"/>Zimbabwe PM pledges 'new chapter'</a></h3> <p>Zimbabwe's new Prime Minister Morgan Tsvangirai vows to stabilise the shattered economy and end political violence.</p> <p id="fbilisten"><a href="/go/homepage/i/int/news/heading/-/news/">More from BBC News</a> </p> </div> I did a quick search for "hpFeatureBoxIn"> and did not find any other matches on the page, which means finding that would return the right result. Next I used file_get_contents to retrieve the html source of the website you wanted to parse and put it into a string. I then used that string in preg_match with the regex: [em]'~"hpFeatureBoxInt">(.+?)</div>~s'[/em] which finds the tag and grabs everything being the starting tag and the ending div tag and stored into an array of matches. The match was stored in the "1" index of the array, the "0" index returns what was found with the original tags in tact, so we do not want that one. Next I used explode to separate the match to 2 separate variables, $title and $body. I explode'd it </h3> cause that separated the two. Next I used strip_tags to remove any html tags left and trim the extra whitespaces. Now you have the two items inside strings to display them how you want. Questions let me know.
-
Without a page reload, you will need Javascript to do this. I would suggest looking down that alley, as it seems to be what you want.
-
lol I am sure he wants it done automatically/dynamically. You need to look at the html source, find common tags then use either preg_match or a series of explode's to grab the data. Of course to retrieve the site data you will have to pull in the full page html source with file_get_contents and or curl.
-
How come you have an ending / after dargil.pt ? Where is that coming from....well either way let's try this: $logoname = $_SERVER['DOCUMENT_ROOT'] . '/' . substr($row["logotipo"], 0, -1); if (file_exists($logoname)) { $fileinfo = substr(sprintf('%o', fileperms($logoname)), -4); if ($fileinfo != "0777") chmod($logoname, "0777"); if (!unlink($logoname)) { echo 'The file ' . $logoname . ' was not erased.<br />'; } }else { echo 'The file does not exist!'; } That should remove the ending slash. If the file actually does have that ending slash in it, then the issue is that. Files with ' and / tend to be very picky and can usually only manually be erased. I would suggest you filter your upload file names to remove or not allow those characters. Sorry I did not catch that earlier.
-
Yes, you can. You need an ODBC driver and figure out which connection string is the right one to use. Another Forum topic There is another forum where they had an issue with connecting, which may help you figure out how to connect.
-
The folder, maybe. The file is not. The file itself needs to be "writeable", which right now it is not, to be erased. $logoname = $_SERVER['DOCUMENT_ROOT'] . '/' . $row["logotipo"]; if (file_exists($logoname)) { $fileinfo = substr(sprintf('%o', fileperms($logoname)), -4); if ($fileinfo != "0777") chmod($logoname, "0777"); if (!unlink($logoname)) { echo 'The file ' . $logoname . ' was not erased.<br />'; } }else { echo 'The file does not exist!'; } Give that a try and see if it works.
-
Let's try this now: $logoname = $_SERVER['DOCUMENT_ROOT'] . '/' . $row["logotipo"]; if (file_exists($logoname)) { $fileinfo = substr(sprintf('%o', fileperms($logoname)), -4); echo 'The permissions for the file ' . $logonname . ' are: ' . $fileinfo . '<br />'; if (unlink($logoname)) { echo 'The file ' . $logoname . ' should be erased.<br />'; }else { echo 'The file ' . $logoname . ' was not erased.<br />'; } }else { echo 'The file does not exist!'; } And see what spits out.
-
Page: test.php <?php if (isset($_POST['list']) && is_array($_POST['list'])) { $items = implode(", ", $_POST['list']); echo $items; } ?> <form action="test.php" method="POST"> <select size="4" name="list[]" multiple> <option value="1">Item 1</option> <option value="2">Item 2</option> <option value="3">Item 3</option> <option value="4">Item 4</option> </select> <input type="submit" value="submit" /> </form> Should do it, making the name of the select an array (adding the []) allows for you to post more than one element. Using the implode on that posted item will make it into one line, comma separated.
-
encapsulate $font in the string with {$font} and it will work. The string thinks you are trying to call "$fontpx" is is not a variable. Also note, that if it is 10 to 30, you have a 1 instead of 10 in your rand function.
-
[SOLVED] Authenticate to Password Protected Site
premiso replied to jriggs's topic in PHP Coding Help
curl I believe that is what you are looking for/need to do. -
Alright, lets comment out header(sprintf("Location: %s", $deleteGoTo)); Then re-run the script with the code I gave you. Let's see if anything is displayed. As the script I gave you would not "error out", although it should output something and cause a header error since it does echo information out no matter what. Given that, I do not think you updated the script properly on the site. Either it was uploaded to the wrong spot, or the wrong modified file was uploaded. As this should cause header errors since it outputs data before the header call.