Jump to content

Recommended Posts

Hey guys, I have a total noob question here...the project this is from is my first PHP application and I'm basically learning php/html on the fly.  Now what I want this to do is add the record, show that 1 record was added, and redirect to the homepage but I have an error on line 34, which is

 

die('Error: ' . mysql_error());

 

<?php

/* Declare connection variable */

$con = mysql_connect("localhost","","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  
/*   Connect to db  */

mysql_select_db("test_db", $con);

  /* select db to query  */


/*  SQL to talk to the database   ....need to add date function and date column...  */


$sql="INSERT INTO open_cases (its_rep, case_id, call_type, ret_num, trk_num, rs1, ord_num, gm_num, pk_num, 
gm_num2, pk_num2, gm_num3, pk_num3, gm_num4, pk_num4, gm_num5, pk_num5, gm_num6, pk_num6, valret_num, dmgd, contact, notes, status)
VALUES
('$_POST[its_rep]','$_POST[case_id]','$_POST[call_type]','$_POST[ret_num]','$_POST[trk_num]','$_POST[rs1]
','$_POST[ord_num]','$_POST[gm_num]','$_POST[pk_num]','$_POST[gm_num2]','$_POST[pk_num2]','$_POST[gm_num3]','$_POST[pk_num3]','$_POST[gm_num4]','$_POST[pk_num4]
','$_POST[gm_num5]','$_POST[pk_num5]','$_POST[gm_num6]','$_POST[pk_num6]','$_POST[valret_num]','$_POST[dmgd]','$_POST[contact]','$_POST[notes]','$_POST[status]')";


/*   If query is successfully run, show user 1 record was added...or else show error message.   */


if (!mysql_query($sql)

  die('Error: ' . mysql_error());
  }
  
  echo "1 record added";
  
mysql_close($con);
?> 

<!---     ... Wait 3 seconds, redirect to homepage  --->

<HTML>
<HEAD>
?
<META HTTP-EQUIV="refresh" CONTENT="3;URL=loginsuccess.php">
?
</HEAD>
<BODY>
?
</BODY>
</HTML> 

Link to comment
https://forums.phpfreaks.com/topic/267656-unexpected-t_exit/
Share on other sites


if (mysql_query($sql,$con))
  {
  echo "1 record successfully added..";
  }
else
  {
  echo "Error performing update: " . mysql_error();
  }

 

Pardon my noob status, I see by your guys' join dates you are veterans at this, also I appreciate the guidance.  Does this look more on track? (I'm not at work where my database is but when I get there I will run this query and post results.

Link to comment
https://forums.phpfreaks.com/topic/267656-unexpected-t_exit/#findComment-1373139
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.