I have a function that's supposed to query mysql with a zip code, and generate an html <select> box with possible cities. Instead, it crashes the site and gives this error:
Code:
Fatal error: Can't use function return value in write context in /home/rahl/public_html/RVM/include/functions.php on line 298
# errorno=1064
# error=You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1
# query=query
I think this is causing the problem:
PHP Code:
if(empty($error))
{
$query = mysql_query("UPDATE Users SET title='$title',last_name='$l_name',first_name='$f_name',zip='$zip' WHERE handle='$user_name'")
or die(mysql_error());
I've Failed You:
# Script Name: /RVM/registration/register2.php
# Include File: /home/rahl/public_html/RVM/include/functions.php
# errorno=1064
# error=You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1
# query= 1
if(empty($error))
{
$query = mysql_query("UPDATE Users SET title='$title',last_name='$l_name',first_name='$f_name',zip='$zip' WHERE handle='$user_name'")
or die(mysql_error());
safe_query($query);
I don't understand what is going on here. Anyway I was right about a boolean. It is an UPDATE query and mysql_query is returning true. Then for some reason you are running that boolean as if it were another query. Also what is the point having that function if you never use the return value for anything.
I've switched to session variables to handle all of the passing of information from one page to another, and I have *most* everything working.
I'm having trouble with my email confirmation page now, and I can't figure out why. It changes the database corectly, but it isn't printing the error or confirmation method.
I've been working on it for a couple hours now and I can get the message to print under the table, but not inside it!
This is the confirmation page:
PHP Code:
<?PHP
session_start( );
$location_ID ="RVM Email Confirmation"; // Set the location variable
// Include the registration forms functions page
Require('../registration/registration_forms.php');
// Include Database connection information
Require('../include/SQL_connect.php');
// Include the shared registration functions
Require('../include/functions.php');
// get the confirmation code
$code = $HTTP_GET_VARS["confirmation_code"];
function check_confirmation_code($code)
{
$query = "SELECT * FROM Users WHERE confirmation_code = '$code'";
$result = safe_query($query);
if (mysql_num_rows($result) > 1)
{
$return_message = "AAAAAAAAHHHHHHHHHHHHHH!!!!!!!!!!!!!!!!!!!!!!!<br/> Something has gone teribly wrong. Please email technical support,
or <a href='../registration/dc_request.php' class='inline_link'>request a new confirmation code here</a>.";
// draw the page
registration_email_confirmation();
}
elseif (mysql_num_rows($result) < 1)
{
$return_message = "I'm sorry, but the confirmation code you have entered isn't valid.<br/>Please be sure you are using the
code provided in your confirmation email, and that you are doing so within 24 hours of receiving it.
If you need to, you may <a href='../registration/dc_request.php' class='inline_link'>request a new confirmation code here</a>.";
// draw the page
registration_email_confirmation();
$return_message = "Thank you, ".$_SESSION["title"]." ".$_SESSION["l_name"].".<br/><br/><br/>
You are now registered under the username: ".$_SESSION["user_name"]." Using the email address: ".$_SESSION["email"]."
<br/><br/> From here, you can <a href='../interface/user_home.php' class='inline_link'>go to your homepage</a>.... more options when I acctually code somewhere to go.";
$query = "UPDATE Users SET confirmation_code='0',confirmed='1' WHERE confirmation_code='".$_SESSION["confirmation_code"]."'";
$result = safe_query($query);
// draw the page
registration_email_confirmation();
}
}
and this is the function that prints the HTML, and *should* be printing out the $return_message variable inside of it:
Bookmarks