Ok, so I have the following code, meant to delete a category in a script I'm working on. It takes the category ID from the $_GET array, checks the database to make sure such a category ID exists, then deletes it if true or shows an error if false.
if ($_GET['categories'] == "deletecat") { if (isset($_GET['delid'])) { $idofd = cleaninput($_GET['delid'], 1); $idofd = (int)$idofd; $check_delete = mysql_fetch_assoc(mysql_query("SELECT * FROM table_cats WHERE cat_id = '" . $idofd . "' LIMIT 1", $connect)); if (empty($check_delete)) { echo "
Error: There is no category with the ID number " . $idofd . ".
"; } else { $deletecateg = mysql_query("DELETE FROM table_cats WHERE cat_id = '" . $idofd . "' LIMIT 1", $connect); if ($deletecateg) { echo "
The category could not be deleted: " . mysql_error($connect) . "
"; } } } else { echo "
Error: No category selected for deletion.
"; } }
When I execute this code, Firefox will always tell me that there is no category with the ID number specified, even when it does exist - however it will delete the category anyway. Opera does things correctly - a category is selected for deletion and the success message is shown.
Is this a browser problem or a code problem? I have tried all sorts of different solutions, originally the code was as such:
if (!empty($check_delete)) {
// delete the category
}
else {
// display error
}
However I switched it around thinking that maybe Firefox was taking too long to check the category and then finding it deleted or something like that.
I haven't been able to test this in IE yet, but I have a feeling it might work, like it did in Opera. So... any ideas as to why it's not working in Firefox?
Specs: PHP 5.0.5/MySQL 5.0.15 running on Windows XP (local testing server); Firefox 1.5
Thanks in advance.
PS: First post to this community! *Bows low*
Edit: Solved! Firefox didn't like having a button in the form field used to get the delete ID (it's a "get" method form). Changed it to a normal link and everything now seems to be working as it should. :)
I have a website, just a little personal project where I archive my writing. Over the years I have streamlined the code of this page as my knowledge of web design grows, so that it has gone from ugly frames to a smooth CSS-based design. However, this site has many identical pages (as far as layout is concerned, not content), and every time I significantly update the site layout, I always end up having to update each and every page manually. This is a pain.
So here is what I would like to do about this:
1) Create a database of some sort, or maybe just a collection of .txt files, and when a user clicks on a link (say, to one of my poems), have PHP generate the page based on information parsed in the link. I have no idea if this is even possible.
or
2) Create one file containing all of the layout's HTML information, and have each page access it instead of having to hardcode such into each file. This file could also contain the CSS information if possible.
The trick to all this is that while I am a master of HTML/CSS design, I know next to nothing about PHP, beyond how to write the simplest of scripts and how to upload it to my domain. Is what I'm proposing even feasible, and if so, does anyone have any suggestions/advice/code/places to go for more information to help me make it work?
Thanks so much if you can help me, and apologies for being such a newbie pain!
I'm new to this community. I am starting a web design company, and although I used to be decent at PHP, that was a couple of years ago and my knowledge is now pretty much non-existent. I need a script coded for a band website and I was wondering if some of you would give me a price estimate on it.
The script is for bands that want to add shows to their website. The script needs to do the following
- Allow a user to add / edit / delete shows to their website. The shows will be in 2 categories (which will be 2 HTML tables) which are Upcoming shows, and past shows. - The user puts in information in a form and it's stored in a MySQL database. The most important information is displayed in an HTML table, and in the last cell of the table will have a link for more information. When a user clicks on this link it opens up a popup window and displays ALL the information of the show (eg. Date, time, venue, cost, directions, other notes yada yada yada) in another HTML table (within the pop-up window)
I realise that this is a pretty simple script (in comparison to what you guys have probably coded in the past, so I hope someone out there can code it for me at a reasonable price
I know there's been a couple posts about this recently, so if I'm asking redundant questions, sorry.
A friend of mine has come up with a pretty novel idea for a MySpace-ish site, but for a specific niche market (kind of like those CatSpace and DogSpaces that exist) - users will have profiles, photos, a blog, message boards, send friend requests, yadda yadda yadda, you've seen it all before. I'm going to be developing the initial setup myself (since we have no money), and this is a somewhat long term project that I'll be picking at casually for a little while.
Right now I'm trying to figure out if I should give this a go coding from scratch, or use an existing CMS type solution (like Mambo, Joomla, Drupal, etc). I'd really like to code it myself, as I think it could be a fun project to work on. I'm a pretty solid PHP programmer, but as I have a feeling that this idea could jump in popularity pretty quick, I really want to make sure I keep this thing as efficient as possible for a large user base. For instance, I don't want to go making another MySpace which I think runs horribly as a web app compared to even LiveJournal.
Currently I use PEAR's DB_DataObject or my database interactions and I've just gotten into Smarty for templating, though I'm sure I'm not using either to their fullest potential. I saw mention of a couple of development environments and frameworks in someone's recent post looking for a visual studio-esque PHP environment - http://www.livejournal.com/community/php/388602.html but I've never used any of these.
I'm not really concerned here with using a "rapid development" framework - I don't mind coding, I like it - but what I'm really concerned with is stability, efficiency and security - I know of course that these also rely heavily on how well I code, and using a good coding environment or framework won't do the coding for me, but there have to be some tools/frameworks/etc out there that pros are using that I just haven't moved onto yet, and I wanted to see what you guys (and gals) are using on some of your bigger projects.
- I know this comes up a bunch, but does anyone else think would it be handy at all for us as a community to maybe organize some of the more useful threads and frequently asked (and answered) questions in the php community at a separate location? Doing just a search on the community doesn't necessarily give you anything about the quality of the responses, and it may even be nice to be able to 'browse' solutions/posts by categories or something; maybe we could have some sort of quality ranking on posts, or some way to identify posts that contain questions that get asked all the time. I don't think this would be too tricky to put together, and I'd be willing to work on it, but I don't know if anyone would even use it?
Your hosting package will be reviewed and given on a case by case basis. The minimum package includes (but you could qualify for more):
www.yourname.com 125MB of Space 1G of bandwidth 1 MySQL Database POP Email Control Panel FTP (basically anything you need to get your site up and running)
This new program starts this week. All accounts that are earned between April 18 - 22 will be setup on Sat. the 23rd. Please visit www.subnixus.com for all of the details.
Hi everyone, I am writing a program that uses zip code location information. I am having a really hard time finding a database for this information in a format that I need. Almost all of the databases I have found have the records like this:
Sample Records "Key West","FL","33040","305","12087","Monroe","P", "Stock Island","FL","33040","305","12087","Monroe","A", "Raccoon Key","FL","33040","305","12087","Monroe","N", "Agoura","CA","91376","818","06037","Los Angeles","A","P"
I think what I may be looking for is a list of states with unique IDs. A list of counties tied to those state IDs. A list of zip codes tied to those county IDs.
Am I wrong? The sample records dont seem to follow the rules for database normalization.
I was wondering if anyone could recommend me a webhost that will meet the following requirements:
+ I want as much control as possible. If I decide one week I want to mess around with OracleDB, I want to be able to install it. If I want to use Ruby on Rails, I want to be able to install that too. I basically want to be able to do as much server administration as possible
+ I have the following musts: PHP 5, Apache, MySQL(preferred, but some kind of database)
+ I need a decent amount of space and bandwidth, but not a whole lot.
I have considered a dedicated server, but it seems to be far too expensive for now at least. Any ideas?
Amazingly enough, I've *just* started using functions with my ASP code, even though I've been doing ASP for a little while now.
Right now, I'm only using a function to deal with connecting to my database and retrieving information based on the SQL I use.
In several cases, however, I need to use multiple recordsets for part of a page's content. It gets a little tiresome to use the same function over and over.
Is there a way that I could store all of my SQL statements in an array and then use that array in my function so that it would run through however many items there are in the array (this could not be a static number, since one page might use four different statements and another might use three), run all the SQL statements, and then put the results in different recordsets?
Or..would it just be easier to make one huge SQL statement, like
SELECT table1.field1, table2.field1, table2.field2, table3.field5 FROM table1, table2, table2 WHERE
These tech communities are mostly questions from those that need help which I often do :) I thought it'd be fun to change the pace a little and post some info I think is good to know if your using mysql.
I've recently had problems with table crashes and running mysql in an environment with very little disk space. This has taught me a few things I did not know before hand. One of which is mysql's binary log (also known as the update log in older versions). It stores all statements that are run that could potentially modify data in the database which allows restores to work as best as possible (i.e. even if your backup is a bit old). For more info check the binary log docs
While trying to connect to the mysql database, I get this error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) So I look up the solutions for this error. I discover that I need to edit a my.cnf file and change the socket setting. I wish it was that easy. I check what socket is set too.
[client] #password = my_password port = 3306 socket = /opt/local/var/run/mysqld/mysqld.sock
Not the socket the server is trying to connect to.
The file is located in /opt/local/etc/mysql4 and I also copied it to /opt/local/etc incase. The password and username is correct, I can manually connect to the database. Using a Mac OSX.4 server. DB Server version is 4.1.15 Connection: Localhost via UNIX socket
I am trying to make it so this result can be ordered by the last name of the client. However, the name is in another table thus the JOIN LEFT. That part seems to be working OK (I think), but where I am running into a problem is that the results are showing duplicates (example if invoice 10, there are 3 result rows for invoice 10, but only 1 row in the actual MySQL table "invoice_main").
(Yes, there are some name/case mismatches, but I didnt create the database.)
Thanks!
SELECT DISTINCT invoice_main.invoice_number, invoice_main.invoice_date, invoice_main.due_date, invoice_main.clientid, invoice_main.subtotal, invoice_main.paid_amounts, invoice_main.payment_status, clients.ClientLast FROM $TableName LEFT JOIN clients ON invoice_main.clientid=clients.ClientID WHERE invoice_main.office_id='$office_id' ORDER BY $SortParam LIMIT $limit,$Limit_increment
Adding GROUP BY invoice_main.invoice_number gave me an SQL error
[UPDATE] Figured it out LEFT JOIN clients ON invoice_main.office_id=clients.office_id AND invoice_main.clientid=clients.ClientID
Gotta thank jedifreeman and his help with JOIN a couple weeks ago. I was re-reading our AIM conversation and thought of this.
Hi everyone, I am writing a program that uses zip code location information. I am having a really hard time finding a database for this information in a format that I need. Almost all of the databases I have found have the records like this:
Sample Records "Key West","FL","33040","305","12087","Monroe","P", "Stock Island","FL","33040","305","12087","Monroe","A", "Raccoon Key","FL","33040","305","12087","Monroe","N", "Agoura","CA","91376","818","06037","Los Angeles","A","P"
I think what I may be looking for is a list of states with unique IDs. A list of counties tied to those state IDs. A list of zip codes tied to those county IDs.
Am I wrong? The sample records dont seem to follow the rules for database normalization.
I have a database table with 4 keyword fields. I guess they like to store up to 4 keywords against each entry. Unfortunately this makes processing quite difficult, as I'm constantly having to search each field (key1, key2, key3, key4).
Is there an easy way to merge these into a big conglomerate sort of list that would be easier to manipulate?
I've been looking around since yesterday and just can't seem to find a definitive answer -- how exactly do you use MySQL 4.1.x with PHP 4.x?
Needing some of the functionality available in MySQL 4.1 (and since our host has that as well), I installed it, updated my phpMyAdmin settings, and came across "Client does not support authentication protocol requested by server; consider upgrading MySQL client" message. So I went looking for a fix for that. It told me I had to use the mysqli extension for PHP, but since I installed PHP using the installer (I am on a Windows machine, with Apache), I uninstalled PHP, downloaded the binary zip... but can't find the mysqli extension in the extensions folder in the zip.
So now I am in a quandary. The mysqli extension is not in the binary zip; is it only for PHP5? But the host we're on has MySQL 4.1.x AND PHP 4.x! The manual says something about compiling PHP with support for the mysqli extension -- do I have to recompile PHP4, is that it?
Help, advice, suggestions, etc would be very much appreciated, thanks.
Windows XP Pro Apache 1.3 (I'm using Apache 2.0 on ANOTHER machine) MySQL 4.1.16 PHP... well, none as of the moment, but I was using PHP 4.3.x; I'm trying to install 4.4.2
(Ask if there's anything else needed.)
Update:I thought it would be good to post an update since the update might be significant and people don't always check other comments. :)
Actually, I just got phpMyAdmin working -- not exactly sure what happened there, as the only thing I did was create another mysql user with access to all the databases and use that for phpMyAdmin. I thought my problem was fixed but now I'm trying to log into the webapp I'm working on, to no avail -- the script just plain dies (no warnings, errors, messages, nothing) when I call mysqli_connect( host, user, pw, database). Echoing before and after that line--
The ONLY output is "before call". NONE of the code after the connect gets run, and obviously the die() didn't work either (or didn't output anything within the parentheses, anyway). Hence I'm a little confused why phpMyAdmin is working (without recompiling php, and without the extension dll either since I can't find it) but my script can't. I'm assuming it's BECAUSE I haven't recompiled PHP, so... yeah.
Fix: I'm not sure why phpMyAdmin can connect using php4 without having to use MySQL's old password hashing algorithm for its user, but it's probably just amazing that way. Used the OLD_PASSWORD() function to change the password for my script's user, and now it's working fine again with the ordinary mysql_* calls. :)
Okay, here's one for you. Not sure whether I should be posting here or in csharp; figured I'd try here first.
Trying to set up a SqlConnection in C#.NET (2005 Express Edition). When I test the connection, I get the following error:
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings, SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
All well and good... except the machine to which I'm trying to connect is running SQL Server 2000, not 2005.
There is no connection string as of yet-- it's simply trying to locate the database and access the data (which, I should add, I can do just fine with Enterprise Manager, Query Analyzer, etc.). All I have right now is an "Add Connection" dialog box that has the DSP (Microsoft Sql Server Database File (SqlClient)) and the physical path to the database file (\\edison\c$\Program Files\Microsoft SQL Server\MSSQL\Data\Hospital Rates_Data.MDF). I hit "test connection," and up comes the error.
I am aware of this article at support.microsoft.com. SQL Server 2000 was installed on this machine at least a year before 2005 was released, so that's not the problem (at least, not as they explain it here).Still, I attempted the workaround, and the user they specify does not exist, so I assume that 2005 was never installed on that machine. I've found no help through a websearch; is there no one that doesn't ask questions specifically related to ASP.NET? Sheesh.
I'm having trouble with this script. It's supposed to insert data from a form into a database and upload a file. The file is uploading properly, but nothing is going into the database. Anyone ever have a similar problem? Any idea how I can fix it?
I hope this is not too OT. But as far as I’m concerned, a good LAMP programmer worth his salt is also member of various PHP user groups, so while looking for one right now, this seemed very obvious to me.
JOB TITLE & LOCATION: PHP Web Programmer based in Crawley, West Sussex RH10 9GA
COMPANY OVERVIEW: ViewSonic is a leading worldwide provider of advanced display technology, including computer monitors, flat panel displays and projectors for today's business, education, entertainment, Internet and professional markets. The company employs more than 600 people worldwide. More than 400 are based at the company's headquarters in Walnut, California, and more than 100 employees within our 12 offices across Europe. Other affiliate offices can be found in Taiwan, China, Canada, Australia and Latin America.
SUMMARY: This is a recently created position responsible to develop application code and take part in the application design process as member of a team dedicated to develop Web-based business applications which may subsequently be used by employee partners, business partners as well as the general public alike. The applicant must possess a wide range of web-related technical as well as interpersonal and time management skills with a very strong emphasis in experience in the scripting languages and architectures outlined below.
EDUCATION: University degree not required, but any formal education related to web application development considered favourably. Any informal, yet related education will be considered as well.
LANGUAGE: Excellent written and oral command of English. Excellent written and oral command of further languages common in Europe considered a great plus.
EXPERIENCE: Several years developing and designing web-based applications using the languages, architectures, programs and tools listed in the technical skills sub-section.
Technical Skills / Experience: (Essential / Desired) • PHP5 including OOP (E) • HTML & CSS1+2 (able to hand-code) (E) • Usage of PHP programming IDE e.g. Zend Studio (D) • JavaScript / DOM (E) • SQL (E) and basic Database Design (D) • Web Publishing Methodologies (FTP, SCP, CVS etc) (E) • Smarty Templating Engine (D), Ajax libraries (D) • Version Control (CVS, Subversion SourceSafe etc) (D) • Apache Configuration and Administration (D), UTF-8 web setups (D) • Comfortable with Linux BASH / Shell Console (D) • Photoshop (D) • Plaintext Editor with Syntax Highlighting (UltraEdit, Textpad, Vim etc) (E)
SALARY & TYPE Negotiable, based upon experience. 12 months contract.
CONTACT Please send your CVs (cover letter would be nice) to sue.pegrum@viewsoniceurope.com with the subject line "web programmer"
On the same project that I've asked questions about, now I need to try and figure out how to display some database information in a hierarchical-ish view. I need to write up a page that binds to a database information about various courses offered to sign up for. So it needs to look similar to this:
Subject1
Course1
Course2
Subject2
Course1
Course2
Course3
etc
Like I said this needs to bind to a database, and the thing is that I'm not sure how to get this to work with a Datagrid. I don't want to just make a bunch of different Datagrids because that seems messy and not very efficient. Basically I need all the courses to be displayed under their respective subjects on this page, and they need to be able to have a link that would send the user to another page that has more detailed information on the subjects they want (basically a "more detail" page.) I tried looking at a true Hierarchical datagrid method, but it really seemed like more trouble than it was worth in the free versions I saw and I don't think my company will be very willing to try a 3rd party product and will instead decide that I'm just a shitty programmer. Any help/suggestions on this would be greatly appreciated.
I have mp3s from my album in a folder on the site. Then I have downloads.php?id=#, which reads the details of the id from the database and constructs the url of the file then sends that to the browser. It's definitely getting the right file...
Is it ok to use header location: to give out the file to the browser for a media file? I'm getting the code instead of the binary file when I try to download.
This was not happening on my WAMP dev server and is definitely happening on my LAMP production server. I'm wondering if it's a php thing or a server environment thing?
It's php 4.3.10, btw.
Any suggestions? My site is so close to being done!
I spent a good long time cataloging my huge collection of movies and putting into databases. Now I've got to write some php code to display (and possibly administer) all of this information, which I am not looking forward to. I keep hoping that there's something previously written than I can modify. The concept is simple enough: I need something to display large amounts of tabular data succinctly to end users on my website. I want users to be able to add or remove columns to what they are viewing. They should also be able to sort on any column they wish. All this needs to work seamlessly, as if the user were facing an Excel spreadsheet. Do any of you have suggestions for me on softwares I might try, or have any of you written code to do this already? Thanks in advance for your help.