3 Replies - 265 Views - Last Post: 25 April 2013 - 03:13 PM Rate Topic: -----

#1 joshstevens19  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 05-December 12

PHP coding help .. ? query and if statements playing up

Posted 25 April 2013 - 01:19 PM

so im connecting my netbeans php to phpmyadmin (database).. now in this i am trying to create a php code statement which will insert the data which is written on the website into my database successful.. anybody know what im doing wrong.. ive tried most things it just wont work??



<?php
if (isset($_POST['submitted'])) {
    
    include('connect database.php');
    
    
    $showtitle = $_POST['SHOWTITLE'];
    $showreview =$_POST['SHOWREVIEW'];
    $sqlinsert =mysql_query ("INSERT INTO `reviews` (SHOWTITLE,SHOWREVIEW) VALUES('$showtitle', '$showreview'");
    
    if (!mysql_query($sqlinsert)) {
        die('error inserting new record'); 
        
        
        
    }

?>



that is the PHP code..

here is html code to go with it:


<form method="post" action="New Review.php">
<input type="hidden" name="submitted" value="true" />
<fieldset> 
    <legend> New Reviews</legend> 
    <label> Enter show title:<input type ="text" name="SHOWTITLE" /></label>
    <label> Enter Review: <input type ="text" name="SHOWREVIEW" /></label>
</fieldset> 
<br /> 
<input type ="submit" value ="add new review" />
</form>




Is This A Good Question/Topic? 0
  • +

Replies To: PHP coding help .. ? query and if statements playing up

#2 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2990
  • Posts: 10,332
  • Joined: 08-August 08

Re: PHP coding help .. ? query and if statements playing up

Posted 25 April 2013 - 02:38 PM

Read, study, then use this.
Was This Post Helpful? 1
  • +
  • -

#3 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3480
  • View blog
  • Posts: 11,867
  • Joined: 12-December 12

Re: PHP coding help .. ? query and if statements playing up

Posted 25 April 2013 - 02:48 PM

include('connect database.php');

I definitely wouldn't have spaces in the filename :whatsthat:

if (!mysql_query($sqlinsert)) {

You've already called mysql_query(), you should be testing the result, $sqlinsert.

Quote

ive tried most things it just wont work??

Erm, did you try reading the docs?! Where it also helpfully advises that the mysql library is deprecated.

[I don't know what tried everything means..? Surely you studied, rather than guessing.]
Was This Post Helpful? 1
  • +
  • -

#4 joshstevens19  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 05-December 12

Re: PHP coding help .. ? query and if statements playing up

Posted 25 April 2013 - 03:13 PM

sorted it now .. just repeated query bu accident thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1