Determine Field Type
When a form is submitted I can get the field names and the entered values with $_POST, but is there a way to determine what type of field? For instance, can I determine if a field was a textarea or an input field?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Determine The Type Of A File (gif Or Jpg)
I've written a very basic CMS using a PHP database thing (no MySQL). It lets me update a list of 5 descriptive texts, each relating to an image which is shown next to the text. At the moment, my HTML looks like this (simplified): <tr><td><img src="images/Picture1.gif"></td></tr> <tr><td><img src="images/Picture2.jpg"></td></tr> <tr><td><img src="images/Picture3.jpg"></td></tr> <tr><td><img src="images/Picture4.gif"></td></tr> <tr><td><img src="images/Picture5.gif"></td></tr> which is very inelegant as I have to repeat all the information. I've already written the script to create the 5 table rows dynamically, using a "for" loop with the counting variable $i, so that I can simply write one row and substitute the Picture number with the variable: PHP Code:
Uploading .png And Can't Determine File Type?
I'm currently creating a page where users can upload images and the server will save them to their respective places, but I've run into a snag of sorts. I currently check to make sure that the file being uploaded is an Image file, but only jpg/gif/png. If it is not one of those three, it rejects the upload. If it is, it will save the file to the server. Now my problem is that when a PNG is uploaded, there's no filetype associated with it. If I check the jpg and gif, I'll get image/jpg and image/gif respectively, but when I check the png, I get nothing, there's nothing returned. Does anyone have any suggestions or maybe seen this before? Also, I don't want to go and allow any image type to be uploaded. I'd really prefer to allow only those three types.
Is There A Universal Field Type?
Is there a field that will accept any type of data? like varchar, blob, or any special combination, that will hold the data I insert into a table... exactly as it was entered (including quotes ' and "). .. and not let mysql parse through it?
Determining Type Of MySQL Field.
I have a problem of migrating a database from one host to another. I can't do a dump on the source server. The only access I have is thru queries. So it looks like I'm going to have to query all the tables and insert to the destination. I'm trying to come up with a general solution to this problem which uses queries to determine the structure of the source db, and create the tables on the destination, which I've already done using the nice "show create table" query syntax combined with the PHP mysql_list_tables() function. The problem comes with doing the inserts. It looks like I'm going to have to do a "select * from table" thing and then loop thru the recordset doing insert after insert. Q: Do I have to do it that way? Is there a way I can insert all the records from source to destination more efficiently? Q: How can I determine the type of value in a field returned from a query? PHP's is_string returns true on ALL fields regardless of type used in the database itself. I need to know whether to wrap the values in quotes or not before I insert them. I'd like to be able to at least fetch a record and insert the record without having to process it. I'd like to grab the whole table and insert it, but haven't a clue how to do this. Q: Is there some kind of select/fetch that I can do that will give me a record ready to insert i.e. with commas and quotes?
Read Mssql Field Type From Php
this question is 50% mssql and 50% php. To get field definitions and other informations for table 'myTable', I use with sql server: EXEC sp_help myTable The problem with php is this command returns several result sets, and informations about field types is not in the first one. If I query mssql from php and fetch result, I only get informations about the first one, and php completetly ignores the other one. Is there a mean to read other result sets, or is there another sql command that returns field definition?
Best MySQL Field Type For Unix Timestamp?
What do you recommend as the best type of field for a timestamp in a MySQL database? I've considered varchar(10) or INT but I'm not sure what is the best, most efficient, and most reliable field type.
Changing Form's Field Input Type
We have the form which uses checkboxes for several fields and the target action points to outside webservice. Unfortunatelly they do not support checkboxes. How to pass it as a radio buttons or pull down select box with Yes/No options for example (which they support) using still checkboxes as an input entry.
Help On A Multiple Keyword Search On A TEXT Field Type
Working on a php/mysql driven site which requires me to have a search facility based on multiple keywords. I read the tutorial "quick and dirty search engine". What i want to know is : 1. Is there any SQL query i could perform which could to almost the same thing ( i dont really need the accuracy ) ? 2. Any other methods of achieving it?
Check What Type (integer, String Etc) A Database Field Is
If i have a datebase field like so: $username = $row['username']; //after SELECT and mysql_query etc. how do i check what file type it is? i have tried using is_string to check it but it returns all fields back as strings, even the ones i know are integers. i would like something that would tell me the data tyle (integer, varchar, text etc). are there any other ways or am i doing this wrong?
Show Stored Value For Form Field Type=file
I have a file-uploading form to uploads a .jpg file and stores its name in a table in my db as co_bannerfile. I'm trying to now write an update form so the user can update their .jpg file. I've successfully written a query to retrieve the stored file's name. How can I display the stored file's name so the user can see its name within the input TYPE="file" field and then decide to update it or not? The following doesn't display the stored file name. What do I have wrong? Code:
Save Date To Table Field Date Type
I have a calendar picker on a form that fills a text box with XX/XX/XXXX date format. If I run a insert statement the date field in the database shows 0000-00-00. If i change the field type to varchar the correct format displays. What is the correct way to save a date to a mysql database? Furthermore to query on the date how about a select * from db_name where servicedate >= $startdate and servicedate >= $enddate I supose this will not work Any pointers?
Form Type=submit Vs Type=image
I'm wanting to create a form with quite a few SUBMIT buttons that use an image rather then the stock (plain grey) button. Everything works fine when I use this line: print "<INPUT TYPE="submit" NAME="editaction" VALUE=$id>"; I know which SUBMIT button was pressed by checking the value of $editaction in the receiving page. Now if I replace that line with this one: print "<INPUT TYPE="image" SRC="icon.gif" NAME="editaction" VALUE=$id>"; I no longer get a value in $editaction. I know about $editaction_x and $editaction_y. Is there no way get to the 'VALUE' (from the VALUE=$id part) as well? Am I missing something? Has the variable name been modified to somthing like $editaction_value? TIA for any light you can shed.
Upload Audio Files Of Type .wav & Video Files Of Type .avi
I need to upload audio files of type .wav & video files of type .avi / .mov but my current file unloader is not helping me with that. My unloader works with application types, images, txt, pdf , mp3, mpg, mpeg but not with those .wav & .mov/.avi files........
Can A Field Communicate To A Server And Return Information To Another Field Without Retrieving The Whole Html Code Again?
I´ve got a sql table which has 3 fields. Their relation to each other is like this example. | CARS | YEAR | PRICE | ford 2000 ford 2001 ford 2003 volkswagen 1999 volkswagen 2000 I am developing an ASP web page that modifies a specific registry. So, it loads the information to some fields, but the user will be able to change only the "PRICE" field. I have to create two selects, one for "CARS" and other for "YEAR". But the "YEAR" field will only contain the correspondent years for each car the user selects. Example: selecting "ford" in the "CARS" <select> box, only the years "2000", "2001", "2003" would be automatically loaded in the "YEAR" <selec> box. How could i implement it?
How To Determine Whether GD Is Installed?
I am trying to install a captcha form that required those graphic libraries. I got the error message "call to undefined function" which according to the authors of the form suggests that GD is not probably installed or enabled. I created the usual <?phpinfo()?> report and the only part GD is mentioned is in the Configure Command section: ./configure'...'--with-gd=shared' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-ncurses=shared' '--with-gmp' '--with-iconv' Can you tell whether GD is installed from that? If I remember correctly, GD should have its own section within the PHP info report - but its not there. Since my host isn't very responsive to my requests, I was thinking that I should try installing GD myself. Server is running Apache/2.0.52 (CentOS). Anyone aware of any tutorials that might help preventing me from screwing up things?
How To Determine Current URL In PHP?
Is there a way that I can determine the current url/location (like the 'location' variable in javascript)? For example, if I'm at http://mysite.com/index.php, is there perhaps a fixed variable containing 'http://mysite.com/index.php' already available, or is there a function available to retrieve it? I want to use this to log certain hits on my site, so it would be nice to have a way to do it all in one page rather than integrating information sent with the help of javascript from another page.
Determine How Long It Was Since Last Logged In?
I can insert the date and time into a SQL table, but where do I go from there? What would I use to figure out the exact minutes since they were last on? Also, the minutes need to round to hours, and hours to days.
Determine Four Highest Numbers From DB
Got this interesting problem, I have a table and in there I have a field called itemid which is set to integer, and basically its a list of numbers. The problem is, how do you go about calculating the 4 highest numbers? I've tried using SQL command but I don't think I have the version which support sub selects select * from t where number in (select max(number) from t)
Determine Expire Session
I need know when the session expired. I intend to create two messages, one when the session was not created and other when it's expired. e.g: Was not created: Message: Login in the site Created, but expired: Message: Session Expired, please retype your password and login.
Determine If Image Is Grayscale
i'm a bit new to PHP - i've been messing around with the GD2 image functions and was wondering: i see a lot of information about converting a color image to grayscale but i can't figure out how to determine whether an image (GIF or JPG) is grayscale in the first place. is there a way to do this in PHP?
Determine Contents Of Listbox
How can I determine the values of a listbox, both unselected or selected after submitting the form: Code: <select name="sel1" size="10" multiple="multiple"> <? PHP code populates listbox ?> </select> Do I have to use Javascript to determine the contents, like in the pseudo code Javscript below. But how would you pass the Javascript return value to PHP? Code: function listBoxContents(sel1) { var selLength1 = sel1.length; var valuesPresent1 = new Array(sel1.length-1); var i; for(i=0; i<=selLength1-1; i++) { valuesPresent1[i]=sel1.options[i].valueOf(); } return valuesPresent1; }
Determine Number Of Entries
I have a form in which the user can add more textboxes as need be: Ing1 Ing2 Ing3 .... There could be 1 input or there could be 30... How can I, in php, determine the number of input controls so that I can then loop through them one by one and process their data?
How To Determine What Country Viewer Is From
i'm rather new to php and would like to know how to determine where the viewer is from. ie. what country. so if they have a .ca i can display canadian funds, .com/.us american funds, and .uk for pounds. is there a function that can be used for this or is there a way to set the domain to a variable and extract it from there.
Automatically Determine A Swf Dimensions
I am not sure whether you are actually able to retrieve the dimensions of a flash game from code. But is done seem that Miniclip.com are able to do it, but I am still not sure whether the dimensions are being retrieved from the database or not. Code:
Determine A Forward Email Addy
i have an application that sends out mail from flash. in each mail there is a link for the viewer to click on. when the viewer clicks the link blah.php?email=email@address.com it updates the database adding their email to the list of people who have clicked that link. i want to be able to track emails that have been forwarded. the problem is if someone forwards, it will forward with their email attached to the link instead of the recipients. is there any way i can grab the recipients email and put it in the link?
How To Determine Which Button Was Pressed On <form>
I am having a heck of a time trying to understand how to use graphical buttons in my PHP scripts to interpret user selections. A great example is the list of buttons across the top of this forum (user cp, register, calendar, etc.). Now, I know how to create an <a href><img></a> graphical link and an <input type="image"...> button element for a form, but what I cannot for the life of me figure out is how to tell on a subsequent POST of my form which, of many graphical buttons, was pressed. PHP Code:
Algorithm To Determine Download Time
Anyone got an easy algorithm to find out the estimated download time of a file on a specific speed? I've been trying to figure this out for about a week now, to no avail.
How To Determine If A File Is UTF8 Encoded?
I need a check, if a file is utf8 encoded. I only found the php-functions 'iconv' and 'recode'. But it seems it´s not possible to determine the encoding with them. Isn´t there any similar function to the 'file'-command on linux for php?
Determine Folder A Script Is Running In.
What is the most reliable method to determine the folder a script is running in? I was looking at the globals in $_SERVER but all the variables also listed the actual file the script was running in.
Determine Free Disk Space
Is there a way that PHP can determine the amount of free disk space (Linux system)? I have tried to manipulate the output from $df -h but it's not really working properly.
How To Update A Table's Field With Another Tables Field?
I need to take the state field from dt_profile table and update the dt_matchfinder with this state making sure the member_id field matches. the problem is the dt_matchfinder table has null set for many of the state field but in the dt_profile each member ID has a specific state and I need the same to be true in the dt_matchfinder table.
Checkboxes In A Form To Determine Whether To Display In Results
I am making an effort to put checkboxes in my form that will determine whether to display that column or not. This is my first time doing this with PHP and I am hoping you gurus can assist. I have gotten some extremely great assistance in the past, so I am looking forward to any recommendations. currently my form is as follows:
How To Make PHP Determine If POST Variable Is Existant
if (!$_POST['uploaded'] = NULL){ //If what was posted was NOTHING then $treC = "0"; } else { $treC = "2"; } No matter what, it keeps making the variable equal to "0," even when something WAS posted. Does anyone know what I should be replacing "NULL" with? I tried with 0's, ||'s assigning initial values to the posting form such as 0, nothing has worked so far.
Determine Image Information On Image Stored In MySQL BLOB
I store images in my DB as BLOB. When I want to place them in an html table, I want to determine the width of the image in order to asign the correct width to the column inside table. For JPEGs this is working fine, this is my code: $image = @imagecreatefromstring($r["foto"]); return @imagesx($image); where $r["foto"] is the field selected from the db which contains the image. For GIFs however, its getting really on my nerves !! I know imagecreatefromstring is not supported in gd2 and I tried several thinks. None of them worked ! : - $temp = tmpfile(); list($width, $height, $type, $attr) = getimagesize($temp); echo $attr; gives me :Warning: getimagesize: Unable to open 'Resource id #6' for reading - $handle = fopen("/tmp/tmp.dat", "w+"); fwrite($handle, $r["foto"]); list($width, $height, $type, $attr) = getimagesize($handle); echo $attr; gives me : Warning: getimagesize: Unable to open 'Resource id #6' for reading - Doing this with imagecreatefromgif($temp); wont work either ! Can somebody help me out please? by telling me what I'm doing wrong or what I should do.
PHP Date Question: How To Determine The Date Each Of The Past 3 Sundays
How can I determine what the date was (in YYYY-MM-DD format) last Sunday, and the Sunday before that? For example: Today is Thursday, August 18, 2004 (2004-08-18). I would like to have the following variables: $this_past_sunday = 2004-08-14 $two_sundays_ago = 2004-08-07 $three_sundays_ago = 2004-07-31 etc. etc.
|