Jump to content

rjliquigan

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

rjliquigan's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Gettin this error: Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/w/i/s/wishitlist/html/viewmyitems.php on line 59 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/content/w/i/s/wishitlist/html/viewmyitems.php on line 59 Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/content/w/i/s/wishitlist/html/viewmyitems.php on line 60 Heres my code: // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); //checks cookies to make sure they are logged in if(isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { //if the cookie has the wrong password, they are taken to the login page if ($pass != $info['password']) { header("Location: main.html"); } //otherwise they are shown the admin area else { echo "<table align=\"right\" valign=\"top\" background=\"Main_files/PhotoGray_bg_c-1.jpg\"><td><a href=logout.php target=\"_self\"><font face=\"Arial\" color=\"#667C26\" style=\"text-decoration:none\">Logout</font></a></td></table>"; } } } else //if the cookie does not exist, they are taken to the login screen { header("Location: login.php"); } $username = $_COOKIE['ID_my_site']; $usernameclean = preg_replace("/[^A-Za-z0-9]/","",$username); $query="SELECT mygroups FROM $usernameclean"; $result=mysql_query($query); $num=mysql_numrows($result); echo "<b><center><font size=4 face=\"Arial\" color=\"#667C26\">My items</center></b><br><br \></font>"; echo "<font size=1 face=\"Arial\" color=\"#667C26\">Click the group you wish to Edit or View<br><br \></font>"; $i=0; while ($i < $num) { $mygroups=mysql_result($result,$i,"mygroups"); if($i!=0) { $items = mysql_query("SELECT * FROM $usercheck WHERE mygroups = '$mygroups'"); $row = mysql_fetch_row($items); $Item1 = $row[2]; $Item2 = $row[3]; $Item3 = $row[4]; $Item4 = $row[5]; $Item5 = $row[6]; $Item6 = $row[7]; $Item7 = $row[8]; $Item8 = $row[9]; $Item9 = $row[10]; $Item10 = $row[11]; print <<< EOF <a href="viewgroup.php?group=$mygroups" target="_self" style="text-decoration:none"><font face="Arial" color="#667C26"> <b>$mygroups</b></font></a><br> EOF; echo $Item1; echo $Item2; echo $Item3; echo $Item4; echo $Item5; echo $Item6; echo $Item7; echo $Item8; echo $Item9; echo $Item10; } $i++; }
  2. okay i wrote this first to enter a username to the database: $usercheck = $_POST['username']; $check = mysql_query("SELECT username FROM users WHERE username = '$usercheck'") or die(mysql_error()); $check2 = mysql_num_rows($check); everything works and writes perfectly to the database. Now i want to change it so instead of username it will be an email so i need to put special characters @ and "." so i used this: $usercheck = preg_replace("/[^a-zA-Z0-9s]/", "", $usercheck); it takes out the @ and "." but it wont write to any other tables. Please help, thank you so much!
  3. Hi all, I'm having problems with writing @ and "." I'm having a user name as their email address but its not working properly, if i dont use speacial characters it works fine. So i used a string to pull out the @ . sign but it doesnt work right. Hopefully someone here can help. heres what i got: $usercheck = $_POST['username']; $usercheck = preg_replace("/[^a-zA-Z0-9s]/", "", $usercheck); $check = mysql_query("SELECT username FROM users WHERE username = '$usercheck'") or die(mysql_error()); $check2 = mysql_num_rows($check);
  4. Hello all, new to the php scene. I'm having problems writing capital letters into the database: For example when i input MerryChristmas it will write erryhristmas or Testing123 it would be esting123. Any help would be greatly appreciated thank you heres what it looks like write now: $groupname=$_POST['groupname']; $newgroupname = preg_replace('/[^a-z0-9]/', '', $groupname); $check2 = mysql_query("SELECT groupname FROM groups WHERE groupname = '$newgroupname'") or die(mysql_error()); $check3 = mysql_num_rows($check2);
×
×
  • 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.