Jump to content

please corect my code...


fantomel

Recommended Posts

<?php
rand(1,$count_row);
$sql = "SELECT * FROM vacante LIMIT $rand,1";
     $count_row = mysql_num_rows($res);
     $sql = "SELECT * FROM vacante LIMIT $rand,1";
     $res = mysql_query($sql) or die(mysql_error());    {
     $titlu=$prod_sel['titlu'];
     $subtitlu=$prod_sel['subtitlu'];
     $desc=$prod_sel['poze'];
}
?>

 

 

error:

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1

 

please someone corect my code it's for a random result from mysql in table vacations i have some offers and i want to random in a table on the first page random offers but only title subtitle picture and price. thank you for helping me

 

 

Link to comment
https://forums.phpfreaks.com/topic/104548-please-corect-my-code/
Share on other sites

What rand() returns must be assigned to a variable. Your $rand has no value in it.

 

$rand = rand(1,$count_row);

 

 

 

<?php
     $rand = rand(1,$count_row);
     $sql = "SELECT * FROM vacante LIMIT $rand,1";
     $res = mysql_query($sql) or die(mysql_error());    {
     $count_row = mysql_num_rows($res);
     $titlu=$prod_sel['titlu'];
     $subtitlu=$prod_sel['subtitlu'];
     $desc=$prod_sel['poze'];

?>

 

 

so this is how it must look ? :-s

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.