INSERT Into Mysql Alway Make Two Entries
I code some site and because Im a freak I made my own session-handling. When a user open up my site it will check if there is a ssid in the url if not generate one. this will be done by a function generate_ssid() and works fine. next step is to register the ssid in the table session this will be done by the following code: ****************************** function ssid_register($ssid,$login,$uid,$admin){
$connect = mysql_connect( $GLOBALS["db_host"], $GLOBALS["db_user"], $GLOBALS["db_password"]) or die($GLOBALS["db_error"]); mysql_select_db($GLOBALS["db_name"],$connect) or die($GLOBALS["db_error"].'<br>ErrorCode s.001-con'); $result = mysql_query("INSERT INTO session SET ssid='$season',ip='$rip'",$connect); echo ($rs); return; } ******************************** I redesigned the INSERT INTO part into all possible syntax but everytime I look into the db, there are two entries with two DIFFERENT ssids. The only way it works correct is to dont use a variable on the first place. Means if I use ssid='godhelpmetofindaworkingsolution' it works great but is not realy what I want.
As told above a "INSERT INTO session (ssid) VALUES ($ssid)" also has the effect of two new db-entries.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
File_exists Alway Returns False
I've got two linux boxes running redhat9 and either PHP Version 4.2.2 or PHP Version 4.3.7. The file structure is set up the same on both machines and both files exist. The problem is not file specific and on both machines seq_tables is a symbolic link to another location. It makes no difference to either version of php whether I use double or single quotes when asigning a value to $filename. Nor does it matter whether I use single or double, forward(/) or back() slashes in the path. I don't use open_basedir in either php.ini file so this warning doesn't apply. 'If you use open_basedir in php.ini and use file_exists for file outside open_basedir path, you will not be warned at log and file_exists returns false even if file really exists.' So what else could cause the file to be found on the 4.2.2 version but not on the 4.3.7 version? <?php #####test script############################ $filename = '/var/www/html/seq_tables/lumbricus/sequences/CF610635' if (file_exists($filename)) { print("The file $filename exists<br>"); } else { print("The file $filename doesn't exists<br>"); } ############################################# ?>
Deleting Entries From Mysql
I have business listings that I have pulled from a database(MySQL) and printed to the page, in an admin page, for review. I'm trying to write a script to add and one to delete the listing. I get an SQL error, 'check the manual for blah blah near " on line 1' Here is the 'delete script:
Get All Entries From Today (mysql)
I currently have a page that each time a user visits it, the pageid and timestamp is thrown into a mysql daabase. so the database looks like so: linkid time 3 2007-08-22 17:26:21 3 2007-08-20 17:26:21 3 2007-08-22 18:36:59 2 2007-08-22 18:37:21 What i need is for php to show the total amount of visits today as per a certain time zone (or if thats not possible, the past 24 hours) soo.. Search for all occurrences where linkid = 3 today for a specific timezone (or 24 hours) MORE SPECIFICALLY User 1: Lives in New York (EST -5) registers for my site and sends visitors to his linkid (3) After two days, this is what the mysql table looks like: linkid time 3 -=- 2007-08-22 17:26:21 3 -=- 2007-08-20 17:26:21 3 -=- 2007-08-22 18:36:59 But mysql time isn't Eastern time, its another timezone. So when a visitor comes to user1's page at 3pm EST, mysql registers the time as 2007-08-22 17:26:21 So... I want to first add/subtract the number of numbers in the mysql database depending upon the user, and then see the amount of visitors for the day.
MYSQL Entries Won't Update
I am trying to update some entries in a mysql database that will append the filename to the end of a thumbnail directory entry. So for example /images/thumb/ would become /images/thumb/12345.jpg. I am stumped because the below code gives no php or mysql errors but the entries are not updated in the mysql db! Code:
How To Make A "sophisticated" Insert Record Form ?
I have a DB with many inter-related tables (MySQL) My main table called "content" has almost only foreign keys (integers) some have a 3 level relation (ex: content->city->region->country) I would like admins to be able to insert new records including all the "content" fields (in 1 page form) But how can I make an insert form that would display the related tables as list menus instead of a textfield with a number? (ex: select country from a drop down menu instead of typing the foerign key number) Main content Table: IDRef = primary key IDLocation = foreign key --related to tables city->region->country IDDescription = foreign key --related to table Description (=several big and small text fields) IDImages = foreign key --related to image (=image and thumbs path, alt text, etc..) Do you know any tutorial, help or solution ?
Multi Entries Update To Mysql
Could someone help me to figure out how to upgrade multi entries to Mysql by using PHP? Say, I have a table on Mysql id Priority 1 Okay 2 wait 3 later 4 asap 5 hold Now I want to upgrade that table to: id priority 1 hold 2 asap 3 okay 4 wait 5 later Is it possible to upgrade multi entries with one submitt button? If yes, could you tell me how it could be done. I knew I could do it by each entry (submitt button). Update priority set priority='$priority' where id = '$id'
Selecting 4 Random MySQL DB Entries?
I have a table set up in my MySQL database called 'features'. This table has 10 entries, but I only want to select 4 random rows and display them out in tables.
Limiting User Mysql Entries
I have a script i'm making which is going to be used to search for reciprocal links on different sites and I have user levels such as free, paid, ect... I want to make it so that if the person signs up as a free user they can only add like 2-3 domains to be searched for their links. How would I limit the number of domains allowed to be searched? Would I limit the number of mysql entries allowed in the table for the domains?
Populating Dropdown With Mysql Entries
I would like to create a combobox in Flash which is populated with mysql data and programmed with php. For example: There are 3 entries in database .ie. apple, bannana, peach. Now these I want in combobox in Flash MX/flash5.
Day View Calendar / Mysql Entries
I am trying to create a day view of a lab resource reservation system. So far, I've been able to generate a day view table with php, using variables for start time, end time and periods. Periods represent intervals on the day view. I have two columns in the table: the first one starts at the start time (say 8:00) and there is a row for every time until the end time, each row time being increased by the period, ie. 8:00, 8:30, 9:00 where the period is 30 minutes and the end time is 9:00. My second column in the table is filled with unix timestamps representing the date for that particular row, so the 8:00 row on July 1, 2007 is represented by a timestamp of 1183291200. I then created variables to represent start and end times and date of a reserved lab resource. I did a little switch statement in my second column of my table saying, if that row's timestamp equals the start or end time of my reserved resource, than give it a certain style. All well and good, except I need to tie this into a mysql database where the reservation details (start, end, date) are stored. Where I am getting fuzzy is how to integrate the query results from the database into my little system. I would like to have that second column pick up the results from my query and display the reservations, but I'm not sure now to do that. I'd like to post the code here, but I'm not sure how to post php code on these forums without getting yelled at for doing it wrong (I did that once, can you tell?)
Populate MySQL With Multiple Text Box Entries
I have about 300 rows of mysql data which I have chosen to diplay with a text box at the end of each row, that is available for adding comments. I would like to be able to add comments to entries and then have an update scripte that would take the text box, named "MC" and place the data in its row identified by a hidden field which would corrrespond to the Primary Key of the MySQL Database. I've done something similar using check box arrays, ie. Checkbox name="MC[]" My question is whether I can write a script that would test for a value in the corresponding text box, and update the MySQL data accordingly. I have also provided in my display script that if the MC column is already populated in MySQL it will not display in the form.
Deleting Duplicate Entries From MySQL Database Table
The topic is related to MySQL database. Suppose a table "address" contains the following records ------------------------------------------------------- | name | address | phone | ------------------------------------------------------- | mr x | 8th lane | 124364 | | mr x | 6th lane | 435783 | | mrs x | 6th lane | 435783 | | mr x | 8th lane | 124364 | ------------------------------------------------------- Quote:
Make A Table In MySQL
How do I make a PHP script that is able to make tables with fields? I want to be able to have a HTML form submit the fields. I just want to know the PHP scriptlet that will make a table.
Mysql_pconnect Make Mysql Too Many Connections
mysql_pconnect -> too many connections -> increase mysql max_connections -> take up more memory -> slower?! there's many static file: html/images and dyn file: *.php a php page is loaded, then images is requested, and then keep-alive idle, so most of mysql thread is idling... what can i do to optimize?
How To Make Display Links From Mysql Database?
i have the following problem and i am breaking my mind on it: I have a mysql database with (id,title,topic,body) in the database i have stored some documents. How can i display a link with only the title of the document stored?(easy one) but... I want to view the whole document in the same page! Let me explain in code: <?php $ip = "localhost"; $user = "kostas"; $password = "kostas"; $basename = "test"; $table ="docs"; $db = mysql_connect($ip, $user, $password); mysql_select_db($basename,$db); $result1= mysql_query("SELECT * FROM $table ORDER BY id DESC LIMIT 5 "); $myrow = mysql_fetch_array($result1); $title = $myrow["title"]; $intro = $myrow["intro"]; $body = $myrow["body"]; ?>
Insert Into MYSQL Using PHP
I'm having problems with a form I've created to insert or update into a MySQL database using PHP. The fields (some are varchar and some are text) sometimes contain single or double quotes or slashes or '¿' and some other special characters. These seem to throw off the INSERT process in one way or another. Either that or when I got to display this information, it doesn't come out right. Are there functions that I need to run on the information to make this database safe before I INSERT (or UPDATE) or before I display it?
PHP-MySQL Insert
$Insert_query = mysql_db_query( "INSERT INTO $Table_result VALUES('$Item_Name', $Item_Price)" ); Why do I get a parse error on this line of code???
Insert Into MySQL
I have a system from a company called ProTx they provide online credit card transactions. I have their PHP code, and have had to change some parts of this to work correctly but am getting stuck on this part. This code, is part of a page that sends off some variables to their server and expects a response. I am able to send the variables, and get the response but I want to put them into a database so that I have all refunds seperate from all orders. PHP Code:
Mysql Insert
I can't figure why an INSERT query won't work. This is the table: downloads ---------------- id - int(10) - auto_increment category - char(1) file - text date - varchar(20) user - varchar(50) desc - text These are the variables: $category = "1"; $file_name = "cow.gif"; $date = "0000-00-00 00:00"; $login = "fresh"; $desc = "Bertha the cow."; This is the code: PHP Code:
Cannot Insert In Mysql Using Php
i have a problem about inserting data into the table. I dont know why the output always said cannot be added to the database! Anyone has idea for me? i check the connect is ok, but dont know why. The following is a function i will call to insert the database. Thx!!! function AddPart($Partnumber, $Partname, $Partdescription) { //Set the variables for the database $DBName="krista"; $TableName = "parts"; $Link = mysql_connect("localhost","","") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db($DBName,$Link); $Query = "INSERT into $TableName (Part_Number, Part_Name, Part_Description) values ($Partnumber, $Partname, $Partdescription)"; if (mysql_query($DBName, $Query, $Link)){ print("Your information is successfully added to the database!! <BR> "); } else{ print("Your information cannot be added to the database! <BR> "); } //close MySQL mysql_close($Link); }
INSERT Mysql
How do I write something to a mySQL server using PHP?
Cannot Make Connection To Local MySQL Server From Within Dreamweaver.
I am using OS X and Dreamweaver MX. I am trying to make a connection to the MySQL Server from within Dreamweaver using the Applications panel and clicking on the "+". A window opens asking for: Connection Name: Apress MySQL Server: localhost User Name: apress Password: xxxxxx Database (Select): When I click select so the Dreamweaver can browse to the databases in MySQL the connection is not being made because Dreamweaver cannot find the MySQL Server. I think that "localhost" is wrong even though I am using the APRESS book: PHP Dreamweaver MX 2004 and it says to use localhost. MySQL and PHP are on my local machine. I am NOT using a remote machine. I used phpMyAdmin to create the databases.
Optimizing MySQL To Make Site Load Quicker
I recently coded a site that is based mainly off of mysql. I currently query the database 4 times in two for() loops I'm not sure how to change it, because I see no other way. I can't put the queries outside of the loops because in the loop it queries something different every time. I want some help optimizing it! However, I don't want to post all my code here, because it's basically the main part of my site, and I don't want others copying me.
How To Make MYSQL Query To Sort The Articles By Date ??
I am developing a site using PHP and MYSQL where i can post articles. Each Article has features like author, date, data etc... I want to find out top 5 recent articles. I store the date of an article in database as $timeStamp = Date("F j, Y"); when i make a query to retrieve the latest article by date as: $result = mysql_query("SELECT * FROM postData ORDER BY postDate DESC LIMIT 0, 5"); it doesn't give any output...
Upload Image, Make New Random Filename, Add New Name In MySQL
below you will find my code. In this page I have established a database connect already. the file uploads perfectly with my new name. My real question is how can I put my new file name in my database form my variable $newName. What would be the proper code to do this? Code:
Make Data Safe To Input To Mysql Database
I'm just wondering what kind of things I should do to make sure that inputs from a form are safe to put into a mysql table? I'm currently using ereg() on an input to make sure that only numbers are entered, but on other forms I've got thiongs such as names and other details. How do I make sure that they're not going to break my table?
No Libphp4.so File Created In Make Intstall Or Make.
I have done a make, and a make install on the 4.3.6 version, using /usr/local/etc/php as the directory I make from. However, no matter what I do, I do not see a php4lib.so that has been created. The documentation I recieved (an IBM source) says that the following has to be added to the httpd.conf file : LoadModule php4_modulelib/apache/libphp4.so .. .. .. AddModule mod_php4.c here is the output from my make install : [root@mail php]# make install Installing PHP SAPI module: cgi Installing PHP CGI into: /usr/local/bin/ Installing PEAR environment: /usr/local/lib/php/ [PEAR] Archive_Tar - already installed: 1.1 [PEAR] Console_Getopt - already installed: 1.2 [PEAR] PEAR - already installed: 1.3.1 Wrote PEAR system config file at: /usr/local/etc/pear.conf You may want to add: /usr/local/lib/php to your php.ini include_path [PEAR] DB - already installed: 1.6.2 [PEAR] HTTP - already installed: 1.2.2 [PEAR] Mail - already installed: 1.1.3 [PEAR] Net_SMTP - already installed: 1.2.3 [PEAR] Net_Socket - already installed: 1.0.1 [PEAR] XML_Parser - already installed: 1.0.1 [PEAR] XML_RPC - already installed: 1.1.0 Installing build environment: /usr/local/lib/php/build/ Installing header files: /usr/local/include/php/ Installing helper programs: /usr/local/bin/ program: phpize program: php-config program: phpextdist
PHP INSERT Code (MySql)
Ok... i want to insert info into a db using php and mysql... I can connect to the db using most of this code the only thing i am having trouble with is the 'mysql_result'.... If anyone could help. that would be great... thanks. This is the code im using... my sql statement is fine but im not sure what php code to use... <?php $db = mysql_connect(sql,username,password); $sql = "INSERT INTO tblMyTable (name,address) VALUES ($strName,$strAddress)"; $res = mysql_db_query(username, $sql) ***here is my problem... what goes here? mysql_result($res,0); ***that was my guess but its not working.. ?> I couldnt find the code in the manual.. If anyone could help that would be great thanks
Insert Into Mysql Database
It sounds very simple, but for some reason I just can't figure it out, and it will save a lots of time to me, if someone can direct me into the right direction. I was trying to input data into mysql table through post method, but it was not working. I made it simple and just tried to enter anything from a php file, but it does not work, so there is something that i am doing wrong with the insertion query. $link = mysql_connect($hostName, $userName, $password); echo("connected"); mysql_select_db($databaseName, $link); echo("database selected"); echo ($databaseName); mysql_query("INSERT INTO image VALES('','','','','','','','','', 'hello', '', '', '','','','','')", $link); echo ("done"); I am trying to enter into one of those fields, but it does not populate the table in mysql database.
PHP -> MySQL Insert Statement
heres what i am using : Code: if (($p1 == $p2) && ($p1 != " ")) {print "accepted"; print "<br>entering you into the database...."; $enter = 'INSERT INTO member(name, psw) VALUES("$name", "$p1")' $goenter = mysql_query($enter) or die("Entery Failed due to " . mysql_error());} else {print "<br><font size=+1>Password did not match, try again!</font>";}} ?> now heres the problem : when it writes to the table (all the db selection etc is fine) all that gets written is : "$name" and "$p1" literally $name and $p1 *** not their values. I have tried combinations of quotes ( as " " will interpolate but ' ' will not) but still no dice. and w/o the quotes around the values ("$name" , "p1") --- it will return an error stating the colum ($name value) does not exsist.
Mysql Insert Just Wont Have It!!
i have the following query to insert data into a table with 7 fields... one of the fields only need the default value to start with and the other is and auto increasement field. PHP Code:
Insert Time Into MySQL
I have a page in which the user selects the time with comboboxes labled: hour - minutes - ampm when the user clicks on submit this function gets called to format the selected time:Code:
Return The Key From Last Mysql Insert
How do I return the auto incremented value of the primary key from a tuple that I have just inserted into a MySql database. If that is not quite clear enough then this long winded explanation should explain what I mean: Say I have a MySql table called "n" with two columns: 1: id = Autonumber - Primary Key 2: name = Text If I insert a tuple with the following mysql command using a PHP interface: Quote: INSERT INTO `n` ( `name`) VALUES ('Paul Smith') Then a tuple with with values say (34,Paul Smith) will exist in the MySql table. 34 is the value of the auto generated primary key. The question is how can I find this value 34, which is the primary key, without running a statement like : Quote: SELECT * FROM `n` WHERE `name` = 'Paul Smith'
MySQL INSERT Problem
I am trying to insert data into the fields id and term of the table key. id is an auto-incrementing field. Each of the following forms fails:- INSERT INTO key (id, term) VALUES (0, 'dog') INSERT INTO key ('id', 'term') VALUES (0, 'dog') INSERT INTO 'key' ('id', 'term') VALUES (0, 'dog') INSERT INTO 'key' (id, term) VALUES (0, 'dog') mysql_error() returns messages of the following form:- 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 'key (id, term) VALUES (0, 'dog')' at line 1 What is wrong with the syntax?
Get The Last Insert Of A Mysql Tabel
how can i get the last insert of my userid column its not the primary id if there is one it should add one to this number and save it in a varible so every user gets another userid Code:
MySQL: INSERT If Name Doesn't Exist
I am trying to write a query that will insert if a row with the same name (col='name') doesn't alread exist. So basically, if the query trys to insert Jim, but Jim is already in the table, it will skip the operation. Can anyone tell me how to do this? Also - is it more efficiont to run one query with multiple inserts or multiple queries with one insert.
MySQL Insert With PHP Array
I have a form that collects input to be stored in a database. I want to store each field in the form in the database. But for some reason this code doesn't work: PHP Code:
Using Php To Insert Data Into MYSQL
I just whipped up this script for part of our project. Do the insert statements and script look legit in order to make php insert data into my mysql tables which I already created in previous scripts? Code:
Default Value To Insert Into MySQL
What should I insert as the default value if a form field is blank? My fields don't currently accept null. if($_POST['height']) { // error checking $height = $_POST['height']; } else { $height = ''; } Should $height be equal to '', NULL, or maybe 'NULL'? I'm thinking 'NULL' incase I or someone else decides to change the field to accept null?
PHP MYSQL Insert Syntax
$q = "INSERT INTO downloads (sub, title, name, email, link, date, description, pic) VALUES ('$c', '$t', '$n', '$e', '$l', 'NOW()', '$d', 'NULL')"; $addinfo = mysql_query($q); Does that look right? I don't have many resources for php and mysql.
Bulk Insert => MYSQL
How do I instert multiple rows of SQL into a database from a php file? Is there a way to have a PHP file read a MYSQL DUMP (.sql) file and run it?
Mysql Insert Query
I can't figure out whats wrong witht his query. Quotemysql_query("INSERT INTO `serverInfo` ( `id` , `serverid` , `size` , `filename` , `timestamp` ) VALUES('null', '1', '".$size."', '".$dir."', '".$date."'") or die(mysql_error()); Anything stupidly wrong here? the id,serverid, size, filename,timestamp thsoe are all right. Error: 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 '' at line 1
MySQL: Insert...select - Update?
I was reading about insert select http://dev.mysql.com/doc/mysql/en/insert-select.html Thought this may be a better way to perform a query I'm doing. The differenc is that I need td select from one field, and then update another field in the same record (it is a backup/undo field). Is there a way to do this in one query? It's a large chunk of data (longtext) so I thought this would be faster than the alternative...
|