Finding Next Index In Table.
function add_league () {
$name = strtoupper(trim(addslashes($_POST['name'])));
mysql_query("INSERT INTO leagues (name, format, division) VALUES ('{$name}', '{$_POST['format']}', 'A')");
echo 'League Added: ' . $name . '(' . $_POST['format'] . ')';
echo ' [ <a href="' . $_SERVER['PHP_SELF'] . '?action=edit&league_id=' . $row_leagues['id'] . '">EDIT THIS LEAGUE</a> ]';
}
As you can see, an entry has just been made into the database, but the following echo requires that entrie's ID. What is the best way of getting the LAST entry into the database ? Or even better, get THAT entrie's ID.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Finding Matches In A Table And Then Moving That Match To Another Table?
Ok, I have a database that has a table called critiera in this table is to fields on is ID and the other is critiera. Now I want to filter out all the one that don't apple to the list and move the one that match to a different database. I know how to open a connection, close, select but I don't know how I would inside of a database use another one as the way to create the list of critieras....
Adding An Index To A Table
I am trying to convert a column to a unique column. Tried to look at some examples on-line but failed to find the correct syntax I need. So, while I'm waiting for my SQL book to arrive, a pointer would be nice. This is what I have so far.... ALTER TABLE member MODIFY username UNIQUE What am I missing?
Table Index Reset
We have an auto-incrementing index field in a table we ujse for development. when we deploy, we would like to remove rows and reset the auto-increment field so the first row our clients insert will have the auto-increment value equal to 1;
MySQL Index And UPDATE Table
"When you update a table with an index, you have to update the index as well" What does this mean? For example, my table has four columns:
PHP Script For Finding Table Names
I'm trying to build a script that will find all the table names in my database. This is my current code which of course doesn't work ;) <?php $tables_query = mysql_query("SHOW TABLES"); while ($tables = mysql_fetch_assoc($tables_query)) { print $tables; } ?> So I have the query being built and because I am just saying for it to print the variable $tables it just says array. What I am wondering is what do I put for it to print the table names so $tables['?']. Does anyone know?
Index.htm Going To Login Page And Sending Back To Index Page
1: A visitors visits a.html page. decides to login and post comment. goes to login page and logs in then I want to send him back to a.html page how do I do that? Here is my login page and login.php page. 2: Same as above but I want to send them back after some time... while I make them view the error, why they have not been able to login. Code:
Which Index To Use - Primary Key, Index, Etc
I have the following tables (simplified example): countries: code_country (char-4) , name_contry) breweries: code_brewery (int-4), name_brewery) coasters (code_coaster (char-8), description, code_country, code_brewery) code_coaster is formed by the combination from code_country + a correlative number: for example CH-33, INDO-102, etc How should I define the indexes so that the querries will be optimized? I've thought about the following: code_country: unique in table country code_brewery: unique in table brewery code_country: index in table coasters code_brewery: index in table coasters code_coaster: unique in table coasters I don't really understand the difference between primary key and unique. Should I use primary key instead of unique?
Grab Content From HTML Table And Place Into MySQL Table?
I am in the process of helping a co-worker upgrade some of his old static html pages into dynamic MySQL driven pages. He currently has a lot of pages with huge tables displaying data. Does anyone know if there is a script or class that can convert a table to a .sql file for upload?
Table Background Color Based On Results From MySQL Table
I am trying to get the "Did User Agree" field on a database query to be colored Green for "Agreed" Red for "Disagreed" and Blue for "Agreed (2nd Time)" .. I have my PHP setup to do the query just fine as of right now with alternating column colors, just can't seem to get the colors to work as I am hoping for. Can anyone help me get the Agreed? table's background color to the colors above? Code:
Index.php
I want to land on www.domain.com/index.php when I type in www.domain.com. I have a virtual server. Is redirection in the webserver configuration the way to do it or is there a better way. I tried redirection but it didn't seem to work. Maybe the changes hadn't been logged after rebooting the virtual sever.
Index.php
How can I get a server to show index.php as it would index.html? When I save index.php it just shows the directory, I'm administrator of an Apache Server and I'm not of a (I think, it's what www.awardspace.com uses) a goDaddy server. Can anyone help me with this? Can it be done?
Outputting A Table Or Form Using SHOW FIELDS FROM Table
In the code the MySQL database was queried using "SHOW FIELDS FROM table" which and the returned results of column names was then use to build an output for a form and a table with php using a series of if statements along the lines of if the returned field name matches something echo a text input field. I have never seen this done this way before, so I want to get the opinion of the devshed user. Does it seem like an unsual long process to build up a form. Is there a security advantage doing it this way? Has anyone ever done it this way before?
Mysql Fetch_field Gets Table Alias, Not Real Table Name
After a SQL 'select .... from tablename alias' the mysql_fetch_field function returns a value $result=>table which will contain the alias, not the actual table name. Is there a way to get the actual table name ? I am running mysql 4.1 and php 4.4
Using PHP To Sort Data In MySQL Table 1 By Values In Table 2
I have a MySQL database with 2 tables in it. products and prices.. Products has a field in it called 'prodno'. Prices has a field in it called 'prodid'. There is one of each item in products and each product has it's own unique 'prodno' There are multiple instances of each product's pricing in prices.. One for each price.. So if a product had multiple prices depending on quantity it would have an entry for each price.. Example: id = 1 prodid = 7001 qty = 300 price = 12.5 id = 2 prodid = 7001 qty = 400 price = 15.5 I was wondering if I could query the database getting info from the products table but sort it according to the prices in the prices table. Kinda like doing a "SELECT * FROM products" ordering it by the lowest price value from each item.. This is all very confusing to me, and I'm the one writing it. Let's try one last time.. Query the database selecting * from products (I plan on using all the info in products) and ordering them by the lowest price for each item in the prices table. I've tried sorting the results of just a basic SELECT * FROM products using Javascript and PHP but with pagination in the results it makes it a bit hard.
Complex Name Index
I've not found anything that relates to this problem and I posted it and in the MySQL forum and got no replies. Maybe there are more ideas here. I want to display an alphabetical index from a table where each row contains information about a couple, i.e., lastname, hisfname, herfname, maidenname. The index should display both the man's name and the woman's maidenname in the same list. Here's a sample of my table: lastname | hisfname | herfname | maidenname smith | john | jane | cook riley | dan | sally | price bagley | bill | donna | davis green | graham | susan | richards From this sample I'd like to extract an alphabetical list like the one below: bagley, bill cook, jane davis, donna green, graham price, sally richards, susan riley, dan smith, john What sort of query could I run to get this order? Can I use two queries and somehow join them to form a single list? Or is there some PHP algorithm I should employ to derive the list from two queries?
Index.php?action=1 Etc
just wondering how i could make a php page which has say an output like index.php?action=1 all it has to do is goto another webpage - so if i had URL then the user is taken to another page and so on for index.php?action=2 / index.php?action=3 / etc
Undefined Index
Notice: Undefined index: name in F:uniSoftware engineeringassignment4guestbook.php on line 6 the variable $name is declared as $name = _POST["name"]; What could be causing this? I've recently installed php 5 on IIS with mysql 4. All running on windows XP downloaded code straight from my uni's tute site. went to run it and it sort of runs but I get these errors at the top of the page.
Index.html?etc=foo
I've noticed on some sites that people are passing variables to HTML files using the GET method. How can you set up HTML files to accept variables? Or have they just set their server up so that all .html files get parsed by the PHP/Perl/whatever engine?
Undefine Index,
I installed php4 for apached and restart apache afterward. but my little php script generated error followint error: PHP Notice: Undefined index: myname in /usr/local/www/data-dist/www.authtec.com/php-test.php on line 2 I was trying to run the following php script in apache: <?php if($_POST["myname"]) { print "Hello, ".$_POST["myname"]."<p> " .nl2br($_POST["textbox"]); } else { ?> <form method="post" action="php-test.php"> <input type=input type=text name=myname> <textarea cols=20 rows=4 wrap=virtual name=textbox></textarea> <input type=submit value="Submit"> </form> <?php } ?>
Index.php...bootstrapping?
I want to write an index.php the is the central point of my website. I see it used everywhere, but I can't seem to figure out a good way to do it. I found an article on Zend's website where it refers to this as "Bootstrapping". Is this correct? The article comes in parts, and unfortunately the author hasn't finished all the parts. I thought I'd throw it out there for discussion, see if we can come up with a few examples, from simple to complex ones. I would imagine this can all be done in an OOP way for the more complex ones.
Index.php Does Not Open Up
in PHP and I am enthusiastically trying out things. I've just replaced my index.html ( file with index.php with of course a few lines of php code, which I am sure they are all correct as far as the syntax goes. I expect the file (index.php) to be loaded in to the browser window upon launching the browser. It's not doing that; instead, it loads the apache index file. (Oh, I forgot... I am running php 5 and apache 2.xxx and modified idex.html to indexHtml.html to avoid the webserver serving the page). I guess that I need to insert a line somewhere in the apache config file but I don't how...
'defaultpage' Index.php
i am pretty sure that i need to use this php script but how do i use it? i know 'defaultpage' should be index.php. PHP Code:
Undefined Index
Reference the above thread: "Passing a HTML variable to a PHP file using include". One thing I've learned over the years is that an error doesn't always come from where the compiler/interperture says it does. Case in point maybe. I am getting this error: Notice: Undefined index: var1 in /var/www/vhosts/texasflyfishers.org/httpdocs/form.php on line 4 Warning: fwrite(): supplied argument is not a valid stream resource in /var/www/vhosts/texasflyfishers.org/httpdocs/form.php on line 5 Warning: fclose(): supplied argument is not a valid stream resource in /var/www/vhosts/texasflyfishers.org/httpdocs/form.php on line 6 in this function: <?php if($_GET["op"] == "ds") { foreach ($_GET["name"] as $key=>$value) { $fp=fopen($_GET["var1"],"a"); fwrite($fp,$_GET["name"][$key] ." ". $_GET["email"][$key] .." ". $_GET["phone"][$key] ." ". $_GET["id"][$key]); fclose($fp); } } ?> 'var1' comes from this last line in this snippet in a previous function: <html> <body> <?php include ($_GET["var2"]); ?// this works <br clear="all"> <?php include ($_GET["var1"]); ?//this works <form action="form.php?var1=>($_GET["var1"])" method="GET"// NOT I have found that the text editor you are using will color out the parts of code if they are correct. This code does not color out evenly. In the 2 'include' statements '$_GET' is red. In the 'form action' statement it is not. At this point 'var1' is a name on a disk with zero length. Is it possible that the error trapping of the 'include' function is taking care of this and the error trapping of the 'fopen' alerts you that it is going to crash fwrite because 'var1' is now corrupted?
Get Type Of Index
is there a way (function) whereby I could get hold of a particular table index type? It's funny because when I use Show fields to get records of my tables, I can get PRI (Primary Key), UNI (Unique) but after the first two field, other index I get is stated as MUL. What's wrong with that? I'm not sure what's MUL maybe it stands for Multiples? But that's one field only consist of unique index but it show MUL. How can anyone explain?
Undefined Index
I have a simple search feature that searches 3 fields in 3 separate tables in a MySQL db, and I'm getting an 'undefined index' error, but only in the first section (first table)of the results. The undefined index is tied to the docs.projID in the "if ($row_search['docs.projID'] == 1)". This if statement is there to control to format of the link as pages are in different depths of subfolders depending on security needs. Googling this sort of error seems to reflect problems with the $_POST['keyword'] not existing when the results are first listed, so I moved the PHP results code from it's own page (search.php) to the main page, which didn't help. I have tried several different things and can't seem to get it working right. Here is what I have: Form: <form id="search" name="search" method="post" action="<?php echo $currentPage?>"> SEARCH<br /> <input name="keyword" type="text" size="20" value=""/> <input type="image" name="Submit" src="images/team_icon_go_btn.gif" /> </form> Results: <?php if (isset($_POST['search'])) { $keyword = $_POST['keyword']; mysql_select_db($database_website, $website); $query_search = "SELECT Distinct docURL, docTitle, docDesc, docs.projID, groupCode, projCode, catName FROM docs JOIN subcat on subcat.subcatID=docs.subcatID JOIN cat on cat.catID = subcat.catID JOIN groups on groups.groupID=proj.groupID JOIN proj on proj.projID=docs.projID WHERE proj.projID=docs.projID AND docURL LIKE '%$keyword%' OR docTitle LIKE '%$keyword%' OR docDesc LIKE '%$keyword%'"; $search = mysql_query($query_search, $website) or die(mysql_error()); $row_search = mysql_fetch_assoc($search); $totalRows_search = mysql_num_rows($search); $proj = $row_search['projCode']; ?> <?php if ($totalRows_search < 1) { echo "No internal documents matched your request."; } else {?> <p><table width=95%> <tr><td colspan="3"><font size="+1">Internal Documents:</font></td> </tr> <tr> <td><strongLink </strong></td> <td<strong>Description</strong></td> <td<strong>Project </strong></td> </tr> <?php do { ?> <tr> <td> <a href="<?php if ($row_search['docs.projID'] == 1) { echo $row_search['catName']."/".$row_search['docURL']; } else { echo $row_search['groupCode']."/".$row_search['projCode']."/".$row_search['catName']."/".$row_search['docURL']; ?>"><?php echo $row_search['docTitle']; } ?></a></td> <td><?php echo $row_search['docDesc']; ?></td><td><?php echo $row_search['projCode']; ?></td> </tr> <?php } while ($row_search = mysql_fetch_assoc($search)); ?> </table> <?php }?> </p> <?php mysql_select_db($database_website, $website); $query_search = "SELECT Distinct toolURL, toolName, toolDesc, tools.projID, projCode FROM tools JOIN proj on proj.projID=tools.projID WHERE toolURL LIKE '%$keyword%' OR toolName LIKE '%$keyword%' OR toolDesc LIKE '%$keyword%'"; $search = mysql_query($query_search, $website) or die(mysql_error()); $row_search = mysql_fetch_assoc($search); $totalRows_search = mysql_num_rows($search); ?> <?php if ($totalRows_search < 1) { echo "No tools matched your request."; }
Corrupt Index.php
we are having a problem with our index.php file. our webhost says that it is corrupt, but i am not sure how to fix this - i am completely new to this the message we get when we try to access the site is: Fatal error: Cannot redeclare getfields() in /home/cust1/usr1127/html/management/lib/db/record_set.class on line 225 any help would be very much appreciated! i've tried to upload an old version of the file, but that obviously didn't work.
Undefined Index: Id
I have a website online which I have taken offline to work on it, but when I load the pages, I get the error Notice: Undefined index: id in C:wwwwebconnectwebsitedata.php on line 5 Code:
Undefined Index ?
I have some code with a problem. The code is: 1. <?php 2. $initStartLimit = 0; 3. $limitPerPage = 10; 4. $startLimit = $_REQUEST['startLimit']; 5. $numberOfRows = $_REQUEST['rows']; 6. $sortBy = $_REQUEST['sortBy']; 7. $sortOrder = $_REQUEST['sortOrder']; The errors starts with row 4: Notice: Undefined index: startLimit in *** on line ** Notice: Undefined index: rows in *** on line ** Notice: Undefined index: sortBy *** Notice: Undefined index: sortOrder in *** The code was created by "phpCodeGenie" and works fine on my webserver, which has php version 4.4.4 and mySql version 4.1.21 I just installed easyPHP on my home computer which has php version 4.3.10 mySql version 4.1.9 The errors only show up on easyPHP. My guess is that phpCodeGenie defined these indexes. How can I define them in EasyPHP ?
Update Table While Insert Data To Another Table
it seem like mine coding din work. [php]<? include("checkin.html"); $conn=mysql_connect('localhost','root','') or die ('Could not connect to server'); $today = date("Y.m.d"); mysql_select_db('hms', $conn); $ok = mysql_query("INSERT INTO check_in(ID,room_no,datein)values ('$ID','$room','$today')", $conn); if( $ok ){ $up = mysql_query("UPDATE studtable SET checked = 'checkin' where [ID] = '%ID'); if(mysql_affected_rows( $up ) == 1) { echo'Checked IN!' }else { echo'No such student to check in' }} else { echo'Check In FAILED, please check again'}?>[php]
Finding How Many There Are In A Var
how can I find out how many newlines there are in a variable? It's not hard to find out if there is a newline in the var, but I wanna know how many!
Finding Id Value
i am using php and mysql for this. i only want to keep the last 5 entries in the database. so i will add an entry in, which will have an ID value, then i want to delete the id with the lowest value, which in turn will be 6 from the last entry added. so the code will look like this: $oldid = $newid - 6; $deletethis = mysql_query("delete from table where id = $oldid"); is there a simple way to find the value of $newid ?
Finding Out An IP
I've been wondering for some time now, how to get every visitor's IP address and log them. Any ideas?
Passing The Whole Index Value From The List Box
I've got a problem here. I've a list box which list all the objects from a database. In addition, user can order the sequence of the object via the up and down arrow. The thing works fine for my javascript to order the sequence of the object list as wanted by the user. But how should integrate it with php that when the user click the button, then it'll get the value of the order sequence and insert it to the database. How it can get the whole index value from the list box and insert it into the database..??? I really wonder how to do that… Below is the code of how I generate the object to the list box and how to user can customize the order of the object sequence. <body bgcolor="#ffffff" text="#000000" id=all> <SCRIPT LANGUAGE="JavaScript"> <!-- … … //--> </SCRIPT> <? include "dbinfo.php3"; $query1 = "select * from sss order by order_id"; $result1 = mysql_query($query1) or die(mysql_error()); ?> <select name=abclist size=10 multiple width=180> <?php while ($array1 = mysql_fetch_array($result1)) { echo " <option value=$array1[sequence] > $array1[title] </option>"; } ?> </select> <br><a href="javascript:Up(window.document.abclist)"> <img src="up.gif" </a> <br><a href="javascript:down(window.document.abclist)"> <img src="down.gif" </a> </body>
Error Undefined Index
I keep getting the error: "Undefined index: page in ......." for this script: <? $page = $_Get["page"]; if (!$page){ $page = 1; } If the variable "page" isn't referenced in the url, I want it to be set to a default value of 1. This script works fine on one web server but not another. I'm assuming that it has to do with different php.ini files.
Undefined Index: Mode ...?
I was installing some "canned" php code and came across this error, and am not sure what it means. Undefined index: mode in line xx. here is the code snippet in case anyone can point me at something, or an ini setting. PHP Code:
Notice: Undefined Index:
I am getting the following errors: Notice: Undefined index: sender_name in c:program filesapache groupapachehtdocsallinone_form.php on line 12 Notice: Undefined index: sender_email in c:program filesapache groupapachehtdocsallinone_form.php on line 14.....
Renumber Array Index
Is it possible that I can renumber array indexes? The problem is that I am using array_unique, but it is returning something like this: [1]->value1,[3]->value2,[5]->value3 How can I reset the numbering, so the indexes are 1,2,3 (using a function would be preferable).
PHP Notice: Undefined Index
I got this error message below. How can i fix it... PHP Notice: Undefined index: REQUEST_URI in c:inetpubwwwrootguestbookguestbook.php on line 41 PHP Warning: Cannot add header information - headers already sent in c:inetpubwwwrootguestbookguestbook.php on line 41 any help is very much appreciated.
Sort Array Without Index
I'd like to sort a multidimensional array that hasn't numerical index, in fact it is like: Array ( [mobile] => Array ( [name_str] => mobile [relationCount_int] => 1 ) [video] => Array ( [name_str] => video [relationCount_int] => 2 ) [flash] => Array ( [name_str] => flash [relationCount_int] => 1 ) [tool] => Array ( [name_str] => tool [relationCount_int] => 1 ) ) And I'd like to sort, for instance for the value of "relationCount_int", so the new order should be something like: Array ( [video] => Array ( [name_str] => video [relationCount_int] => 2 ) [mobile] => Array ( [name_str] => mobile [relationCount_int] => 1 ) [flash] => Array ( [name_str] => flash [relationCount_int] => 1 ) [tool] => Array ( [name_str] => tool [relationCount_int] => 1 ) )
Array Index Question
I have source information in a file, and (part of) this information comes as coordinates. A coordinate consists of a letter followed by a number, ranging from a1 to i9 I'd like to count the number of occurrences of each coordinate, and put them in a matrix. The matrix should look like this (metasyntax): matrix = array ['a'..'i'][1..9] Later on in the script I'd like to be able to refer to a cell in the matrix by using the same letter/number combo. I know I can define an array using strings as keys, but how can I define a..i as keys without the need to specify them all individually?
Replace All Links With Url Index?
I'm writing a newsletter poster for a website. I have some html news items which I want to turn into plain text and prettify before emailing it. Now, i have found wordwrap and strip_tags so the only problem remaining is the links. Below you see what I like to see, but I haven't got a clue how to get there. $html = '<p>My <a href="http://go.there/stuff">link somewhere</a>.</p>' doSomeMagic($html); echo $html; After doSomeMagic I'd like the echo to look like this: My link somewhere[1]. [1] http://go.there/stuff That is, in the text I want an reference, and below the entire paragraph i want a link index.
Undefined Index Notices
I'm getting this: [client 192.168.5.50] PHP Notice: Undefined index: D1 in /var/www/html..... From this line of code: $id_option = $_POST['D1']; Which is posted by this: <form target="_blank" method="POST" action="mailchart.php" name="mail_data"> <input type="hidden" name="D1" value="<? echo $id_option; ?>"> <input type="submit" value="View Chart"></p> </form> My question is why? I *am* getting the correct value for $_POST['D1'] and at this point in time am really quite confused because that notice is getting thrown. [root@... ~]# php -v PHP 4.3.11 (cgi) (built: Nov 8 2005 06:24:40) [root@... /]# uname -a Linux ... 2.6.12-2.3.legacy_FC3 #1 Sun Feb 19 10:47:10 EST 2006 i686 i686 i386 GNU/Linux
Quotes Around Array Index?
I have a question about quoting array indices. This is from Rasmus Lerdorf's Programming PHP: Quote: You don't have to quote single-word strings. For instance, $age['Fred'] is the same as $age[Fred]. However, it's considered good PHP style to always use quotes, because quoteless keys are indistinguishable from constants. When you use a constant as an unquoted index, PHP uses the value of the constant as the index: Code:
Undefined Index: Error
simple php website that displays a table from my mysql database. To prep for my MCSE I moved my home server to Windows 2003 Standard, I installed mysql and php 5 to run some of my databases and websites. Under Linux the site worked fine, under windows I keep getting Notice Undefined Index error on line 67 I have went back to the basics just pull the data then display and still get the same error. 60 $sql = "SELECT * from newschool ORDER BY State, CollNam"; 61 62 $result = mysql_query($sql, $dbcnx) or die(mysql_error()); 63 $number_of_rows = mysql_num_rows($result); 64 65 while ($newArray = mysql_fetch_array($result)) { 66 67 $id = $newArray['id']; 68 $testField = $newArray['testField']; 69 70 echo "The ID is $id and the text is $testField <br>";
Preview On Index (substr?)
I want to make the posts on my index: www.datafuse.net shorter so people view the posts in full on their correct URL. But what I want is the script to cut as soon as it reads out a <br> tag. Any ideas?
|