dreamwest
Members-
Posts
1,223 -
Joined
-
Last visited
Never
Everything posted by dreamwest
-
!somehow! work out when the last line will be I need the written file to be line by line so i cant remove it completley
-
Im writing to a file but this put a blank line at the end, the reason why is because of r\n which is like<br> in html. $current .= $buffer."r\n"; //has over 1000 lines file_put_contents($save_as, $current); How can i get rid of this blank line at the end of the file??
-
this is my first go at file open and write. I need to delete a file on a specific line: This file contains lines like something|something something| something|something something|something So a error will script will output "ERROR on line 2 - something|" $handle = @fopen("1.txt", "r"); if ($handle) { $count = 1; while (!feof($handle)) { $buffer = trim(fgets($handle, 4096)); //echo $buffer."<br>"; $check = explode('|', $buffer); if ($check[1] == "" || $check[1] == " " ){ echo "ERROR on line {$count} - {$buffer}<br>"; } $count = $count +1; } fclose($handle); } Now all i need to do is delete that whole line from the file
-
Your right
-
Thank you so much, this is exactly what I was looking for! How would I list them without the array information? For example, make it say this: user1, user2, user3 This is more flexible: foreach ($matches[1] as $value) { echo $value; // add anything you want in front of or after }
-
Is this quicker than CURL or the same speed/resources??
-
[SOLVED] PHP MYSQL How To Page Break After 2 Rows
dreamwest replied to kirisutegomen's topic in PHP Coding Help
$result = mysql_query( "select stuff"); while ( $record = mysql_fetch_assoc( $result ) ){ $counter = 0; echo $row['id']; if($counter == 2){ echo "Stopped!"; break; } $counter = $counter + 1; } -
mysql_query( "UPDATE `table` SET download = download + 1 WHERE id = 'your id here' ");
-
Your right. My way was getting a little buggy so i tried yours and it works. Thanks!
-
Finally figured it out # provide a universal error document RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /404.php?url=$1 [L] The just use $_GET in 404.php
-
Im interested in seeing what theyre after, itll give me some insite on how to better secure the site Over the last 5 mins ive had 5 different ips trying to access restricted files, i dont want to ban them yet i want to spy on them and see what they do
-
Almost what im looking for.. Im trying to track ppl trying to hack my site I have this in htaccess: ErrorDocument 404 /404.php , so whenever someone tries to guess urls: http://site.com/admin/something.php it will automatically go to http://site.com/404.php. But $_SERVER['HTTP_REFERER']; isnt working for this.
-
How can i get the current url without being referred from another page. I can get a referred url : $_SERVER['REMOTE_ADDR'] But if i just typed in the url in the address bar : http://site.com/url.php, how can i echo this url out
-
Im trying to create a unique field, but when i test it and try to insert a duplicate row i get a error error: Duplicate entry 'test' for key 2 Is there a way i can test the string "test" to see if its unique before inserting it??
-
Thanks, but it goes to 100, some searches only need to 2 pages, not all have 100 pages, the ones that dont have 100 pages just loop continuously until they get to 100. Yeah what i meant to say was - Your stuffed without a total . You need to be getting $content_count = ????????; which is the total amount of items from somewhere
-
$content_count = 1000; $page = $_GET['page']; $tpage = ceil( $content_count / 10 ); $startfrom = ( $page - 1 ) * 10; $prev = $page - 1; $next = $page + 1; $adjust = 9; if ( 1 < $page ) { $page_links .= "<a href='".$prev."'><< Prev</a><a href='1'>1</a>...."; } $k = $page - $adjust; for ( $page ; $k <= $page + $adjust; ++$k ) { if (( 0 < $k ) && ( $k <= $tpage ) ) { if(($page)==($k)){ $page_links.="<span> ".$k." </span>"; } else { $page_links .= "<a href='".$k."'>{$k}</a>"; } } } if ( $page < $tpage ) { $page_links .= ".....<a href='".$tpage."'>".$tpage."</a><a href='".$next."'>Next >></a>"; } echo $page_links; Your stuffed with a total
-
If your table looks like this: 1 table for users: userID(auto increment) username password.... 1 table for items id (auto increment) userID item desc image.... 1 table for userItems id (auto increment) userID itemID Then the query will be: $user = 2; $results = mysql_query("SELECT * FROM users AS u, item as i WHERE u.userID = '{user]' and u.userID = i.userID "); Think of userID as your anchor to other tables
-
Your going to end up with a thousand queries if the user has a thousand items $results = mysql_query("SELECT * FROM users AS u, item as i WHERE u.ID = i.ID "); echo "xml=<?xml version=\"1.0\"?>"; echo "<items>"; while($line = mysql_fetch_assoc($results)){ echo "<val>". $line["ID"] . "</val>"; echo "<val>". $line["item"] . "</val>"; echo "<val>". $line["image"] . "</val>"; } echo "</items >"; Of couse thats assuming ID relates to the actual user and not auto increment I would have it like this 1 table for users: userID(auto increment) username password.... 1 table for items id (auto increment) userID item desc image.... 1 table for userItems id (auto increment) userID itemID
-
Yeah i know - you should see my compiled code, some pages are over 2000 lines. But regardless of this and the extra requests i bet you saw a decrease in frontend page loading time I went from having 10+ second loading times to < 1 second +- 0.5 seconds - thats what gets me excited Ill look into this...Im sure they wouldnt allow this bug
-
Have 1 table to store all users info Theres no benefit to having multiple tables if theyre on the same machine - and its easier to have them in one spot
-
If wikipedia says it is - it is http://en.wikipedia.org/wiki/Avant_Browser It doesnt make sense - ive tested normal code against smarty. My pages load within 1 second with smarty and has over 800 lines (formatted) of code. Smarty is slower without compile check because every time a page is viewed it checks to see if the file has been modified. So once youve finished designing the site use $smarty->compile_check = false; before displaying the templates and wella like magic So instead of running this all the time: <?php require './mysqltable_init.php'; echo '<h1>PHP Freaks Tutorials</h1>'; while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo '<div class="tutorial" id="tut-' . $row['content_id'] . '">' . '<h2>' . htmlentities($row['title']) . '</h2>' . '<small>' . date('F j, Y, H:i', strtotime($row['created_at'])) . '</small>' . '<div class="summary">' . htmlentities($row['summary']) . '</div>' . '<a href="' . htmlentities($row['permalink']) . '">Read more</a>' . '</div>'; } It only compiling the php page : <?php $db = new PDO('mysql:host=localhost;dbname=test', 'root', '******'); $stmt = $db->query('SELECT content_id, title, permalink, summary, created_at FROM content ORDER BY created_at DESC'); because the template is already compiled Dont belive me? I dare you to try it in a real application, generate the template first by going to the php page then any further requests by anyone will be SUPA fast
-
Can you add this just under new Smarty and do the test again, im interested at seeing how fast this speeds it up: $smarty = new Smarty; $smarty->compile_check = false;
-
Lately i have been able to increase my sites performance with smarty by well over 500%. I can build apps in a fraction of the time than traditional scripting and enjoy the performance, i can assign a simple query: while ($row = mysql_fetch_assoc( $result )){ $show_content[] = $row; } $smarty->assign( 'show_content', $show_content ); and pull bits and pieces out separating content and code {$show_content[i].field} Its all so simple and flexible - I lov it! I think this can go in my hall of fame for best apps 1. BING 2. Smarty 3. Avant browser
-
It just looks better. Having if($_COOKIE['snap']== "on" ) $snap = "on"; looks wrong. But having { is like having a border around the code to easily see the blocks if($_COOKIE['snap']== "on" ){ $snap = "on"; }
-
[SOLVED] Select only Rows with distinct values applying to 1 column
dreamwest replied to rmelino's topic in MySQL Help
$result = mysql_query("SELECT distinct * FROM table group by name"); while ($row = mysql_fetch_assoc($result)){ echo " <tr> <td>{$row['name']}</td> <td>{$row['city]}</td> <td>{$row['state']}</td> </tr>";