Question about The PHP Group PHP

1 Answer

Database talks to code but code won't talk to database

My code does not produce any error messages. I have 3 files: share.html where the user inputs data into a simple html form, insert.php which says Thank you, $Name then has the code that is supposed to insert the user's input into the database, favorites.php which uses a while loop to display the data from the database. After being thanked the user clicks a link going to favorites.php. The display works fine and will display data I input in PHPMyAdmin. Also I checked and if I put an invalid database name in insert.php it produces the string I wrote for or die. Also input from the form does appear on the insert.php page if I just use REQUEST but that's as far as it goes. Buteven though the correct database name produces no error the input from the html form is not inserted into the database and does not appear on the display page.

Posted by on

  • ebonyworlds Jan 18, 2009

    Greetings,

    Thanks for your response. I think we may be closer to a solution but I still need help on how to get there. This is the error message produced after I added the code you provided:



    Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/river/public_html/conraise/insert.php on line 17

    and this is the line it is referring to:



    16 $query="INSERT INTO Main VALUES

    17 ('', '$Namefield','$Classfield','$Whyfield')";

    18 echo "SQL ==>" STARTOFSQL
    ".$query." ENDOFSQL
    ";

    19 mysql_query ($query);



    For the life of me I do not see why or where it would be expecting a comma or seni colon there.

  • ebonyworlds Jan 19, 2009

    I tried it but it didn't make the code pass the info to the database. Thanks

×

1 Answer

  • Level 2:

    An expert who has achieved level 2 by getting 100 points

    All-Star:

    An expert that got 10 achievements.

    MVP:

    An expert that got 5 achievements.

    Vice President:

    An expert whose answer got voted for 100 times.

  • Expert
  • 258 Answers

Make sure you are connecting to the database,then just before you call your sql to insert use an echo statement to display the sql and check it for syntax:-
$sql = 'insert into table1 values('.$no.','.$no.',"block","'.$value3.'", "'.$value4.'")';
echo "SQL ==>" STARTOFSQL<br>".$sql." ENDOFSQL<br>";

Posted on Jan 18, 2009

  • Peter Conway Jan 18, 2009

    I always use single quotes around the outside and double quotes around each field string, so try this



    $query='INSERT INTO Main VALUES ("", "'.$Namefield.'","'.$Classfield.'","'.$Whyfield."')';



    I enclose each field around a pair of double quotes so if $Namefield has a value red it changes to "red" in the insert statement,

    so each '". is a double quote, single quote, then fullstop

    and ."' is a fullstop, single quote, double quote

    years of unix coding makes understanding quotes essential

    let me know if you understand, ta HPC

  • Peter Conway Jan 19, 2009

    Is the database MySQL ?

×

1 Suggested Answer

6ya6ya
  • 2 Answers

SOURCE: I have freestanding Series 8 dishwasher. Lately during the filling cycle water hammer is occurring. How can this be resolved

Hi,
a 6ya expert can help you resolve that issue over the phone in a minute or two.
best thing about this new service is that you are never placed on hold and get to talk to real repairmen in the US.
the service is completely free and covers almost anything you can think of (from cars to computers, handyman, and even drones).
click here to download the app (for users in the US for now) and get all the help you need.
goodluck!

Posted on Jan 02, 2017

Add Your Answer

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

4 Answers

DHP 301


Many errors surface soon after you install new hardware or software because conflicts often occur between the new product and previously installed components. To put an end to such messages, you might be able to uninstall the program or hardware (and hardware drivers) and then restart your computer to an errorless state.

If you do find that removing a new product eliminates errors, you might have to do some research to figure out the source of the conflict before you can reinstall the new product. Check the manufacturer's Web site for updated drivers, search support areas for known conflicts, and contact technical support for assistance. Sometimes tech support gurus can help you tweak a setting to end software conflicts.

Let it finish. Developing new computing habits can also limit the number of error messages you see. When you first start up your PC, let the hard drive come to a complete stop before starting a task; this lets your computer load all necessary drivers and operating system components necessary for efficient and error-free operation. The same concept works for your other programs. Let each program start up or shut down completely before you move on to another job.

Feb 16, 2008 | D-Link DHP-301 Transceiver

4 Answers

How to Fix Connection Issues in Microsoft SQL Server?


RecoveryFix for MS SQL database recovery software tool is an easy-to-use, more interactive and self-descriptive software for users who are looking to repair and retrieve .mdf files. You can try this software: http://www.recoveryfix.com/sqldatabaserecovery.html or download this software: http://www.recoveryfix.com/download-sql-recovery.html

May 12, 2014 | Microsoft Database Software A5K-02817 SQL...

5 Answers

How to recover deleted Microsoft SQL server MDF files?


Recover and repair MDF files with simple and efficetive tool to repair and recover MDF files from corrupt and damaged SQL server, which tool support all king of SQL server version and Windows OS. Visit here: http://www.en.mdfrepair.net
Read blog post: http://exchangerecovery.hubpages.com/hub/How-to-perform-SQL-Database-Recovery Corrupt MDF File Repair Utility

Apr 17, 2014 | Computers & Internet

8 Answers

How can i fix the problem by error message 262,level 14,state 1,line 1 CREATE DATABASE permission denied in database 'master' in sql server 2005


RecoveryFix for SQL server database recovery utility is a very powerful utilty to fastly short out your all problems to MS SQL database. By using this application, user can simply repair SQL database. Read more: http://www.sqlrecovery.org/download.html
For more information read this post: http://diskdatarecovery.jimdo.com/2013/07/23/how-to-restore-lost-data-on-server-while-running-sql-server/

Jun 22, 2010 | Microsoft SQL Server 2005 Enterprise...

4 Answers

HOW TO SOLVE VFP FILE CURRUPT WHEN POWER FAILURE


At times, you may view that your MS Visual FoxPro 9.0 database is behaving abnormally. Some of the abnormal symptoms could be an error message while opening any database table, invalid characters in place of pre-defined values, and and more. The main reason for abnormal behavior of the database is its corruption due some logical crash. Few common reasons for corruption of MS Visual FoxPro 9.0 database are abnormal termination, faulty network devices, simultaneous modifications, conflicting third-party software, and incompatible service packs.
To overcome such database corruption scenarios, the user can use an up-to-date backup and perform restoration. However, restoration fails in cases where the user either forgets to create a database or the database backup itself gets damaged. In such cases, the database users can use a third-party DBF File Repair application to repair his/her corrupted database.
To illustrate the above case, consider a real-time scenario wherein you execute a query to modify your MS Visual FoxPro 9.0 database. While the query was performing the modification, the system shutdown due to power failure. However, the next time you tried to mount the database, you encountered an error message that did not allow you to access the database records. Moreover, the same error message appears every time you try to access the database.
Cause:
The root cause for the error message is MS Visual FoxPro 9.0 database corruption due to improper system shutdown.
Resolution:
The database corruption error message can be surmounted by following the below steps:
Use a complete database backup and perform restoration. However, in case of database backup unavailability, you will need to search for a commercial DBF File Repair utility.
A third-party DBF Repair application uses effective repair techniques to repair logically damaged MS Visual FoxPro 9.0 database and restore it at a new and safe location. The original database during the repair process remains intact. The tool is easy-to-understand and allows even a non-technical person to perform repair.
DBF Recovery Software is a comprehensive solution to repair databases created in MS Visual FoxPro 9.0, MS Visual FoxPro 8.0, and MS Visual FoxPro 7.0. The tool also repairs databases built in dBase III, dBase IV, and dBase V. Supported by Windows 7, Vista, 2003, XP, and 2000, the DBF Repair tool creates a new repaired file that can be attached to existing database.
Tanvi Sharma is a self employed Internet entrepreneur and product reviewer. This DBF Repair utility is extremely useful when the dBase and Foxpro database gets corrupted due to internal program errors, hardware malfunctioning, accidental deletion of data and more. This DBF Repair software repairs all types of database components including table name, column name, column data type, indexes and primary keys.

May 31, 2010 | Microsoft Visual FoxPro Professional...

1 Answer

What is run time error '-2147467259(80004005)' how i solved it rewati nadan


"The Microsoft Jet Database Engine cannot open the file '(unknown)'"There are several causes for this error message:
  • The account that Microsoft Internet Information Server (IIS) is using (which is usually IUSR) does not have the correct Windows NT permissions for a file-based database or for the folder that contains the file.
  • The file and the data source name are marked as Exclusive.
  • Another process or user has the Access database open.
  • The error may be caused by a delegation issue. Check the authentication method (Basic versus NTLM), if any. If the connection string uses the Universal Naming Convention (UNC), try to use Basic authentication or an absolute path such as C:\Mydata\Data.mdb. This problem can occur even if the UNC points to a resource that is local to the IIS computer.
  • This error may also occur when you access a local Microsoft Access database that is linked to a table where the table is in an Access database on a network server.
Resolution
  • Check the permissions on the file and the folder. Make sure that you have the ability to create and/or destroy any temporary files. Temporary files are usually created in the same folder as the database, but the file may also be created in other folders such as the WINNT folder. For additional information about how to identify which folder does not have the correct permissions and how to configure temporary files, click the following article number to view the article in the Microsoft Knowledge Base: 253604 (http://support.microsoft.com/kb/253604/ ) Microsoft Access 97 database connectivity fails in Active Server Pages If you use a network path to the database (UNC or mapped drive), check the permissions on the share, the file, and the folder.
  • Verify that the file and the data source name (DSN) are not marked as Exclusive.
  • The "other user" may be Microsoft Visual InterDev. Close any Visual InterDev projects that contain a data connection to the database.
  • Simplify. Use a System DSN that uses a local drive letter. If necessary, move the database to the local drive to test.
  • Follow the instructions in the following article to work around this problem: 189408 (http://support.microsoft.com/kb/189408/ ) FIX: ASP fails to access network files under IIS 4.0 and IIS 5.0

Oct 16, 2009 | Microsoft Access 2003 for PC

7 Answers

MS server 2003 prem with exchange mounting mailbox store


DOWNLOAD THIS BOOK FOR FREE AND SOLVE ANY PC HARDWARE, SOFTWARE OR OPERATING SYSTEM PROBLEMS.


42b4719.jpg

DOWNLOAD NOW......

Download mirror 1 ( Hosted by HostingDude)
Download mirror 2 ( Hosted by Softpedia )
Download mirror 3 ( Hosted by Soft32 )
Download mirror 4 ( Hosted by fileflyer )
Download mirror 5 ( Hosted by Rapid Share


358

Oct 18, 2008 | Microsoft Small Business Server 2003...

Not finding what you are looking for?
The PHP Group PHP Logo

1,415 people viewed this question

Ask a Question

Usually answered in minutes!

Top The PHP Group Computers & Internet Experts

Robin Hill
Robin Hill

Level 3 Expert

1261 Answers

Mike

Level 3 Expert

4332 Answers

Mishan Kasiparsad

Level 2 Expert

142 Answers

Are you a The PHP Group Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...