Jump to content

Recommended Posts

Possibly a MySQL issue, but the function that is not behaving in the anticipated way is a PHP function.

 

Seems as though mysql_affected_rows() is not returning the desired number so I can move into my if statement.

 

This is just a snippet. Let me know if more code might be needed to diagnose.

<?php
dbconnect();
$sql = "INSERT INTO `registration` (`id`, `the_date`, `first_name`, `last_name`, `email`, `phone`, `street_address`, `city`, `state`, `zip`, `emergency_contact`, `emergency_phone`, `high_school`, `test_score`, `major_interest`, `gpa`, `activity1`, `activity2`, `activity3`, `activity4`, `recruitment`, `recruitment_explain`, `travel`, `language`, `language_years`, `rotc`, `interests`, `accommodations`, `pay`) VALUES (NULL, '{$the_date}', '{$first_name}', '{$last_name}', '{$email}', '{$phone}', '{$street_address}', '{$city}', '{$state}', '{$zip}', '{$emergency_contact}', '{$emergency_phone}', '{$high_school}', '{$test_score}', '{$major_interest}', '{$gpa}', '{$activity1}', '{$activity2}', '{$activity3}', '{$activity4}', '{$recruitment}', '{$recruitment_explain}', '{$travel}', '{$language}', '{$language_years}', '{$rotc}', '{$interests}', '{$accommodations}', 'N')";
$result = mysql_query($sql) OR DIE ('//INSERT error<br />Please report this to the site admin <a href="/contact/index.php">here</a>.<br /><br />'.mysql_error());
if (mysql_affected_rows($result)==1)
{
//send email
?>

Link to comment
https://forums.phpfreaks.com/topic/185054-mysql_affected_rows-usage/
Share on other sites

The parameter that mysql_affected_rows() takes is a link identifier, not the value that mysql_query() returns.

 

The value returned by a INSERT/UPDATE/DELETE query is just a TRUE (the query executed without any errors) or FALSE (the query failed to execute because of an error, like a syntax error or a problem with the database) value anyway.

 

You can have a case (depends on the mysql server configuration or the use of the IGNORE keyword) where an INSERT query executes without error but the row will not be inserted.

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.