Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PHP Member Activation mySQL fails!

Featured Replies

Hey guys,

 

I hope you are all well!

 

I'm struggling with this one.

 

Do you have any idea where I'm going wrong?

 

<?
 session_start();
 include('../db.php'); 



 $code = $_GET['code'];


 $query  = "SELECT * FROM vip WHERE state = '$code'" or die ('Error: '.mysql_error ());;
 $result = mysql_query($query) OR die(mysql_error());
 while($row = mysql_fetch_array($result, MYSQL_ASSOC))
 { 

 $_SESSION['vip_username'] = ($row['username']);


 $query  = "INSERT INTO vip (state) VALUES ('1') WHERE state='$code'";
 $result = mysql_query($query);


 $msg = "Congratulations! You are now a fully fledged member";



     include('main.php');


 }



 ?>

 

Basically, a link gets sent to the users email address, they then click the link - it will look something like this

 

example.com/FemG83rO4j7z8rk

 

The code should then get checked in the database - when the code has been located it gets changed to "1" - which means they are an active member.

 

It then registers their session variable and they get forwarded to the member area.

 

But I am getting this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:xampphtdocsycc2vipactivate.php on line 12

 

I am at a loss! - Any suggestions?

 

Thanks guys,

 

Nick

Hi Nick, I tried your code on my own database and got no errors ... are you sure that the contents of db.php aren't causing this problem?

Here's the code I ran that didn't have any error messages - does this cause errors for you?

 

<?
 session_start();

 include ("myown_db.php");

 $code = "a constant I know exists in table";

 $query  = "SELECT * FROM vip WHERE state='$code'" or die ('Error: '.mysql_error ());;
 $result = mysql_query($query) OR die(mysql_error());
 while($row = mysql_fetch_array($result, MYSQL_ASSOC))
 {
    echo "hi" ;
 }

?>

Here's the code I ran that didn't have any error messages - does this cause errors for you?

 

<?
  session_start();

  include ("myown_db.php");

  $code = "a constant I know exists in table";

  $query  = "SELECT * FROM vip WHERE state='$code'" or die ('Error: '.mysql_error ());;
  $result = mysql_query($query) OR die(mysql_error());
  while($row = mysql_fetch_array($result, MYSQL_ASSOC))
  {
     echo "hi" ;
  }

?>

 

I had a similar project with some of my code, turns out it was my installation of PHP/mySQL that was at fault. Try it on another server if you can and rule out the error that way, I ended up putting in another method incase mysql_fetch_array wasn't available.

[/code]

<?

session_start();

include('../db.php');

 

 

 

$code = $_GET['code'];

 

 

$query = "SELECT * FROM vip WHERE state = '$code'";

$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result, MYSQL_ASSOC))

{

 

$_SESSION['vip_username'] = ($row['username']);

 

 

$query = "INSERT INTO vip (state) VALUES ('1') WHERE state='$code'";

$result = mysql_query($query);

 

 

$msg = "Congratulations! You are now a fully fledged member";

 

 

 

include('main.php');

 

 

}

 

 

 

?>

[/code]

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.