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 ?

×

Add Your Answer

Uploading: 0%

my-video-file.mp4

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

×

Loading...
Loading...

Related Questions:

4 Answers

Some requirement for SQL server repair


Read this blog at the following link: http://recoverymaster.livejournal.com and know helpful details about MS SQL server database recovery wizard. You can download this software: http://www.sqlrecovery.org

Jun 10, 2014 | Microsoft Database Software A5K-02817 SQL...

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...

4 Answers

How to Repair Corrupted MS SQL Database (MDF) File?


To choose a reliable and 100% safe and secure, a Microsoft SQL server database recovery program guarantee the zero loss of quality. You can see this page: http://www.en.repairsqlserver.net
See demo: http://www.youtube.com/watch?v=Q0aW1vT5nxA

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

14 Answers

How can I repair a corrupted MDF files and SQL server?


Similar question has been answered here: http://www.fixya.com/support/t24364927-sql_repair_recovery_process_very

Before asking any question in the forum, first you need to search your problem.

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

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...

2 Answers

Modify Web.config file at Run time


http://www.west-wind.com/Weblog/posts/5688.aspx ~This sets the basic idea in motion. Regards Gewiz

May 28, 2009 | InstallShield 11 Professional Edition

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 Compilers & Programming Tools Experts

Robin Hill
Robin Hill

Level 3 Expert

1251 Answers

Mike

Level 3 Expert

4331 Answers

Mishan Kasiparsad

Level 2 Expert

142 Answers

Are you a The PHP Group Compiler and Programming Tool Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...