Jump to content

gaurav.iit

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

gaurav.iit's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. still not working guys..
  2. ok..so i have database which contains a table girls with fields Serial(int) hits(int) name(text) ...following is code for homepage <?php ini_set("display_startup_errors", "1"); ini_set("display_errors", "1"); error_reporting(-1); session_start(); $con = mysql_connect("localhost","gaurav",""); mysql_selectdb("website",$con); $sql = "Select COUNT(*) from girls"; $var = mysql_query($sql,$con); $count=mysql_result($var, 0); $index1 = rand(1,$count); $index2; while(1) { $index2 = rand(1,$count); if($index1 != $index2) break; } $_SESSION['index1'] = $index1; $_SESSION['index2'] = $index2; $sql = mysql_query("SELECT * FROM girls WHERE Serial=$index1"); $row = mysql_fetch_array($sql); $name1 = $row['name']; $hits1 = $row['hits']; $sql = mysql_query("SELECT * FROM girls WHERE Serial=$index2"); $row = mysql_fetch_array($sql); $name2 = $row['name']; $hits2 = $row['hits']; echo <<<ECO <html> <head> <script src="jquery.js"></script> <script language="javascript" type="text/javascript"> <!-- //Browser Support Code function in1(){ var ajaxRequest; try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } ajaxRequest.open("GET", "girls.php", true); ajaxRequest.send(null); } function in2(){ var ajaxRequest; try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } ajaxRequest.open("GET", "girls1.php", true); ajaxRequest.send(null); } //--> </script> </head> <body > //some html code <a href="index.php" onclick="in2();"><img src="t1.png" id="t1" /></a> <a href="index.php" onclick="in1();"><img src="t2.png" id="t2" /></a> </body> </html> ECO; ?> and girls.php is <?php ini_set("display_startup_errors", "1"); ini_set("display_errors", "1"); error_reporting(-1); session_start(); $con = mysql_connect("localhost","gaurav",""); mysql_selectdb("website",$con); $myvar = $_SESSION['index1']; $sql = "UPDATE girls SET hits = hits + 1 WHERE Serial = $myvar"; mysql_query($sql,$con); ?> similarly is girls1.php ..when i click t1.png or t2.png the hits are supposed to be incremented...but its not happening so when i hosted it...
  3. yes i added the code .. its not giving any errors.. its working fine when i run it on my lappy on wamp server but when hosted it isnt working ..
  4. its not giving any errors...actually i have a button which uses session variables to increment some values... now that i have noticed sometimes its incremented sometimes not , could it be sm prblm in the server or internet speed..
  5. gaurav.iit

    php

    i had used session_start() for using variable between php scripts...it worked fine on wamp server but when i hosted it...it isnt working.. i m not able to access the variables...wat cud be the prblm the code is quite big and distributed..so cant post it.. help plz..
  6. inside the increment function i need to run some php commands for incrementing the hits column in the database using the $name1 and $serial variables.. now simply writing the php commands inside the increment doesnt workk...wat shud i do..
  7. i have a database which contains a table named girls with three columns ...Serial(int) name(text) hits(int) <?php error_reporting(E_ALL ^ E_NOTICE); $con = mysql_connect("localhost","gaurav",""); mysql_selectdb("website",$con); $index1 = rand(1,$count); $sql = mysql_query("SELECT * FROM girls WHERE Serial=$index1"); $row = mysql_fetch_array($sql); $name1 = $row['name']; $hits1 = $row['hits']; echo <<<ECO <html> <script language="javascript"> increment(){ // some php code to increase the hits in database where name = $name1 } </script> <input type="button" value="increment" onclick="increment();" name="button"> </html> ECO; ?> sorry for the code to be really haphazard..i jst started with php.....now i dont know wat code to put to increment the hits in increment function since it would also use varialble $name1 and $index1.....
×
×
  • 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.