[PHP-DB] Re: Insert Newbie
$result = mysql_db_query($db,$SQL,$cid) or die (mysql_error()); ...should give you and idea. On Sun, 22 Sep 2002 12:05:19 +, Brandon Boyce wrote: Below is the code I used to try to insert info into a mysql database, the form posts to itself. After I hit the submit button it isn't echoing the indication that information has been added, and when I check the database there isn't anything there. help please! ? $usr = username; $pwd = password; $db = dbname; $host = localhost; # connect to database $cid = mysql_connect($host,$usr,$pwd); if (!$cid) { echo(ERROR: . mysql_error() . \n);} ? HTML HEAD TITLEInsert Link/TITLE /HEAD BODY BGCOLOR=#FF PFONT SIZE=5B Add Link /B /FONT/P ? if ($REQUEST_METHOD==POST) { $description = str_replace(','',$description); $sitename = str_replace(','',$sitename); $SQL = INSERT INTO links ; $SQL = $SQL . (category, sitename, siteurl, description) VALUES ; $SQL = $SQL . ('$category', '$sitename','$siteurl','$description') ; $result = mysql_db_query($db,$SQL,$cid); if (!$result) { echo(ERROR: . mysql_error() . $SQL\n);} echo (PBNew Link Added/B/P\n); } ? FORM NAME=fa ACTION=insert.php METHOD=POST TABLE TRTDBCategory: /B /TDTDINPUT TYPE=text NAME=category SIZE=40/TD/TR TRTDBSite Name:/B /TDTDINPUT TYPE=text NAME=sitename SIZE=40/TD/TR TRTDBSite URL: /B /TDTDINPUT TYPE=text NAME=siteurl VALUE=http://; SIZE=40/TD/TR TRTD VALIGN=TOPBDescription: /B /TDTD TEXTAREA NAME=description ROWS=5 COLS=40/TEXTAREA/TD/TR TRTH COLSPAN=2PINPUT TYPE=submit VALUE=Add Link/P/TH/TR /TABLE /FORM ?mysql_close($cid); ? /BODY /HTML -- Jason Morehouse (jm[@]netconcepts[.]com) Netconcepts - http://www.netconcepts.com Auckland, New Zealand Linux: Because rebooting is for adding hardware. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Re: Insert Newbie
Yeah, that too =) On Sun, 22 Sep 2002 22:02:31 +, John Holmes wrote: From manual page on mysql_db_query(): Note: This function has been deprecated since PHP 4.0.6. Do not use this function. Use mysql_select_db() and mysql_query() instead. ---John Holmes... -Original Message- From: Jason Morehouse [mailto:[EMAIL PROTECTED]] Sent: Sunday, September 22, 2002 8:59 PM To: [EMAIL PROTECTED]; Brandon Boyce Subject: [PHP-DB] Re: Insert Newbie $result = mysql_db_query($db,$SQL,$cid) or die (mysql_error()); ...should give you and idea. On Sun, 22 Sep 2002 12:05:19 +, Brandon Boyce wrote: Below is the code I used to try to insert info into a mysql database, the form posts to itself. After I hit the submit button it isn't echoing the indication that information has been added, and when I check the database there isn't anything there. help please! ? $usr = username; $pwd = password; $db = dbname; $host = localhost; # connect to database $cid = mysql_connect($host,$usr,$pwd); if (!$cid) { echo(ERROR: . mysql_error() . \n);} ? HTML HEAD TITLEInsert Link/TITLE /HEAD BODY BGCOLOR=#FF PFONT SIZE=5B Add Link /B /FONT/P ? if ($REQUEST_METHOD==POST) { $description = str_replace(','',$description); $sitename = str_replace(','',$sitename); $SQL = INSERT INTO links ; $SQL = $SQL . (category, sitename, siteurl, description) VALUES ; $SQL = $SQL . ('$category', '$sitename','$siteurl','$description') ; $result = mysql_db_query($db,$SQL,$cid); if (!$result) { echo(ERROR: . mysql_error() . $SQL\n);} echo (PBNew Link Added/B/P\n); } ? FORM NAME=fa ACTION=insert.php METHOD=POST TABLE TRTDBCategory: /B /TDTDINPUT TYPE=text NAME=category SIZE=40/TD/TR TRTDBSite Name:/B /TDTDINPUT TYPE=text NAME=sitename SIZE=40/TD/TR TRTDBSite URL: /B /TDTDINPUT TYPE=text NAME=siteurl VALUE=http://; SIZE=40/TD/TR TRTD VALIGN=TOPBDescription: /B /TDTD TEXTAREA NAME=description ROWS=5 COLS=40/TEXTAREA/TD/TR TRTH COLSPAN=2PINPUT TYPE=submit VALUE=Add Link/P/TH/TR /TABLE /FORM ?mysql_close($cid); ? /BODY /HTML -- Jason Morehouse (jm[@]netconcepts[.]com) Netconcepts - http://www.netconcepts.com Auckland, New Zealand Linux: Because rebooting is for adding hardware. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Jason Morehouse (jm[@]netconcepts[.]com) Netconcepts - http://www.netconcepts.com Auckland, New Zealand Linux: Because rebooting is for adding hardware. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Fw: search question
http://www.mysql.com/doc/en/Fulltext_Search.html On Tue, 17 Sep 2002 20:34:37 +1200, Meltem Demirkus wrote: Hi, Is there any other efficient way (--except using LIKE)of searching a keyword in mysql ... thanks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: onnecting to MSSQL database from Linux?
It means you haven't compiled mysql support into php. Recompile it using --with-mysql -- Jason Morehouse (jm[@]netconcepts[.]com) Auckland, New Zealand Linux: Because rebooting is for adding hardware. On Tue, 17 Sep 2002 15:30:29 +, Avi Schwartz wrote: I have PHP4 and freetds installed and I am trying to connect to a mssql server. The problem I am having is that the mssql_connect() call generates the following error: Fatal error: Call to undefined function: mssql_connect() Is there something I need to require? Thanks, Avi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Select string.
Single quotes within the select work fine. $login = mysql_query(SELECT * FROM Users WHERE Username = '$User_Name'); On Thu, 11 Jul 2002 06:47:54 +1200, Shiloh Madsen wrote: Yet another thing i need some quick help with. What is the proper way to generate a select string in php. I know if youre trying to select a value from a column you need to enclose it in double quotes if youre doing it directly in sql. in this case the value in question is being passed as a variable from a previous page. i have the current line for selection in my page, but i dont think it is correct. any help? $login = mysql_query(SELECT * FROM Users WHERE Username =. $User_Name) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: remove from db renumbering
That's the way auto_increment works. You'll have to make the field an int (no auto_increment) and supply a record id yourself on insert. On Mon, 01 Jul 2002 08:21:18 +1200, Chris Payne wrote: Hi there everyone, I have my id field auto incrementing (Of course) and I have a utility that allows me to remove items from it, the problem is when I remove something the items after it keep their IDs leaving a gap in the ID. For example, say I have 1-10 in the ID field and I remove number 8, Ill have 1-7 and then 9-10, what I need is for 9-10 to go down to 8-9, how can I do this? Its really important as I have an ad-rotator system which gets the total number of fields from the DB and if there is an empty ID it causes there to be an invalid image appear (Of course). So all I need is to renumber the ID field after a delete I guess, but how? Any help would be extremely grateful :-) Thanks Chris --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.372 / Virus Database: 207 - Release Date: 6/20/2002 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: mysql_fetch_array pointer
mysql_data_seek($result_cat,0); http://www.php.net/manual/en/function.mysql-data-seek.php On Tue, 29 Aug 2000 22:55:11 +1200, Jeffrey Barendse wrote: I like to use a script like this: $result_cat = mysql_query(select cat_naam from categorie order by cat_naam); while($row = mysql_fetch_array($result_cat)) { echo 'OPTION VALUE=' . (urlencode($row[cat_naam])) . '' . $row[cat_naam]; } while($row = mysql_fetch_array($result_cat)) { echo $row[cat_naam]; } In the first while function it works fine. But in the other I have no date. I suppose the mysql_fetch_array sets a pointer. Is there a way to reset the pointer so I can reuse a query? Regards, Jeffrey Barendse WireITup -- Jason Morehouse ([EMAIL PROTECTED]) Netconcepts LTD - Auckland, New Zealand * Linux: Because rebooting is for adding hardware. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Easy one for you guru's :-)
Here is a simple cart, but should give you the idea. Cheers! -J ? switch($action) { # Add to cart case 'add': $_SESSION['cart'][$id] = array('name'=$name,'price'=$price,'qty'=$qty); break; # Remove from cart case 'remove': # Remove item unset($_SESSION['cart'][$id]); break; } # Show cart contents if any if (count($_SESSION[cart]) 0) { print Cart contents:; foreach($_SESSION[cart] as $id = $value) { print li $value[qty] $value[name] (@\$$value[price])br; $total += $value[price] * $value[qty]; } print Total: \$$totalhrbr; } # a product $id = 101; $name = 'beer'; $price = '3.15'; ? form action=?=$PHP_SELF? pQty: input type=textbox name=qty size=3 value=1br Product: ?=$name?br Price: $?=$price? NZDbr input type=radio name=action value=add checked Add input type=radio name=action value=remove Remove input type=submit value=OK /p input type=hidden name=id value=?=$id? input type=hidden name=name value=?=$name? input type=hidden name=price value=?=$price? /form ? On Sun, 12 May 2002 06:02:39 +1200, Dave Carrera wrote: Hi All Can someone breakdown the logic of adding and subtracting products to a shopping cart using sessions. I can't quite get the logic so something in plain English would help very much. Any helpful advice, pointers or even code examples are very much appreciated. Thank you fully in advance for any help you may give. Dave C -- .--- .- ... --- -. / -- --- .-. . --- ..- ... . Jason Morehouse [EMAIL PROTECTED] Netconcepts LTD Auckland, New Zealand - Linux: because rebooting is for adding hardware. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Need php page to upload files
http://www.php.net/manual/en/features.file-upload.php On Mon, 23 Apr 2001, Hector M Banda wrote: Hi all, I need a basic php page to upload files containing information to later import them into my server. Can somebody point me to a simple site where I can get one? Thanks, -- .--- .- ... --- -. / -- --- .-. . --- ..- ... . Jason Morehouse [EMAIL PROTECTED] Netconcepts LTD Auckland, New Zealand -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]