TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   personal messages system (http://www.talkphp.com/absolute-beginners/1935-personal-messages-system.html)

webtuto 01-11-2008 01:18 PM

personal messages system
 
hi im trying to do a personal messages system in my script
and i had few problems
is there someone than can help a little bit with some tips
thanks already


ok this script didnt work why !!
PHP Code:

$wom="SELECT * FROM `coms`";
$man=mysql_query($wom);
while(
$car=mysql_fetch_array($man)){
   
$sendername=$car['sender'];
}
   echo 
"By : ";
   echo
"<a href='msgs.php?member=$_COOKIE[user]'>".$sendername."</a><br>"


Karl 01-11-2008 01:28 PM

That's a very vague question webtuto, can you elaborate on what part of the script you actually need help on?

webtuto 01-11-2008 01:33 PM

karl i edit the thread u can see the code

buggabill 01-11-2008 01:49 PM

Webtuto, could you be more specific? Are you getting error messages? Are you looking to optimize the code?
What's up?

Jim 01-11-2008 01:54 PM

You are not using $car anymore in the code, and we don't see $oop and $row being created. Are you sure they exist? And $oop[com] may give problems on some PHP servers, use $oop['com'].

Hope this helps a bit :)

webtuto 01-11-2008 02:09 PM

Quote:

Originally Posted by Jim (Post 8233)
You are not using $car anymore in the code, and we don't see $oop and $row being created. Are you sure they exist? And $oop[com] may give problems on some PHP servers, use $oop['com'].

Hope this helps a bit :)

its a big page not just this little script the problem that i have is in here =>


PHP Code:

$man=mysql_query("SELECT * FROM `coms` ");
$car=mysql_fetch_array($man);
   echo 
"By : ";
   echo
"<a href='msgs.php?member=$_COOKIE[user]'>".$row['sender']."</a><br>"


webtuto 01-11-2008 02:11 PM

Quote:

Originally Posted by buggabill (Post 8231)
Webtuto, could you be more specific? Are you getting error messages? Are you looking to optimize the code?
What's up?

im not getting any error but in the page near "BY" it douesnt show the sender name $car[sender]

Jim 01-11-2008 02:17 PM

Then if you don't get the sender name give give is the code that makes $row (inc query)

webtuto 01-11-2008 02:20 PM

$car not $row i edit it
but still the error

Jim 01-11-2008 02:28 PM

If you only need it once use:

Code:

$man=mysql_query("SELECT * FROM `coms` LIMIT 1");
$car=mysql_fetch_row($man);
  echo "By : ";
  echo"<a href='msgs.php?member=$_COOKIE[user]'>".$car['sender']."</a><br>";


webtuto 01-11-2008 02:32 PM

yeah but still douesnt show any result

ReSpawN 01-11-2008 02:54 PM

This stuff is pretty basic so you should know it by now. If you don't, please save it, or repeat the method a couple of times.

PHP Code:

$femaleQuery 'SELECT * FROM `coms`';
$maleQuery mysql_query($femaleQuery);

while (
$carRow mysql_fetch_array($maleQuery)) {
    
$senderName $carRow['sender'];
    echo 
'<a href="msgs.php?member='.$_COOKIE[user].'">'.$senderName.'</a><br>';


This is the way if you want to echo more than 1 result in a row, table, tr, td, div or what ever. While, Foreach and stuff prints it out, so you should use this.

I have NOT tried it out but it is the most basic method I know and very solid. The query construction aside of course.

Jim 01-11-2008 03:40 PM

Quote:

Originally Posted by webtuto (Post 8243)
yeah but still douesnt show any result

Then you don't have a filled in "sender" field in your DB.

ReSpawN 01-11-2008 06:08 PM

OR the field isn't called sender. Use phpMyAdmin or NaviCat (or any other mySQL program) to check out how you named your database.

You can also include at the top, or rather in the config error_reporting(E_ALL); or maybe error_reporting(E_ALL ^ E_NOTICE);. This way you can see all the errors except the notices (like define and such). I use it mainly for developing since then I can see if my query is wrong, my fetch didn't go as planned or maybe if I even haven't established a connection to the database.

Good luck.

webtuto 01-11-2008 08:27 PM

im gonna try night and this u the result thanks guys

codefreek 01-12-2008 06:25 AM

it is easyer if you post what the bug output on the page is,
and in what line.

webtuto 01-14-2008 03:04 PM

the problem is solved now thanks


All times are GMT. The time now is 01:32 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0