dreamwest
Members-
Posts
1,223 -
Joined
-
Last visited
Never
Everything posted by dreamwest
-
I get an error when i try this 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 'DISTINCT title from table where (title like '%search icon%') order by title' at line 1 I need to select over 20 columns so i cant keep naming each one SELECT DISTINCT title, colname1, colname2, etc FROM table WHERE title LIKE '%{$search_id}%'
-
Yes works perfectly. Images are cached and instantly load. It must be your browser
-
Im trying to select distinct title from a column but also need to select all columns Heres what ive originally got, this has duplicates in title column: $sql = "SELECT * from table where (title like '%{$search_id}%') "; If i select distinct info from the other columns wont get selected: $sql = "SELECT DISTINCT title from table where (title like '%{$search_id}%') "; How can i select distince titles and also select all coumns with distinct titles in one query
-
Dont refreash your browser it will clear the cache and reload everything again. Just surf your site normally through hyperlinks Example: http://site.com/image_page.html > http://site.com/no_image_page.html > http://site.com/image_page.html When revisiting the 1st url all your images will load instantly
-
Dont include htaccess files, im not sure if you can anyway. If you put htacces in your root directory of your site: http://site.com/.htaccess and have htaccess enabled then something else is going on I definately works ive been using it for 2 years Make sure the htaccess file has no extensions as well
-
You cant access htaccess files with your browser. If you refreash you browser the images will reload again. Trying surfing you site a bit the images should appear instantly
-
did you put .htaccess in root directory? http://site.com/.htaccess If you did - check your browser to allow caching from sites. Most browser have caching on by default
-
No. chuck it in .htaccess You can also cache files as well # 5 MIN <FilesMatch "\.(css|js|swf|flv)$"> Header set Cache-Control "max-age=172800, private, proxy-revalidate" </FilesMatch> It will dramatically increase your speed
-
Sweet thanks! I used !=
-
# 1 WEEK <FilesMatch "\.(jpg|jpeg|gif|ico|png)$"> Header set Cache-Control "max-age=604800, public" </FilesMatch>
-
Awesome. Works well Can this be adjusted to remove subdomains like this: http://subdomain.sitename.com/dir/A/02/?extras=MTM0MjQ6Mzo2,0,0,0,194
-
Im trying to display a website url without the supplied subdirectories and http:// Example url: http://sitename.com/dir/A/02/?extras=MTM0MjQ6Mzo2,0,0,0,194 What i need: sitename
-
i cant figure out how to select "is not sumthing" ive tried: $result = mysql_query("SELECT id FROM video WHERE user_id NOT '1'") or die(mysql_error()); and $result = mysql_query("SELECT id FROM video WHERE user_id IS NOT '1' ") or die(mysql_error());
-
how can i select mlore than 1 option from a dropdown list? <select name="menu" > <option selected>Select</option> <option value="one">one</option> <option value="two">two</option> etc.... </select>
-
If your after speed - Whatever you gain would be lost connecting to multiple databases Unless you have millions of queries an hour i wouldnt worry about it. Your better of caching content and compressing data to reduce server load: #increase speed and preserve bandwidth <ifmodule mod_php4.c> php_value zlib.output_compression 16386 </ifmodule> # 1 WEEK <FilesMatch "\.(jpg|jpeg|gif|ico|png)$"> Header set Cache-Control "max-age=604800, public" </FilesMatch> # 5 MIN <FilesMatch "\.(css|js|swf|flv)$"> Header set Cache-Control "max-age=172800, private, proxy-revalidate" </FilesMatch>
-
Does the comments table have the user name/id as well Table "comments" with columns: comments | userid Use a join to ....join the tables // Construct our join query $query = "SELECT user.*, comments.* ". "FROM user, comments ". "WHERE user.userid = comments.userid"; $result = mysql_query($query) or die(mysql_error()); // Print out the contents of each row into a table while($row = mysql_fetch_array($result)){ echo $row['user']. " - ". $row['comment']; echo "<br />"; } If not you cant associate the comment with the user. The only solution would be to add the comments within users table, or add the user id to the comments table...then join
-
I finally work a way to do this. SELECT all rows and tables and write that data to a file. <?php $mysql_host='localhost'; $mysql_database='name'; $mysql_username='user'; $mysql_password='pass'; $storing_dir = ""; $file_name = $mysql_database."_".date('YmdHis').".sql"; $link = mysql_connect($mysql_host, $mysql_username, $mysql_password); if (!$link) { fwrite($fh, 'Could not connect: ' . mysql_error()); exit(); } $db_selected = mysql_select_db($mysql_database, $link); if (!$db_selected) { fwrite($fh, 'Can\'t use $mysql_database : ' . mysql_error()); exit(); } $myFile = $storing_dir . $file_name; $fh = fopen($myFile, 'w') or die("can't open file"); _mysqldump($mysql_database); fclose($fh); function _mysqldump($mysql_database) { global $fh; _mysqldump_schema_structure($mysql_database); $sql="show tables;"; $result= mysql_query($sql); if( $result) { while( $row= mysql_fetch_row($result)) { _mysqldump_table_structure($row[0]); _mysqldump_table_data($row[0]); } } else { $content = "/* no tables in $mysql_database */\n"; fwrite($fh, $content); } mysql_free_result($result); } function _mysqldump_schema_structure($schema) { global $fh; fwrite($fh, "/* database : `$schema` */\n"); $sql="show create schema `$schema`; "; $result=mysql_query($sql); if( $result) { if($row= mysql_fetch_assoc($result)) { fwrite($fh, $row['Create Database'].";\n\n"); } } fwrite($fh, "USE `$schema`; \n\n"); mysql_free_result($result); } function _mysqldump_table_structure($table) { global $fh; fwrite($fh, "/* Table structure for table `$table` */\n"); fwrite($fh, "DROP TABLE IF EXISTS `$table`;\n\n"); $sql="show create table `$table`; "; $result=mysql_query($sql); if( $result) { if($row= mysql_fetch_assoc($result)) { fwrite($fh, $row['Create Table'].";\n\n"); } } mysql_free_result($result); } function _mysqldump_table_data($table) { global $fh; $sql="select * from `$table`;"; $result=mysql_query($sql); if( $result) { $num_rows= mysql_num_rows($result); $num_fields= mysql_num_fields($result); if( $num_rows > 0) { fwrite($fh, "/* dumping data for table `$table` */\n"); $field_type=array(); $i=0; while( $i < $num_fields) { $meta= mysql_fetch_field($result, $i); array_push($field_type, $meta->type); $i++; } //print_r( $field_type); fwrite($fh, "insert into `$table` values\n"); $index=0; while( $row= mysql_fetch_row($result)) { fwrite($fh, "("); for( $i=0; $i < $num_fields; $i++) { if( is_null( $row[$i])) fwrite($fh, "null"); else { switch( $field_type[$i]) { case 'int': fwrite($fh, $row[$i]); break; case 'string': case 'blob' : default: fwrite($fh, "'".mysql_real_escape_string($row[$i])."'"); } } if( $i < $num_fields-1) fwrite($fh, ","); } fwrite($fh, ")"); if( $index < $num_rows-1) fwrite($fh, ","); else fwrite($fh, ";"); fwrite($fh, "\n"); $index++; } } } mysql_free_result($result); fwrite($fh, "\n"); } ?>
-
Well, yeah, if you're doing a linear search then it will obviously potentially take longer time finding what you're looking for with a larger problem size. How are you doing the search? Search is query driven. Pulls the file name from the database then gets the file based on the name
-
I have over 30,000 videos in one directory. I certainly cant use an ftp client to open the directory, so i cant tell if there are any hacker files in there. What is the safe amount of file to load into one directory? Does it slow down the server if it has to scan the entire directory to find the one file?
-
Ahh sweet. Ive done this stuff before using DTD feeds
-
Thanks. Was the rand thing i didnt know about $text[0] = 1; $text[1] = 2; $text[2] = 3; $text[3] = 4; $text[4] = 5; // etc. echo $text[rand(0, 4)];
-
What is a simple way of by using php to create a random number based on a array, i can do this with javascript but i need to convert it to php: Javascript random array: <SCRIPT LANGUAGE="Javascript"> function text() { }; text = new text(); number = 0; // textArray text[number++] = "3894" text[number++] = "2236" text[number++] = "4976" // keep adding items here... increment = Math.floor(Math.random() * number); document.write(text[increment]); //--></SCRIPT>
-
I want to build a simple API for my site so other ppl can display my content on there sites. Just like yahoo and youtube have. The question is ...where do i start?? Is it just a simple php script to retrieve data like an rss??
-
I dont know how to set this up. Also i dont have shell access if this is needed I searched for a couple of hours and found a sql query (INTO OUTFILE) that might do it , but i think its missing something cause it wont work: //Usually localhost $host = "host"; //Database Username $username = "user"; //Database Password $dbpass = "pass"; //Database Name $dbname = "name"; //Connect to DB. mysql_connect("$host", "$username", "$dbpass") or die(mysql_error()); mysql_select_db("$dbname") or die(mysql_error()); $tableName = 'Everton_Park'; $backupFile = 'Everton_Park.sql'; $query = "SELECT * INTO OUTFILE '$backupFile' FROM $tableName"; $result = mysql_query($query); echo "All Done!!"; Ive set the permissions of this file to 777 and the directory to 777, and placed it here: http://site.com/backups/backup.php
-
Woops - i didnt notice the AS total. I figured it out Thanks