|
-
Need help with SELECT syntax.
Date: 08/23/05
(MySQL Communtiy) Keywords: mysql, database, sql
Okay, I have a dilemma.
I'm not sure how to assemble a SELECT query for what I want to do.
I have a database of ratings for books and movies. Each rating/review is placed into a new row, with a reference number for the item they're related to (actual books and movies are in their own table). and I wish to run a SELECT that will find rating entries for books that have a minimum of 5 entries (ie; 5 rows).
I'm somewhat of a newcomer to mysql, but I'm not a complete moron. I've been able to set up long and complex query strings, but for some reason, this is befuddling me.
Any ideas?
** EDIT **
Problem solved, thanks to timeimp & bobalien
The resulting query ended up being:
$query = "SELECT book_reviews.bookid AS idofbook, avg(book_reviews.rating) " $query .= "AS nrating, books.bookname AS nameofbook FROM book_reviews,books " $query .= "WHERE books.id = book_reviews.bookid GROUP BY book_reviews.bookid " $query .= "HAVING count(book_reviews.rating) >= 5 ORDER BY nrating DESC LIMIT 10";
Source: http://www.livejournal.com/community/mysql/67126.html
-
How to Determine if your Sensitive Data is Safe in Shared Hosting
Date: 08/26/05
(Java Web) Keywords: mysql, sql, security, web, hosting
One of the strong security concerns in shared hosting environments is whether your sensitive data like MySQL server login/password or other login/password is actually safe from other users sharing the same web hosting machine.
Few shared hosting providers do not provide telnet/ssh. They are normally more secure. However I would not recommend them for two [...]
Source: http://blog.taragana.com/index.php/archive/how-to-determine-if-your-sensitive-data-is-safe-in-shared-hosting/
-
php, mysql search engine
Date: 09/07/05
(MySQL Communtiy) Keywords: cms, php, mysql, html, sql
Ok, I’m trying to make a nice little search script for my CMS. The whole site is in the db, and I would like to have a way for people to be able to search all the content. Each entry in the db has an id, name, title, description and body. They may all contain html. now I would like to run a query that looks through all the fields (except the id) and pulls out all those that match, then display them in a table (I assume a while loop is fie for this). So what I'm really looking for is an sql query that will search all the fields. Now I would also like it to recognise boolean searches if this is possible.
Ok, I’m sure you get the idea by now. Does anyone know how this might be achieved? Please note, my php knowledge is about a year old and my mysql is very poor. I have also been through mysql docs (mainly this page, but have found it s little beyond me).
Thanks for any help
x-posted to php
Source: http://www.livejournal.com/community/mysql/68021.html
-
zip codes
Date: 09/07/05
(MySQL Communtiy) Keywords: php, mysql, html, database, sql
i'm doing a project where i need to measure distances between zip codes; en route to a solution i stumbled upon a couple of handy resources that i figured i'd pass along:
http://www.zend.com/codex.php?id=1486&single=1 a class used to do various zipcode calculations such as distance and finding the zip codes within range of another zip code take a look at the class to see how he wants your tables and fields named for the state and zip code database tables
http://www.cfdynamics.com/cfdynamics/zipbase/index.cfm zipbase - datbase of zip codes with lat & long info, state info, etc. available in a text file and an access datbase i used the textfile and in mysql said: mysql> LOAD DATA LOCAL INFILE 'c:/ZIP_CODES.txt' -> INTO TABLE zip_code -> FIELDS TERMINATED BY ',' ENCLOSED BY '"' -> LINES TERMINATED BY '\r\n';
http://27.org/isocountrylist/usps_states_list.sql SQL file for creating a states table (i believe in the zipcode class, he wants the states table called "state")
i used that to make a silly little app to test some of the features of the class:
$zip){
$field = 'zip'.($key+1);
if(isset($_REQUEST[$field])){
if(is_numeric($_REQUEST[$field])){
$zips[$key] = $_REQUEST[$field];
}
}
}
?>
foreach($zips as $key => $zip){
if($zip){
echo " ";
echo "$zip:";
$details = $zc->get_zip_details($zip);
if(!empty($details)){
foreach($details as $key => $value){
echo "- $key: $value
";
}
}
echo " ";
}
}
?>
if($zips[0] && $zips[1]){
echo "Distance: ".$zc->get_distance($zips[0], $zips[1]);
}
?>
oh, and i found this http://centricle.com/tools/html-entities/ to convert app code into HTML special chars
crossposted in php mysql & bobalien
Source: http://www.livejournal.com/community/mysql/67585.html
-
php, mysql search engine
Date: 09/07/05
(PHP Community) Keywords: cms, php, mysql, html, sql
Ok, I’m trying to make a nice little search script for my CMS. The whole site is in the db, and I would like to have a way for people to be able to search all the content. Each entry in the db has an id, name, title, description and body. They may all contain html. now I would like to run a query that looks through all the fields (except the id) and pulls out all those that match, then display them in a table (I assume a while loop is fie for this). So what I'm really looking for is an sql query that will search all the fields. Now I would also like it to recognise boolean searches if this is possible.
Ok, I’m sure you get the idea by now. Does anyone know how this might be achieved? Please note, my php knowledge is about a year old and my mysql is very poor. I have also been through mysql docs (mainly this page, but have found it s little beyond me).
Thanks for any help
x-posted to mysql
Source: http://www.livejournal.com/community/php/341853.html
-
zip codes
Date: 09/07/05
(PHP Community) Keywords: php, mysql, html, database, sql
i'm doing a project where i need to measure distances between zip codes; en route to a solution i stumbled upon a couple of handy resources that i figured i'd pass along:
http://www.zend.com/codex.php?id=1486&single=1 a class used to do various zipcode calculations such as distance and finding the zip codes within range of another zip code take a look at the class to see how he wants your tables and fields named for the state and zip code database tables
http://www.cfdynamics.com/cfdynamics/zipbase/index.cfm zipbase - datbase of zip codes with lat & long info, state info, etc. available in a text file and an access datbase i used the textfile and in mysql said: mysql> LOAD DATA LOCAL INFILE 'c:/ZIP_CODES.txt' -> INTO TABLE zip_code -> FIELDS TERMINATED BY ',' ENCLOSED BY '"' -> LINES TERMINATED BY '\r\n';
http://27.org/isocountrylist/usps_states_list.sql SQL file for creating a states table (i believe in the zipcode class, he wants the states table called "state")
i used that to make a silly little app to test some of the features of the class:
$zip){
$field = 'zip'.($key+1);
if(isset($_REQUEST[$field])){
if(is_numeric($_REQUEST[$field])){
$zips[$key] = $_REQUEST[$field];
}
}
}
?>
foreach($zips as $key => $zip){
if($zip){
echo " ";
echo "$zip:";
$details = $zc->get_zip_details($zip);
if(!empty($details)){
foreach($details as $key => $value){
echo "- $key: $value
";
}
}
echo " ";
}
}
?>
if($zips[0] && $zips[1]){
echo "Distance: ".$zc->get_distance($zips[0], $zips[1]);
}
?>
oh, and i found this http://centricle.com/tools/html-entities/ to convert app code into HTML special chars
crossposted in php mysql & bobalien
Source: http://www.livejournal.com/community/php/341574.html
-
MSSQL scares me
Date: 09/08/05
(SQL Server) Keywords: mysql, database, sql, postgresql, web, linux, microsoft
(my background) Using MySQL and PostgreSQL on FreeBSD and Linux machines (the problem) I have four databases (actually MDF and LDF files) from a client. They want to know if they can extract data from the four databases by year and place them in to individual databases. This sounds ok, but I am new to Microsoft's SQL server. I sacrificed one of my personal dev machines and installed 2k3 Enterprise and 2000 SQL server. Created new databases with the same name as the files and then replaced the new files with the original ones from the client. Super. Now what?
Again my background is in the command line/web front end so I am running a little blind. What is the simplest way to see the data in each database? What are some _quality_ sites I can read (because googling information you have no idea about takes time to filter out the bs).
Source: http://www.livejournal.com/community/sqlserver/33194.html
-
gmui/php probs
Date: 09/09/05
(Computer Geeks) Keywords: php, mysql, sql, apache
I'm having trouble getting gmui to work properly. I have MySQL and Apache2 running fine behind it, but I just get this:
Warning: displaysite(/var/www/localhost/gmui/./themes/default/template.php): failed to open stream: No such file or directory in /var/www/localhost/htdocs/gmui/class/Core.php on line 369
EDIT: This is Line 369: require_once($this->gmui_dir.$this->subDirs['theme_dir'].$_SESSION['user']->theme."/template.php");
* @author Don Seiler */ class Core {
/* * The version of GMUI */ var $version;
/* * Array containing settings for GMUI from conf.php */ var $settings = array();
/* * Array containing all CORE_OP * where the page refresh should enabled */ var $pageRefresh = array("vd", "servers", "upl");
/* * all available GMUI panels which are optional when mldonkey is running/off * */ var $clientUpPanels = array("vd" => "Downloads", "s" =>"Search", "dllink" => "Links", "upl" => "Uploads", "upstats" => "Statistics", "servers" => "Servers", "shares" => "Shares",// "vfr" => "Friends", "cmd" => "Console", "opt" => "Client Options", "uopt" => "User Options", "umanage" => "Users", "gmanage" => "Groups", "other" => "Other", "inc" => "Incoming", "kill" => "Kill Client", "logout" => "Logout");
var $clientDownPanels = array("umanage" => "Users", "gmanage" => "Groups", "other" => "Other", "uopt" => "User Options", "inc" => "Incoming", "start" => "Start Client", "logout" => "Logout");
/* * GMUIs subdirectories */ var $subDirs = array( "conf_dir" => "./conf/", "lang_dir" => "./lang/", "theme_dir" => "./themes/", "client_dir" => "./client/", "bin_dir" => "./bin/", "lib_dir" => "./lib/"); /* * GMUIs priority mapping */ var $priorities = array(); /* * reload id */ var $refreshed = FALSE; /* * client stat */ var $alive;
/* * settings from conf.php * */ var $gmui_dir; var $gmui_http;
var $client_basedir; var $client_startup; var $client_incoming; var $min_page_refresh; var $data_sync_time; var $use_javascript; var $allow_http_download; var $allow_http_upload; var $max_upload_size; var $make_commit_script; var $use_hard_links; var $include_incoming_size; var $max_displayed_sources; var $max_displayed_names; var $content_src; var $use_http_auth; var $use_db; var $sqlite_db_file;
var $mysql_user; var $mysql_passwd; var $mysql_host; var $mysql_db; /* * use php file functions, workaround for file too big errors */ var $use_php_ff;
/** * Constructor for Core class * * Loads all settings and initializes what is needed. */ function Core() { $this->loadSettings(); $this->checkSettings(); } /* * hack to use settings during Core Object is created */ function postInit() { $this->setVersion(); $this->setInterface(); $this->setDataBase(); $this->setPriorities(); } function setPriorities() { $this->priorities = array( "-20" => _("Very Low"), "-10" => _("Low"), "0" => _("None (priority)"), "10" => _("High"), "20" => _("Very High") ); } /** * Get database wrapper Object * * @author Moritz Warning */ function setDataBase() { require($this->subDirs['conf_dir']."config.php"); if($use_db == "sqlite") { $_SESSION['db'] = new SQLite($sqlite_db_file); } elseif ($this->use_db == "mysql") { $_SESSION['db'] = new MySQL($mysql_user, $mysql_passwd, $mysql_host, $mysql_db); } else exit(''._("No valid database type selected!")." \n"); } /** * Get Interface Objekt to get data from MLDonkey * * @author Moritz Warning */ function setInterface() { require($this->subDirs['conf_dir']."config.php"); $_SESSION['interface'] = new MLD_Interface($client_host, $client_port, $client_user, $client_passwd); $_SESSION['interface']->postInit(); }
/** * Grabs version from VERSION file * * @author Don Seiler */ function setVersion() { if (file_exists("./VERSION")) { $lines = file("./VERSION"); $this->version = $lines[0]; } else { exit(''._("Version File not found!")." \n"); } }
/** * Return available languages. * * @author Moritz Warning */ function getLanguages() { return getDirs($this->subDirs['lang_dir']); }
/** * Return available themes * * @author Moritz Warning */ function getThemes() { return getDirs($this->subDirs['theme_dir']); }
/** * Loads core settings into $this->settings array * * @author Moritz Warning */ function loadSettings() { $conf_file = $this->subDirs['conf_dir']."config.php"; if (!file_exists($conf_file)) { exit(''."Required file conf/config.php not found!"." \n"); } require($conf_file); //check for optional $gmui_dir in conf.php if(!isset($gmui_dir)) { $this->gmui_dir = dirname($_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"]).DIRECTORY_SEPARATOR; } else { $this->gmui_dir = $gmui_dir; } //check for optional $gmui_http in conf.php if(!isset($gmui_http)) { $this->gmui_http = dirname("http://".$_SERVER["SERVER_ADDR"].":".$_SERVER["SERVER_PORT"].$_SERVER["PHP_SELF"]).DIRECTORY_SEPARATOR; } else { $this->gmui_http = $gmui_http; } //needed settings in ./conf/conf.php $this->client_basedir = $client_basedir; $this->client_startup = $client_startup; $this->client_incoming = $client_incoming; $this->data_sync_time = $data_sync_time; $this->min_page_refresh = $min_page_refresh; $this->use_javascript = $use_javascript; $this->allow_http_download = $allow_http_download; $this->allow_http_upload = $allow_http_upload; $this->max_upload_size = $max_upload_size; $this->make_commit_script = $make_commit_script; $this->chmod = $chmod; $this->use_hard_links = $use_hard_links; $this->include_incoming_size = $include_incoming_size; $this->max_displayed_sources = $max_displayed_sources; $this->max_displayed_names = $max_displayed_names; $this->content_src = $content_src; $this->use_http_auth = $use_http_auth; $this->use_db = $use_db; $this->use_php_ff = $use_php_ff; //other settings, depend on others if($use_db == "sqlite") { $this->sqlite_db_file = $sqlite_db_file; } elseif($use_db == "mysql") { $this->mysql_user = $mysql_user; $this->mysql_passwd = $mysql_passwd; $this->mysql_host = $mysql_host; $this->mysql_db = $mysql_db; } } function checkSettings() { $check_settings = array( 'client_basedir', 'client_startup', 'client_incoming', 'min_page_refresh', 'data_sync_time', 'use_javascript', 'allow_http_download', 'allow_http_upload', 'max_upload_size', 'make_commit_script', 'use_hard_links', 'include_incoming_size', 'max_displayed_sources', 'max_displayed_names', //'content_src', this may be empty b y purpose 'use_http_auth', 'use_db' ); foreach ($check_settings as $setting) { $value = $this->{$setting}; if (is_null($value) or $value === "") { $missingsettings[] = $setting; } } if(count($missingsettings) > 0) { $errorstring = "\nConfig file incomplete. The following values are missing: \n\n"; foreach ($missingsettings as $setting) { $errorstring .= "- $setting
\n"; } $errorstring .= " \n\n"; $errorstring .= "If you have recently upgraded, please check config.php.sample for any new settings.\n"; exit($errorstring); } } /** * Lets you know if a menu item is currently active * * @author CJ Kucera */ function isMenuActive($menu) { return ($_SESSION["active"] == $menu); }
/** * Returns a list of available menu items, for themes * * @author Moritz Warning */ function getMenu() { $menu = array(); $panels = array(); if($this->alive) { $panels = $this->clientUpPanels; } else { $panels = $this->clientDownPanels; } foreach($_SESSION['user']->titlebar as $id) { if(isset($panels[$id])) { $menu[] = new MenuItem($id, _($panels[$id]), $this->isMenuActive($id)); } } return $menu; }
/* * this function print the entire site using getSite() in themes/template.php * * Moritz Warning */ function displaySite() { $this->setConstants(); $this->setAlive(); $this->setLanguage(); $this->setTimeMark(); //update users downloads and settings if($this->timemark) { $_SESSION['user']->refill_settings(); $_SESSION['user']->refill_downloads(); } require_once($this->gmui_dir.$this->subDirs['theme_dir'].$_SESSION['user']->theme."/template.php"); echo getSite(); //getSite is part of the theme //reset text variables $_SESSION['title'] = ""; $_SESSION['message'] = ""; $_SESSION['headline'] = ""; exit(); } //$this->subDirs /* * set constants * * Moritz Warning */ function setConstants() { define("NL", "\n"); define("BN", " \n"); define("BBN", "
\n"); } /* * set alive status of the client * * Moritz Warning */ function setAlive() { $this->alive = $_SESSION['interface']->alive(); }
/* * set gettext variables * * Moritz Warning */ function setLanguage() { $lang = $_SESSION['user']->lang; if($lang == "en") { setlocale(LC_ALL, 'en_US'); } else { setlocale(LC_ALL, $lang."_".strtoupper($lang)); } putenv("LANG=".$lang); bindtextdomain('messages', $this->subDirs['lang_dir']); textdomain('messages'); }
/* * set $this->timemark every $data_sync_time seconds (set in config.php) * * Moritz Warning */ function setTimeMark() { $this->timemark = FALSE; if(!isset($_SESSION['last_time_check']) OR (time() - $_SESSION['last_time_check']) > $this->data_sync_time) { $_SESSION['last_time_check'] = time(); $this->timemark = TRUE; } }
/** * Reads $_REQUEST var and takes appropriate action * * @author Don Seiler * @author Moritz Warning */ function getBody() { $core_op = $_REQUEST["CORE_OP"];
if(!$this->alive) { $_SESSION['was_dead'] = TRUE; }
list($prefix,$suffix) = explode("_", $core_op); //set CORE_OP if it is not valid if(!$_SESSION['user']->allow_show_Menu($prefix)) { if(!empty($core_op)) { $core_op = ""; $prefix = ""; } elseif($this->alive AND $_SESSION['user']->allow_show_Menu("vd")) { $core_op = "vd"; //default is CORE_OP when not set and "vd" allowed $prefix = "vd"; } } $_REQUEST["CORE_OP"] = $core_op; //reset core_op because other programms use it $this->dbCare(); //select availabel panels $panels = array(); if($this->alive) { $panels = $this->clientUpPanels; } else { $panels = $this->clientDownPanels; } if(function_exists($core_op)) { $_SESSION["title"] = "Web-GMUI: ".$panels[$prefix]; $_SESSION["active"] = $prefix; $content = call_user_func($core_op); } else { $_SESSION["title"] = "Web-GMUI: "._("Welcome"); $_SESSION["active"] = ""; $content = ""; } return $content; } /* * dbCare check if mlnet was restarted and initiate an auto reassignment program (verify_db) * * Moritz Warning */ function dbCare() { $restarted = FALSE; if($this->alive AND $_SESSION['was_dead']) { $restarted = TRUE; $_SESSION['was_dead'] = FALSE; } if($this->alive AND !$restarted AND ($_REQUEST["CORE_OP"] == "vd")) { $restarted = $_SESSION['interface']->check_MLDrestart(); } if($restarted) { $check_all = FALSE; if($_SESSION['user']->username == "admin") { $check_all = TRUE; } $_SESSION['user']->verify_db($check_all); $_SESSION['user']->refill_downloads(); } elseif($this->alive AND $this->timemark) { $_SESSION['user']->remove_finished(); } }
/* * logout - what should i say any more? ;) * * Moritz Warning */ function logout() { //for gettext tool _("Logout"); $_SESSION['user']->search_delAll(); unset($_SESSION); session_destroy(); if($this->use_http_auth) { //send a 401 to clear the browser cache Header('WWW-Authenticate: Basic realm="Logout"'); Header('HTTP/1.0 401 Unauthorized'); } } } ?>
x-posted to #linux and #computergeeks
Source: http://www.livejournal.com/community/computergeeks/771090.html
-
Testing stages
Date: 09/13/05
(WebDesign) Keywords: php, mysql, css, html, sql
I'm currently working on a text based RPG that is in the testing an development stages. I'd like to get an opinion on it. Considering it is my first time working with php, mysql, and css. I was always a HTML girl.
http://www.divineillusion.us
Source: http://www.livejournal.com/community/webdesign/976981.html
-
Testing stages
Date: 09/13/05
(Web Development) Keywords: php, mysql, css, html, sql
(Ugh, I updated to the wrong community the first time. Copy/paste baby!)
I'm currently working on a text based RPG that is in the testing an development stages. I'd like to get an opinion on it. Considering it is my first time working with php, mysql, and css. I was always a HTML girl.
http://www.divineillusion.us
Source: http://www.livejournal.com/community/webdev/243364.html
-
error_log() problem
Date: 09/14/05
(PHP Community) Keywords: php, mysql, sql, google
I have been trying to write a custom error handler (or at least adapt the one used in O'Reilly's PHP and MySQL book) and I'm encountering an issue with the error_log() php function. I'm not sure whether this is a problem in my configuration files or whether the function is being used incorrectly - I haven't altered this part of the code from the book. The code being called is:
error_log($error, 3, ERROR_FILE);
And it produces the following error message (file paths removed):
Warning: error_log(...filepath.../log/php_error_log.log): failed to open stream: Invalid argument in ...filepath.../phpincludes/customHandler.inc on line 89
If anyone can help me (I've spent hours trawling Google with no luck) it would be much appreciated.
Life is tough when you can't debug your debugger...
Source: http://www.livejournal.com/community/php/343526.html
-
Mysql
Date: 09/17/05
(MySQL Communtiy) Keywords: php, mysql, software, database, sql, web
Does anyone know how much one can expect to spend to hire someone to create a mysql/php script? The one in particular is for allowing a member to view online statements at a gym website and needless to say, quite secure. The software we use for gym management uses a mysql database. I've got to run this by my manager in two days so I'm looking for how much he can expect to spend and what is a good and reliable source to get this done. Thanks for any assistance. Trinity
Source: http://www.livejournal.com/community/mysql/68184.html
-
pseudo-code help
Date: 09/18/05
(PHP Community) Keywords: php, mysql, blogging, sql
I'm making a threaded comments script for a blogging system. My code so
far is not working, so I'm trying to think it through again using
pseudo-code. I'd really appreciate some feedback on what I should be
doing, if anyone would mind taking a look at the pseudo-code (under the
cut). If my reasoning is correct, then I can concentrate on the syntax.
MySQL tables:
Posts (sorry for the yuck formatting)
Comments
id (unique id)
|
post (to which the comment belongs)
|
parent (comment to which the comment is a reply)
|
author
|
title
|
timestamp
|
email
|
homepage
|
content |
Coding
- have a script, PostsTable.php, to display a post or posts using a while loop, including a collapsible division to display comments or not as desired (easy - done that)
- for each post, set the parent value, $parent_id, to 0 as part of the while loop
- for each post, set the ID of the post, $post_id, from the array generated by the query used to get the post
- within the comments division below each post, include a script, CommentsView.php, to run the queries to get comments
- use a while loop in CommentsView.php to get all comments in order and in accordance with $parent_id and $post_id
- for each comment, set its ID (within the loop) as $parent_id for looping through its replies later
- if there are no comments for a particular post (or replies to a particular comment), end
- if there are comments, include a script to display them similar in design to PostsTable.php: CommentsTable.php
- CommentsTable.php includes CommentsView.php, until it ends
Thank you in advance ^^
Source: http://www.livejournal.com/community/php/344263.html
-
Birthdays problem
Date: 09/24/05
(PHP Community) Keywords: php, mysql, database, sql, web
I'm doing a web application with PHP and MySQL where members can enter their birthday on their profile. I've done a nice monthly calendar view, and I want to populate the calendar with members' birthdays.
Can anyone advise me the best way of doing this? Obviously I don't want to do a database request for each day: "Does anybody have a birthday on this day?" - I think we can all guess that 30 database requests would be rather excessive for one page!!
What I'd like to do is one database request to get all the birthdays for the month and then write it to a 2-dimensional array. Each row in the array will have the user's name, their userid (to link to their profile) and the day of the month which is their birthday. Then all I need do is ask the array if there's any birthdays when I'm writing out the days.
The trouble is, I'm very unfamiliar with arrays and I'm not sure the best way to do this. Can anyone help?
Update I've found a very useful function which is helping a lot:
$birthdayquery = "SELECT ID, RealName, DOBDay from Users where DOBMonth = '$month'"; $birthdays = mysql_query($birthdayquery); $arrayindex = 0; while ( $birthdayarray[$arrayindex++] = mysql_fetch_assoc($birthdays) );
You can then do
$arrayindex = 0;
foreach ($birthdayarray as $value) {
if ($birthdayarray[$arrayindex]["DOBDay"] == $day) {
echo $birthdayarray[$arrayindex]["RealName"];
echo "'s birthday";
}
$arrayindex++;
}
I think this is going to work!
Source: http://www.livejournal.com/community/php/346726.html
-
Host for beta test site.
Date: 09/24/05
(Web Development) Keywords: php, mysql, sql, web, apache
I'm looking for a cheap host which offers the following:
- MySQL 4 with InnoDB support
- PHP 4 with GD/Image manipulation module
- Apache mod_rewrite support
I'm looking to set up a beta test website for an open source myspace/friendster clone that I'm working on called Appleseed (http://appleseed.sourceforge.net).
Let me know if you have any suggestions.
Update: I need SSH access, too.
Source: http://www.livejournal.com/community/webdev/246550.html
-
Introduction and question
Date: 09/26/05
(PHP Community) Keywords: php, mysql, html, database, sql
Hi everyone! I've slowly been teaching myself php and mysql over the past few months, but it's slow going, and I tend to learn better from someone teaching me something than I do from a book. I finally got the bright idea today (after having been on LJ for how long? lol) to look for a php help community, and lo and behold, I find you! :D If anyone could help me, I'd be very appreciative.
Here's the situation: I'm trying to build forms that will gather the information provided, check to make sure that everything necessary is included, and either redirect to an error page or a success page as needed. The html form looks like this (obviously without the spaces):
< form action="add_entry.php" method="post"> Subject: < input type="text" name="subject" /> Text: < textarea rows=6 cols=60 name="text">< /textarea> < input type ="submit" name="add_entry" value="Add Entry" /> < /form>
add_entry.php looks like this (again, without the spaces):
include('common.php'); if(isset($formname) && $formname == 'add_entry'){ if($subject != '' && $description != ''){ $dbh=mysql_connect ($host, $user, $pass) or die ('I cannot connect to the database because I do not like you' . mysql_error()); mysql_select_db ($database) or die('I could not find the database you are searching for'); $query = "INSERT INTO journal SET dateadd = NOW(), subject = '$subject', message = '$description'"; mysql_query($query); mysql_close($dbh); $redirect = 'success.html'; } else{ $redirect = 'error.html'; } } else{ $redirect = 'error.html'; } < html> < head> < meta http-equiv="Refresh" content="1;url=< ?php echo $redirect ?>" /> < /head> < /html>
My problem is that it never seems to go through the mysql query and always redirects to the error page. I know that the query is good--I've checked it through phpMyAdmin--so I'm thinking it has something to do with the isset.
Any help would be greatly appreciated! :D
Source: http://www.livejournal.com/community/php/347463.html
-
session variable help?
Date: 10/04/05
(PHP Community) Keywords: php, mysql, sql, web, shopping
Context: I'm working on a bare-bones shopping cart system and am using a session variable $cart to store cart items. $cart is an associative array holding item_id => quantity. To add an item to the cart, I'm calling the page with a url variable ?new=xx where xx is the item id. If the item id exists in the array, am incrementing it. If it doesn't exist, I create it and set the quantity to 1. In theory, anyway.
Problem: Adding a new item to the cart produces the expected results, but if the page is called immediately after without the url variable, or with a url variable pointing to a different id, it increments the quantity of the item just added by one. It is also the case that when I call a separate checkout page with the display_cart($cart) function in it, the item quantity shows up incremented by one.
(the following code will look very familiar if you've ever used PHP and MySQL Web Development)
On the shopping cart page:
if($new) { if(!session_is_registered("cart")) { $cart = array(); session_register("cart"); }
if($cart[$new]) $cart[$new]++; else $cart[$new] = 1; }
if($save) //have tried commenting out this part, makes no difference { foreach ($cart as $item_id => $qty) { if ($$item_id == "0") unset($cart[$item_id]); else $cart[$item_id] = $$item_id; } }
if ($cart&&array_count_values($cart)) display_cart($cart); else echo "There are no items in your cart.";
Display cart function:
function display_cart($cart) { echo " "; }
I've done a bit of reading on how sessions work, but am still pretty confused by it. Is this black magic or am I just not going about this right? Any suggestions, including debugging techniques, would be appreciated. In the meantime, I'm just going to take a whole different approach to this cart, but I'd like to solve the mystery eventually.
Thanks in advance.
Source: http://www.livejournal.com/community/php/350281.html
-
DELETE query and not only
Date: 10/06/05
(PHP Community) Keywords: mysql, sql
Do someone know what's wrong with the following code:
//deleting
if ($delete) {
foreach ($record as $num) {
$query=mysql_query ("DELETE FROM $table WHERE ID='$num'");
}
printf ("Records deleted: %d\n ", mysql_affected_rows($query));
}
As you probobly can see, I need it to print how many rows were deleted and it returns 0 even when I"m 100% sure several rows were deleted.
Source: http://www.livejournal.com/community/php/351399.html
-
catas-apostrophe
Date: 10/07/05
(Web Development) Keywords: mysql, sql
Quick Question:
I'm feeling less than genius today, so I'm stumped as to why this is happening
I've got a field I'm pulling from the mysql db. $name = stripslashes(urldecode(mysql_result($result, $row,'NAME')));
If the db field contains "donkey%5C%27s" then $name echoes "donkey's"
this looks fine when I plop it as text, but when I insert into a text INPUT field, like so:
[input typ="text" name="name" value="[? echo $name; ?]"]
it shows up as "donkey"
the 's is chopped off in the text field why?
edit : the problem was the [input... attributes were single quoted [input type='text' name='name' value='donkey's']
doh.
Source: http://www.livejournal.com/community/webdev/252293.html
-
Programming a Tag Function
Date: 10/10/05
(PHP Community) Keywords: programming, mysql, database, sql
Most of us are aware of the function Live Journal has to assign "tags" to journal entries. I have also seen Flickr.com do this and use as a path for search and browsing (Pretty cool).
As far as I can tell this is just a list of keywords, probably stored as a Text Blog per journal entry (Live Journal) or per image (Flicker).
How would you go about programming a tag function? I am not looking for code, but rather logic steps.
EDIT: BTW the database will be MySQL.
From the initial response, I see a BLOG isnt the way to go. Also, let me give a little more detail: the function I am building will also function kinda like Live Journal's Interests where a user will list interests and then be matched up to the tags (keywords) of other database entries (not necessarily other users).
Source: http://www.livejournal.com/community/php/353398.html
|