View Full Version : Why am I getting this error?
DrewM
03-05-2006, 10:49 PM
Well I was poting the "user quick links hack" for presonal use and evry thing was working fine until you save the error is:
Database error in vBulletin 3.5.4:
Invalid SQL:
UPDATE usertextfield SET
customquicklinks = 'a:1:{i:0;s:111:\"a:2:{s:5:\"title\";s:11:\"Melon Fresh\";s:3:\"url\";s:56:\"http://sim2world.com/forum/profile.php?do=editquicklinks\";}\";}'
WHERE userid = Array[userid];
Error Number : 1064
You're not passing a userid to the query.
DrewM
03-06-2006, 09:25 AM
How can I do this I'm currtenly using:
userid = $vbulletin->userinfo[userid]
Is this right?
No, use this:
$userid = $vbulletin->userinfo['userid'];
DrewM
03-06-2006, 09:45 AM
thank you, but still getting errors this is my error now:
Database error in vBulletin 3.5.4:
Invalid SQL:
UPDATE usertextfield SET
customquicklinks = 'a:1:{i:0;s:62:\"a:2:{s:5:\"title\";s:4:\"Test\";s:3:\"url\";s:15:\"http://test.com\";}\";}'
WHERE userid = = Array['userid'];;
MySQL 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 '= Array['userid']' at line 3
Error Number : 1064
And well heres the update code:
if ($_REQUEST['do'] == 'updatequicklinks')
{
require_once(DIR . '/includes/functions_misc.php');
$vbulletin->input->clean_array_gpc('p', array(
'existinglinks' => INT,
));
$quicklinks = array();
for ($i = 1;$i <= $existinglinks;$i++)
{
$title = '';$url = '';
if ($title = htmlspecialchars(trim($_REQUEST['quicklink' . $i . '_title'])) AND $url = htmlspecialchars(trim($_REQUEST['quicklink' . $i . '_url'])))
{
$quicklinks[] = serialize(array('title' => $title, 'url' => 'http://' . $url));
}
}
for ($i = 0;$i < 3;$i++)
{
$title = '';$url = '';
if ($title = trim($_REQUEST['newlink' . $i . '_title']) AND $url = trim($_REQUEST['newlink' . $i . '_url']))
{
$quicklinks[] = serialize(array('title' => $title, 'url' => 'http://' . $url));
}
}
if (count($quicklinks))
{
$db->query("UPDATE " . TABLE_PREFIX . "usertextfield SET
customquicklinks = '" . addslashes(serialize($quicklinks)) . "'
WHERE userid = $userid = $vbulletin->userinfo['userid'];
");
}
else
{
$db->query("UPDATE " . TABLE_PREFIX . "usertextfield SET
customquicklinks = ''
WHERE $userid = $vbulletin->userinfo['userid'];
");
}
$url = 'profile.php?do=editquicklinks';
eval(print_standard_redirect($vbphrase['quicklinks_saved'],0));
}
Brad, this is in a query'
Larry:
if ($_REQUEST['do'] == 'updatequicklinks')
{
require_once(DIR . '/includes/functions_misc.php');
$vbulletin->input->clean_array_gpc('p', array(
'existinglinks' => INT,
));
$quicklinks = array();
for ($i = 1;$i <= $existinglinks;$i++)
{
$title = '';$url = '';
if ($title = htmlspecialchars(trim($_REQUEST['quicklink' . $i . '_title'])) AND $url = htmlspecialchars(trim($_REQUEST['quicklink' . $i . '_url'])))
{
$quicklinks[] = serialize(array('title' => $title, 'url' => 'http://' . $url));
}
}
for ($i = 0;$i < 3;$i++)
{
$title = '';$url = '';
if ($title = trim($_REQUEST['newlink' . $i . '_title']) AND $url = trim($_REQUEST['newlink' . $i . '_url']))
{
$quicklinks[] = serialize(array('title' => $title, 'url' => 'http://' . $url));
}
}
if (count($quicklinks))
{
$db->query("UPDATE " . TABLE_PREFIX . "usertextfield SET
customquicklinks = '" . addslashes(serialize($quicklinks)) . "'
WHERE userid = {$vbulletin->userinfo['userid']};
");
}
else
{
$db->query("UPDATE " . TABLE_PREFIX . "usertextfield SET
customquicklinks = ''
WHERE userid = {$vbulletin->userinfo['userid']};
");
}
$url = 'profile.php?do=editquicklinks';
eval(print_standard_redirect($vbphrase['quicklinks_saved'],0));
}
Notice that the $vbulletin calls are surrounded in curley braces - this is necessary for substitution inside strings, if you escape the string and use a concatenation operator its different.
DrewM
03-06-2006, 06:55 PM
thanks I'm just starting to learn php to mySQL.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.