Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Linux, Apache, MySQL > MySQL Help

MySQL Help Post any question relating to MySQL here and hopefully someone can help

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2004-08-24, 01:30 AM
Junior Member
 
Join Date: Aug 2004
Posts: 2
evenstar7139
Default

Oh, I'm all frustrated! I put a string in my database like this: $callName looks very happy that you've given it the $toy and when I retrieve it in a PHP page and echo it, it doesn't evaluate the darn variables. It just prints it like this: $callName looks very happy that you've given it the $toy How do I get it to evaluate the variables.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 2004-08-24, 04:45 AM
Moderator
 
Join Date: May 2004
Location: Portugal
Posts: 143
gesf is an unknown quantity at this point
Send a message via ICQ to gesf Send a message via MSN to gesf Send a message via Skype™ to gesf
Default

I guess you´re making something like:
Code:
<?php

echo '$callName looks very happy that you've given it the $toy';

?>
Right !?
Try this:
Code:
<?php

echo $callName . ' looks very happy that you've given it the ' . $toy;

?>
__________________
Best Regards,
Gonçalo "GesF" Fontoura

Website : gesf.org
Reply With Quote
  #3 (permalink)  
Old 2004-08-24, 04:08 PM
Junior Member
 
Join Date: Aug 2004
Posts: 2
evenstar7139
Default

No, no. Here is what I'm trying to do.

The variables, first, are defined, then the string is pulled from the database, then I put it in a varaible and echo it. And it just print the variable name, and not the value in the variable.

Code:
$item=horses;
$callName=Roonie;

if 
($item == horses 
OR $item == sheep 
OR $item == asdfsdafd)
 {
   $requestFrom=itemEndingPlur;
   $plur=yes;
   print $plur;
  }

$linkID=mysql_connect(xxxxx,xxxx,xxxx);
mysql_select_db(users, $linkID);

$result=mysql_query("SELECT message FROM socialize WHERE name='$requestFrom'");
$message=mysql_result($result, socialize);
print $message;
You see, what I want to do, is put a string in a database with variables in it, and have it so when I print the string, it puts the value int he variables, not the variable names.
Reply With Quote
  #4 (permalink)  
Old 2004-08-24, 10:59 PM
Xnuiem's Avatar
Senior Member
 
Join Date: May 2004
Location: DFW, Texas
Posts: 1,104
Xnuiem will become famous soon enough
Send a message via Yahoo to Xnuiem
Default

I am kinda unclear about what you are actually attempting, but there are several errors in that code.


Use quotes around strings in your declarations
Drop the OR's they are much slower than ||
The resource link ID is not required if you only have a single connection open.
The second argument in mysql_result is a row number, not a string (http://www.php.net/mysql_result

So, with that said, lets clean it up a little bit and try again, maybe it will work with some of the errors removed.

Code:
$item = "horses";
$callName = "Roonie";
$checkItem = array("horses", "sheep", "asdfsdafd");

if (in_array($item, $checkItem)){
 Â* Â*$requestFrom = "itemEndingPlur";
 Â* Â*$plur = "yes";
 Â* Â*print($plur);
}

mysql_connect(xxxxx,xxxx,xxxx);
mysql_select_db(users);

$result=mysql_query("SELECT message FROM socialize WHERE name = '$requestFrom'");
$message = mysql_result($result, 0);
print($message);
__________________
I rarely give code examples.
No, I have never used IIS or Windows of any kind as a web server. Get a real OS!
Please don't PM me, I won't respond.
Reply With Quote
  #5 (permalink)  
Old 2004-08-25, 06:54 AM
Moderator
 
Join Date: May 2004
Location: Portugal
Posts: 143
gesf is an unknown quantity at this point
Send a message via ICQ to gesf Send a message via MSN to gesf Send a message via Skype™ to gesf
Default

That´s it !
__________________
Best Regards,
Gonçalo "GesF" Fontoura

Website : gesf.org
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.5 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.5 (a popular PHP IDE) and NuCoder 2.0 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 11:20 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.