Jump to content

Recommended Posts

Ok I am having trouble figuring this out...For some reason this is not updating my changes

I have two sheets...the first is

<?php
$tournid = $_GET['id'];
$con = mysql_connect("xxxxxxxx","xxxx", "xxxxx") or die('Sorry could not connect to database at this time');
mysql_select_db("srhino", $con)or die('Sorry, could not connect to database');



$query = "SELECT * from Contacts where tournid =$tournid";
$result = mysql_query($query) or die('Sorry, could not get tournaments at this time');
if (mysql_num_rows($result) ==0){
echo "<h3> Sorry, There are no tournaments at this time, please try back later.</h3>";}
else
{
while($row=mysql_fetch_array($result, MYSQL_ASSOC))
{
$tournid = $row['tournid'];
$tourname = $row['tourname'];
$location = $row['location'];
$month = $row['month'];
$day = $row['day'];
$year = $row['year'];
$days = $row['days'];
$contact = $row['contact'];
$phone = $row['phone'];
$fax = $row['fax'];
$cell = $row['cell'];
$email = $row['email'];
$address = $row['address'];
$website = $row['website'];
$notes = $row['notes'];
$poster = $row['poster'];

echo


"<form action=\"dowork.php\" method=\"post\">
<table>
<tr><td>Tournament Name:</td><td><input type=\"text\" size=\"40\" name=\"tourname\" value=\"$tourname\"></td></tr><br>
<tr><td>Location:</td><td><input type=\"text\" size=\"40\" name=\"location\" value=\"$location\"></td></tr><br>
<tr><td colspan=\"2\" align=\"center\">Month:<input type=\"text\" size=\"2\" name=\"month\" value=\"$month\">
Day:<input type=\"text\" size=\"2\" name=\"day\" value=\"$day\">
Year:<input type=\"text\" size\"4\" name=\"year\" value=\"$year\">
# of Days:<input type=\"text\" size=\"2\" name=\"days\" value=\"$days\"></td></tr><br>
<tr><td>Contact:</td><td><input type=\"text\" size=\"40\" name=\"contact\" value=\"$contact\"></td></tr><br>
<tr><td>Phone:</td><td><input type=\"text\" size=\"40\" name=\"phone\" value=\"$phone\"></td></tr><br>
<tr><td>Fax:</td><td><input type=\"text\" size=\"40\" name=\"fax\" value=\"$fax\"></td></tr><br>
<tr><td>Mobile:</td><td><input type=\"text\" size=\"40\" name=\"cell\" value=\"$cell\"></td></tr><br>
<tr><td>E-mail:</td><td><input type=\"text\" size=\"40\" name=\"email\" value=\"$email\"></td></tr><br>
<tr><td>Address:</td><td><input type=\"text\" size=\"40\" name=\"address\" value=\"$address\"></td></tr><br>
<tr><td>Website:</td><td><input type=\"text\" size=\"40\" name=\"website\" value=\"$website\"></td></tr><br>
<tr><td>Notes:</td><td><textarea rows=\"10\" cols=\"50\" name=\"notes\" value=\"$notes\"></textarea></td></tr><br>
<tr><td>Posted By:</td><td><input type=\"text\" size=\"40\" name=\"poster\" value=\"$poster\"></td></tr><br>


<TR><TD colspan=\"8\" align=\"center\"><input type=\"submit\" value=\"Submit\">
<input type=\"hidden\" name=\"content\" value=\"update\"></TD></TR>

</table></form>";

}}?>


This is really where I think the problem is...when I change the query and take out the "where tournid='$tournid'"; part the page updates all records...when I put it in it won't update anything...

<?php

  $tournid = $_POST['tournid'];
  $tourname = $_POST['tourname'];
  $location = $_POST['location'];
  $month = $_POST['month'];
  $day = $_POST['day'];
  $year = $_POST['year'];
  $days = $_POST['days'];
  $contact = $_POST['contact'];
  $phone = $_POST['phone'];
  $fax = $_POST['fax'];
  $cell = $_POST['cell'];
  $email = $_POST['email'];
  $address = $_POST['address'];
  $website = $_POST['website'];
  $notes = $_POST['notes'];
  $poster = $_POST['poster'];

if (trim($month == ''))

  {

  echo "<h2>Sorry, each tournament must have a month</h2>\n";

  }else

  {

$con = mysql_connect("xxxxxxx","xxxxx", "xxxx") or die('Could not connect to server');
    mysql_select_db("srhino", $con) or die('Could not connect to database');


$query = "update Contacts set tourname ='$tourname', location='$location', month='$month', day='$day', year='$year', days='$days', contact='$contact', phone ='$phone', fax='$fax', cell='$cell', email='$email', address='$address', website='$website', notes='$notes', poster='$poster' where tournid = '$tournid'";


$result = mysql_query($query) or die('Sorry, we could not post your scoring to the database at this time');


if ($result)

  echo "<a href\"dowork.php\"><h2>Scoring posted</h2></a>\n";

  else

  echo "<h2>Sorry, there was a problem posting your tournament</h2>\n";

  }

  ?>

 

Please help

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/85477-solved-please-help-find-update-error/
Share on other sites

In your second "sheet" as you call it, $_POST['tournid'] doesn't exist because it doesn't exist in your form.

 

I'm not sure if it'll work, but you can try changing it to $_GET['tournid'] and then on your first "sheet,"

 

Find:

"<form action=\"dowork.php\" method=\"post\">

 

Change to:

"<form action=\"dowork.php?id=$tournid\" method=\"post\">

 

 

Hope that helps.

 

PS: Next time, don't give out personal sensitive data such as your database connection values in your second "sheet"

I'm sorry I am really new at this and I still cant figure it out...I have triued all the things you suggest and it's not working.

 

I have figured out that it has something to do with my query. When I take out the WHERE clause in my query on the update page it will update...but it changes every record...when I put in a WHERE CLAUSE that says WHERE tournid = 'tournid' the form stops working but pretends like it works...in other words it gives me the scoring posted comment although it doesn't actually update.

 

Thanks

Just noticed a minor thing in your code.

 

On your second "sheet"

 

Find:

if (trim($month == ''))

 

Replace with:

if (trim($month)=='')

 

 

First of all, if you changed the variable $tournid to tournid, it wouldn't work. And can you post your updated code? Just the second "sheet"

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.