Jump to content

Recommended Posts

For some reason, which I can't seem to work out, my script is dying.

 

My code is:

 

<?php
if(empty($user_familiar_name))
{
$query = mysql_query("SELECT `name` FROM `kol_familiars` WHERE `id`='$user_familiar'") or die(mysql_error());
$row = mysql_fetch_assoc($query) or die(mysql_error());
$_SESSION['user_familiar_name'] = $row['name'];
$user_familiar_name = ucwords($_SESSION['user_familiar_name']);
}
?>

 

The script wil die on $row yet it does not give an error even though I have mysql_error(). So this means it isn't a mysql error, so i'm stumped :(

 

I've tried using array and row instead of assoc but it still doesn't work.

 

So I was wondering if anyone could shed some light on the matter.

 

If you need any more info, drop me a line.

 

Many thanks,

 

~ Chocopi

Link to comment
https://forums.phpfreaks.com/topic/63099-mysql_fetch-problems/
Share on other sites

code looks good... are you sure the that section is being called? perhaps the var your checking to see if its empty() isn't really empty?

 

instead of fetch_array or _assoc since you're just getting one resutit did you try:

 

$_SESSION['user_familiar_name'] = mysql_result($query,0,0);

Link to comment
https://forums.phpfreaks.com/topic/63099-mysql_fetch-problems/#findComment-314340
Share on other sites

Thanks, it thought error reporting was turned on but apparently not :P so im using: error_reporting(E_ALL);

 

It said something to do with line 35 which is:

 

$user_familiar_name = $_SESSION['user_familiar_name'];

 

But for some reason the error message is not showing up now, even though the problem persists seeing as I havent changed anything.

 

$user_familiar is set further up and that works fine. $user_familiar is a number which corresponds to the id's in the table hence why I am trying to take the name where the id from the user matches the table.

 

The empty() part is working fine as I added echos onto every line to check where it stops, and it stops at $row.

 

At first I thought it was a problem with using mysql_fetch_assoc but quite sure it isn't seeing as it is not throwing up anything from mysql_error().

 

So thanks for all of your help, but so far I think that premiso is the closest as the error message said something about user_familiar_name not being set/called/used or something along those lines.

 

Many thanks,

 

~ Chocopi

Link to comment
https://forums.phpfreaks.com/topic/63099-mysql_fetch-problems/#findComment-314852
Share on other sites

Here we go I got the error message back:

 

Notice: Undefined index: user_familiar_name in /data/members/free/tripod/uk/c/h/o/chocopi/htdocs/kol/sessions.php on line 35

 

Line 35: $user_familiar_name = $_SESSION['user_familiar_name'];

 

So how do I go about fixing this, as I don't quite understand what it means :(

 

Many thanks,

 

~ Chocopi

Link to comment
https://forums.phpfreaks.com/topic/63099-mysql_fetch-problems/#findComment-314872
Share on other sites

cheers, but that just gets rid of the error message, which is quite random seeing as it still stops/dies in the same place

 

The only error I get now is that i am using another session_start();

 

Thanks

you should only use one session_start(); call.  should be at the very top of the page.

Link to comment
https://forums.phpfreaks.com/topic/63099-mysql_fetch-problems/#findComment-315008
Share on other sites

The problem is still persisting even after removing sessions_start(); at the top of sessions.php

 

The strange thing with this is that it still die()'s on line 35:

 

$row = mysql_fetch_assoc($query) or die(mysql_error());

 

Yet nothing is being echoed. Now, I know its not a mysql error seeing as nothing is echoed.

Then i turned on the error reporting and for a brief time and got this message to appear:

 

Notice: Undefined index: user_familiar_name in /directory/folder/sessions.php on line 35

 

However, this message isn't showing up anymore yet i have changed squat, but im quite sure its still the same problem. So does anyone know what the above error means, and know how to rectify the problem.

 

By the by the code giving me the problem is:

 

<?php
if(empty($user_familiar_name))
{
$query = mysql_query("SELECT `name` FROM `kol_familiars` WHERE `id`='$user_familiar'") or die(mysql_error());
$row = mysql_fetch_assoc($query) or die(mysql_error());
$_SESSION['user_familiar_name'] = $row['name'];
$user_familiar_name = ucwords($_SESSION['user_familiar_name']);
}
?>

 

Many thanks ;D

 

~ Chocopi

Link to comment
https://forums.phpfreaks.com/topic/63099-mysql_fetch-problems/#findComment-319260
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.