Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




After Mysql Insertion Another Row Is Added


on the site i am developing i have noticed after a database insertion is made, mysql insert another row (but only the id increments by 1)

if i insert:

id---name---age---country
1 ---Graham---28---Scotland

right after this will be:

2 ---blank---blank---blank

i checked the inserts carefully it all seems fine, then tried LIMIT 1, with the INSERT INTO but that didn't work, any ideas on what this could be?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Get ID For Newly Added Mysql Data
how can I get the id (primary key) for the recently added data from insert query.

How To Display Newly Added Mysql Column
I have a mysql table and i want the user to add columns using a php
interface and then display the table with the newly added column. I
was thinking about putting all the columns names in a special table
but there must be another more efficient way.

as an example this is my query to display the table:
$result = mysql_query("select * from news");
while($r=mysql_fetch_array($result))
{
$title=$r["title"];
$message=$r["message"];
//display the row
echo "$title <br> $message <br>";
}

now if the user alter the table and add a column "rank", how can i
update my query automatically so it can display the newly added row
(or column)?

Mysql Data Insertion
I am using this script to load a file into the webserver, and store the path in the database. That is working fine. However, when I try to upload other information from the same field I keep getting the field name in the data. Code:

Image Upload & MySQL Insertion
I am having a bit of trouble getting my script to work. I am trying to get a file (image) to be uploaded to a specified path and insert the file name, a timestamp, and id into my MySQL database to later pull the files that I uploaded out from the DB and display them on a page. Could someone tell me what I am doing wrong? It displays the image upload form, just as I want it to, but if you submit the form, it just takes you back to it and does nothing. It doesn't give any errors, upload the file, nor does it insert anything into the DB.

Image Insertion And Retrievel Using Mysql
I've managed to get images inserted in mysql and can pull them out for display, but for some reason it looks as if the bottom 4th of the jpg photos do not show. Is there a space limitation for blobs?

Drag And Drop Insertion In MySql
I'm developing a site in PHP/MySql that requires Ajax for this feature
: The user read an article and if ever he likes it he can drag it and
drop it into his "basket". Then when he'll consult its account he'll
found that article.

Drop Down Menus And Mysql Insertion
I'm looking to create drop down boxes for a user to select the date and then have it insert what they select for month, day, year, hour, minutes and insert it into mysql. It needs to be organized in a timestamp like so: 2007-02-28 21:06:40

I've created the drop down boxes and it works pretty well: Code:

Insertion Of Data Into MySQL Tables By Date?
My assumption is that when you insert data into a MySQL table, the latest data is put on the bottom, and is thus the farthest from the beginning of any search you'd initiate. I assume the search starts at the top-most row (oldest) and works it's way down.

Since I'd like to search the latest data, and pull only about 10 rows of data, the most efficient manner would be to have the tables structured such that the newest content was always on top (a date-wise descendent structure).

There must be a way to create a table such that any insertion would be put on top. I know I can ORDER BY date when doing a SELECT command, but that would entail searching the entire data set; isn't there a way to define the table ahead of time such that a date/time column is always ranked in descending order?

Why Is Localhost Added To All My Links ?
Not sure if this is a php, mysql, or apache issue. I use win2k and I
have AMP on my system as a localhost. I use this to test PHP/MYSQL
scripts I write on my local PC.

I render a URL w/PHP by reading the URL string from a mysql field, eg.
on the php web page it shows as eg. www.yahoo.com link

But when I click the link I see that "localhost" is added to the URL
and it goes nowhere. ie. it get localhost added to the front -
localhost/www.yahoo.com

Is there a setting somewhere so that the link is exactly what the link
is and localhost is not added.

All I Need Is A Couple Of Lines Added To My Script.
categories table info :

id: unique auto increment
parent_id: all master categories =0
sub categories = id of its master category
name : name of category

The script I've written is supposed to each master category in the table followed immediately by any sub-categories it may have. If a particular master category does not have any subcategories it should fetch the next master category.

My script works fine up to the point where the table contains a few subcategories before the next master category. At this point it lists out the subcategory (which has already been listed earlier within a master category) again assuming that it is a master category.

All I need if an if or while statement in my script. I've tried different variations, but nothing worked.

Here's the script:

Exec Can't Work Even Added Safe_mode_exec_dir
I've downloaded the convert class to convert 3gp, mov, wmv to flv. As
the php file is small, i just posted all the original code at the end
of this message.

My problem is about the exec function in safe mode. I installed xampp
which bundled Apache, PHP and MySQL in Window Server 2003 SR2. I've
added the following entry already in the php.ini file:
safe_mode_exec_dir ="C:Program Filesffmpeg"

The php page run without any error prompted but there isn't any output
file. When I turn off the safe mode, output file appeared. Is there
anything I need to set beside the safe_mode_exec_dir?

No Error Message But No Data Added?
This is my script for uploading binary files and store them in mysql. It runs without error, but no file is added to the db? Anyone with a hint?

Here it goes:

[error] An Unknown Filter Was Not Added: PHP
I'm getting this error in my error_log in apache. Can anyone offer any
assistance in fixing the problem?

I'm using RH 9 with apache 2.0.53 and PHP v4.3.11

[Fri Apr 29 09:32:03 2005] [error] an unknown filter was not added: PHP

.........

[error] An Unknown Filter Was Not Added: PHP
Anyone know why this message would appear in my error_log. My PHP code
executes fine...but it is outputting this to my error_log and I cannot
figure out why. I've been looking for a couple days...but have not found
any reason/fix on the web for this message. My php.ini and php.conf look
fine.

Exclamation Points Being Added To Email Script?
I'm using an email script that takes form values and passes them to various email addresses depending on a selection choice in the form.

Anyway, I've been getting exclamation points being added at random in the text of the email. For example, one time I'll have a line saying >> Name: Joe Smith City: Ch!cago.

The next time it may show >> Nam!e: Joe Smith City: Chicago or else not include an exclamation point.

Also, if I try to use some simple html tags (eg <b></b>) it will work correctly for a couple lines then the rest of the lines will be bold as if the </b> isn't being read. This is a random thing also as each email has different lines "bolded".

Has anyone come across this type of thing before with using PHP, HTML, and Email?

Searching A Website - Including All New Added Pages
Basically, i need to write a php search function which will search all
our pages in the directory depending on user keywords..

the thing is, this could be difficult as we may have 8000+ dynamic
pages (these would also need searching) plus we will be adding more and
more of these dynamic pages (so wont have a list of page names).

Escape Characters Added To Form Data
Some characters entered in the text fields of a form get an escape
character. What is the reason? How can I prevent/remove this?

Here is an example:
<form action=hello.php method=post>
<input type=text value=firstname>
</form>

If the user enters:
O'Hara

And I have the following file hello.php:
<? echo $_POST['firstname']; ?>

The output is


I Have 100 Servers Which Need A New Backup Server Added To A Text File,
This seems easy but I have been asking tcl and python IRC chat all day
and no one gave an answer.
I have 100 servers which need a new backup server added to a text file,

and then the backup agent restarted.
If I have a list of the servers, all with same root password, and the
connection is ssh.
How do I connect to the server, cat the line to the config file, stop
adn start the agent, and then do same to next server in list and
iterate through the 100 servers.

Saving Data Into Database From A Dynamically-added Textbox
let's say i have a html form with textboxes that can be dynamically added with javascript.

i'd like to save each of the textbox's value into a new different row in the database.

so i'll have this in my html form:

<form action='/add' method='POST'>
    <a href='javascript:;' onclick='addTextBox()'>Add New Field</a> <!-- new textfield/textbox will be added dynamically everytime the user clicks</a>
</form>

so basically i should do something like this in the serverside:

for ($i = 0; i < totalTextBoxes; ++i) { // iterate every textbox in the html form
    mysql_query("insert into `books` value (textBoxName[i]); // for every textbox save it into a new row in the table}

the problem is, since i created the textbox dynamically using javascript, how can i tell php how many textbox that i actually have there?

PHP Mail Function, Some Exclamation Marks (!) Added In The Text
I use PHP mail function to send emails, when I receive these emails I find some exclamation marks (!) added in the text, this is weird....

Extra Newlines In Output Text Added By PHP File Include
I have a simple PHP script that outputs a string requested by an Ajax
page. XMLHttpRequestObject.responseText as received from the PHP script
begins with 2 extra newline characters (

MyString):

<?php
require_once('DB.php');
require_once('../myDir/myFile.php');
.......
echo('MyString');
?>

myFile
<?php
$var1 = 1;
$var2 = 2;
$var3 = 3;
?>

If I manually write the contents of myFile.php into the script, there
are no extra newlines in responseText.
Am I missing something?

SQL Insertion Problem
I am have a little problem with inserting some info into my database. What I would like to do is be able to select the last row of my database because my data is sorted by database the most recent date will be at the bottom of my database.

This script is being used for uploading files and when the user uploads files the date is stored with it thats why the date is the most recent at the bottom.

Anyways I understand that mysql_num_rows($var); will tell me how many rows of data are in my database. I have tried a million times to use a for loop to get the last row of data.

There has to be some way to just extract the last row of data from my database I just dont know how.

Date Insertion ?
I am inserting date in a table as following....is it the correct way ?

$dt = getdate();
$day = $dt['mday'];
$month = $dt['mon'];
$year = $dt['year'];
$dt = $year."-".$month."-".$day;

$query = "insert into Articles(PostedDate) values('".$dt."')";
$result = mysql_query($query,$con);

Stripping Chars Before SQl Insertion
I have a form with an input box that the user puts in a dollar amount. I dont want them to put a dollar sign or anything else apart from the currency amount (1.00, 1,658 etc). How would I achieve this?

Problem With Ip Address Insertion
This problem is manifesting it self outside PHP at the level of directly typing commands into the MYSQL application itself. Obviously it is going to have the same effect inside PHP. I need escape characters or something but nothing I have tried works.

typing the command
INSERT INTO table(ip,commentfield)VALUES ("111.222.333", 'old spammer');

results in only the characters 111 appearing in the ip field . It is defined as a char 16 field.

Multiple Insertion Querry
I have an array of data in PHP. I would like to insert each member of the
array into it's own row in SQL. The array is of variable length, so it
would have to be dynamic code. How would I go about this? Would I stick
the SQL querry generation and actual querry into a while loop? This would
generate a lot of traffic between the SQL server and the PHP script.

The arrays are each over 1000 members long, however, this is an rare admin
script that will be run roughly 4 times a year, so I guess it isn't that
bad. If possible however, I would like to do it in one querry. Is that
possible? I thought I heard somewhere that it's impossible to run more
that one querry at once through PHP as a failsafe for users sticking bad
data into forms. (ie, you cant do: "querry1; querry2;", you have to do
"querry1;" querry it, then do "querry2;"

Insertion Of Data Not In Order
I have a slight problem with inserting data into MySQL tables with PHP. So far, everything that is entered into my form does get inserted correctly, meaning all data is added successfully to their respective columns. However, sometimes when I insert another set of data, it appears on top of the preceding data. The first column in my table is called 'employid', it set to auto_increment and primary. Code:

Stripping Chars Before SQl Insertion
I have a form with an input box that the user puts in a dollar amount. I dont want them to put a dollar sign or anything else apart from the currency amount (1.00, 1,658 etc)
How would I achieve this?

String Insertion And Extraction
is there a function to replace  a section af a string with another regardless of the values and to do the reverse i.e.

$srt1 = "ABCDEFGHIJKLM")
$str2 = "XY

// insert $str2 in to $str1 [3] and [4]
$srt1 = "ABCXYFGHIJKLM")
AND
$str = $str1 positions [7] and [8]
$str = "HI";

I want to do some incripion on text. OR will I have to create something?

Getting Primary Key Value Of Last Database Insertion
I have a very simple issue.  I have a bunch of data I'm inserting into a database to create an article.  When complete, I want to redirect to the article, but I need the node_id.  It just so happens that the node_id is the Primary key and is automatically generated by mySQL at insertion time.  Is there an easy way to get the value of the Primary key for the most recent insertion?

Stop Sql Insertion On Every Page Refresh
The page has a form which basically take in a file name, and and upload button does the uploading.

the php code at the top of the page takes the file name and insert the name into a database.

the problem is: everytime the user presses the refresh button, a new entry is inserted into the database.

Two-Dimensional Array Insertion And Print
1. return results from an Oracle query into an array. there are 3 fields and approx. 2,000 records.

2. insert the results into an array of some type, inside of a loop, obviously.

3. print the results so i can verify the query is working.

PHP Code:

Code Insertion + Escape Chars
I'm updating my scripts a bit, and I was wondering how I could insert data in a textarea just by clicking a button. For instance add a Url or a smily ... (just like in these forums when posting)

An other question, how do I make sure I don't need to use a to get a ' For instance if I want to add content containing a " ' " I need to write "hello I'm ..."

Preparing Text For Insertion Into Database
I insert text into a MySQL Database using a TEXT field. PHP syntax is:

$query = "INSERT INTO data (text_field) VALUES('$text_field')";

The problem is, when the user has an apostroph (like "friggin' cool") in the text, MySQL misinterprets it, and the query is invalid. Is there a PHP function that formats the that input so it can be entered into the database?

Form Calculation Before Database Insertion
My problem is that i want to make a form where will be made calculations and after the calculation are made, the user should press submit and then, all the values from the form should be inseted into a database.

My code is writen under these lines, but all I want to do is the value code to be calculated from Nume and Prenume (for example, if the Nume value is 2 and Prenume value is 3, in the form the value of code should be 5. Code=Nume+Prenume, but i don't know how to write to make the calculation in real time. Code:

Today's Date In Database Insertion
How do I insert today's date in a certain database row without using the date() function for a string?  For example, when you use PHPMyAdmin to insert a new table row and there's a column with the type "date", it gives you options such as CURDATE, NOW, etc.  How would I use that in a database query?

Avatar Script Insertion Vulnerability (Security)
Looking at http://secunia.com/advisories/17295/ , it seems possible to embed javascript in images in a special way.

So, if a user provides an avatar or an image url like this pointing to an external site, they will be able to hack accounts.

Do you know how this can be avoided? And/or, how sites like vbulletin/phpbb/smf type of applications protect users from this?

Preventing Multiple Data Insertion On Page Reload
I am developing a PHP-mysql database. It is noted that when the
browser window is refreshed the data is inserted again in the
database. unfortunately there is no unique keys that I can use to
verify the existance of the data, so as to prevent the multiple
insertion. Is there any other way to prevent it otherthan introducing
another field for this purpose and verifying its existance?

Generate An Html Form, To Be Submitted For Insertion To A 3rd Table
1. display a form consisting of radio buttons and check boxes. multiple selection of check boxes per radio button basically.

I got this part done, it displays the data in the form which is being pulled from two separate tables.

2. Insert for each check box a record into a third table of the check box and radio button.

this is what i have thus far and I'm not really sure why it's not working from what i can see step by step it should be inserting the records, these arrays are the most terrible thing i can think of having to do. Code:

Complicated Email Parse Or Text Extraction And Database Insertion
I am trying to strip some data out of numerous emails and place it in
my database. I know that this seems as if it has been done before.
But, this is a little different. First, the numerous emails all have a
set of data that needs to be extracted and inserted into the database.
Some of the data in the email is id, name, address, city, state, zip,
company, etc. The catch is that the date is formated and presented
differently in each email. Take into consideration the following email
examples:

- excert from email #1
ID:.............. 12345
Name:............ JOHN DOE
Address:......... PO BOX 9999
City:............ Somecity
State:........... CA
Zip Code:........ 90210 ....

PHP And MySQL: How To Properly Call A Stored Procedure With Output Parameters From PHP - Mysql, Mysqli, Or PDO
I am currently using PHP 5 and MySQL 5, both on Fedora Core 5. I am
unable to call a MySQL stored procedure that returns output parameters
using mysql, mysqli, or PDO. I'm having a hell of a time with it...

The following comes from phpinfo():
PHP Version: 5.1.2
mysql Client API version: 5.0.18
mysqli Client API version: 5.0.18
PDO Driver for MySQL, client library version: 5.0.18

MySQL version, from running SELECT version(); = 5.0.18

Here's the procedure I've created in MySQL:
CREATE PROCEDURE testproc(OUT p_testvar varchar(50)) BEGIN SET
p_testvar = 'HELLO WORLD!' END
[color=blue]
>From the MySQL Command Line, I can do the following:[/color]
mysql> call testproc(@a);
Query OK, 0 rows affected (0.00 sec)

mysql> select @a;
+--------------+
| @a |
+--------------+
| HELLO WORLD! |
+--------------+
1 row in set (0.00 sec)

MySQL Error - Supplied Argument Is Not A Valid MySQL-Link Resource
I am getting the error

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/server7/public_html/71/arranholloway/database4.php on line 7

I tested my code on local computer and there were no problems, the error message only appeared when I loaded it onto my web hosters server. I'm new to PHP so its probably something simple but any help would be appreciated.

Connection With MySQL. Navicat - CANNOT CONNECT TO MYSQL SERVER ON LOCALHOST
I am new in PHP & MYSQL. I installed PHP & MYSQL properly. To easy
operate for MYSQL I installed Navicat and it installed properly. But
when I am going to test the connection between MYSQL & Navicate the
error message showing CANNOT CONNECT TO MYSQL SERVER ON LOCALHOST
(10022) it should mention that my connection name = localhost, Ip =
localhost,port = 3306 , user name = root in Navicat.


PHP Saying Error In Mysql Syntax, But Written My Mysql Query Browser!
I have a basic db that I access with MySQL query browser. Everything
seems fine to me but I am using this db as part of a php shopping
basket and when I try to add an item I get:

Notice: Query failed: You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near '>function.extract]: First argument should be an
array in functions.inc.php on line 31
Notice: Undefined variable: price in functions.inc.php on line 36
Notice: Undefined variable: price in functions.inc.php on line 39
Notice: Undefined variable: total in unctions.inc.php on line 39

I'm assuming the last three are caused by this problem as price should
be passed to the cart, and total is worked out using it. However
although I know mySQL code it was the MySQL query browser that
actually generated the code and I cannot see a way to view or debug
the code.

The db has one table in it which is made up of id, name, subname,
desc, and price.

The code in the php file that is being referred to is:

Automatic Scheduled MySQL Backup (MySQL Dump)
Is it possible to configure a UNIX/LINUX server to do a MySQL Dump for a database on an automatic schedule and then to email the dump file to me (the administrator)?

I want to be able to have my database automatically backed up every week and emailed to me for storage purposes without any action on my part.

PHP/MySQL: Using PHP To Probe MySQL Db And Send An Email Automatically
Let's say you have a login feature on your site... and a user forgets their password which is stored along side their email address in a MySQL database. Is it possible to use PHP to automatically send the password to that email address upon request? If so, please provide a detailed solution. If not, can Java be used in some way to accomplish this?

--with-mysql ? Php-4.4.2 With Mysql Install In Special Directory
I'm trying to link php-4.4.2 with mysql install in special directory,
like /usr/newsystem/mysql, but whatever options I try, php always gets
linked to version in /usr/local/lib. I've tried several options:

--with-mysql=/usr/newsystem/mysql
--with-mysql-dir=/usr/newsystem/mysql
--with-mysql-lib=/usr/newsystem/mysql
--with-mysql-lib-dir=/usr/newsystem/mysql

....but none of them work, CLI is always build against /usr/local/lib/
libraries.

Create A Sequence In MySQL, With Mysql Variable?
This might be fairly easy to do and I think I've seen the code before,
but I haven't seen many good examples of this. Of course Pear::DB
probably uses this code in some of its API, probably in dealing with
auto-increment indexes and prepared statements.

Maybe I'm off base here, but I'm looking for something like this:
(psuedo-code)
Of course the seq table only needs 1 row holding id, which is
updated.
select id from tbl;
// get result resouce and do fetch, store value in $myid
set @myvar = $myid + 1; // can php send to MySQL with a query? (
never seen this )
update myseq set id=@myvar // send this statement through in a
update/query

// for use in PHP code
$newSeqVal = $myid +1

Create A Sequence In MySQL, With Mysql Variable?
This might be fairly easy to do and I think I've seen the code before,
but I haven't seen many good examples of this. Of course Pear::DB
probably uses this code in some of its API, probably in dealing with
auto-increment indexes and prepared statements.

Maybe I'm off base here, but I'm looking for something like this:
(psuedo-code)
Of course the seq table only needs 1 row holding id, which is
updated.
select id from tbl;
// get result resouce and do fetch, store value in $myid
set @myvar = $myid + 1; // can php send to MySQL with a query? (
never seen this )
update myseq set id=@myvar // send this statement through in a
update/query

// for use in PHP code
$newSeqVal = $myid +1


Copyright © 2005-08 www.BigResource.com, All rights reserved