Jump to content

display texts from Mysql in textarea randomly? please Help


crf121359

Recommended Posts

Hello,

 

I am trying to display the texts that is stored in mysql in a textarea on a random basis.

 

here is my code:

 

<?php

mysql_connect("localhost", "myusername", "mypass") or die("Connection Failed");

mysql_select_db("mydatabase")or die("Connection Failed");

 

 

$query1 = ("SELECT name FROM advertising");

$result1 = @mysql_query ($query1) or die (mysql_error());

$data = mysql_fetch_assoc($result1);

 

while($row = mysql_fetch_array($query)){

 

    $name = $row["name"];

}

 

but when I run the above code I get this error and also the textarea doesn't show anything and its blank:

 

Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in /home/path.../public_html/display.php on line 9

 

 

could someone please help me?

 

Thanks

Link to comment
Share on other sites

OMG smerny, You are my God... you don't know how long I've been trying to resolve this issue!!

 

Thank you sooooo much.

works like a charm now. :)

 

Now, just to pick your brains again, can you tell me how I can show the texts randomly?

 

for example I have 10 columns in my mysql table with different texts in each of them. how can i  randomly show the contents of each columns in the same textarea?

 

 

Link to comment
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.